Skip to content

Commit

Permalink
Fixing BLS cross platform (#66)
Browse files Browse the repository at this point in the history
* Update IcpBlsUtil.cs

* Update EdjCase.Cryptography.BLS.csproj

* Update IcpBlsUtil.cs

* Update IcpBlsUtil.cs

* Update IcpBlsUtil.cs

* Update IcpBlsUtil.cs

* Update IcpBlsUtil.cs

* Update libbls384_256.dylib

* Update EdjCase.Cryptography.BLS.csproj

* Update IcpBlsUtil.cs

* Adding files to runtime specific folders

* Remove broken CustomMapperAttributes

* Changing to not use DLLImport

* Update dotnet.yml

* Fixing build

* dd

* d

* Adding hex string method

* Update IcpBlsUtil.cs

* Update dotnet.yml
  • Loading branch information
Gekctek authored Apr 25, 2023
1 parent 6a9be15 commit bcfbb59
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 240 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
Expand All @@ -20,6 +20,8 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Install libdl
run: sudo apt update && sudo apt install -y libc-dev
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
30 changes: 0 additions & 30 deletions src/Candid/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,6 @@
- [CompoundTypeTable](#T-EdjCase-ICP-Candid-Models-CompoundTypeTable 'EdjCase.ICP.Candid.Models.CompoundTypeTable')
- [CompoundTypeIndexMap](#F-EdjCase-ICP-Candid-Models-CompoundTypeTable-CompoundTypeIndexMap 'EdjCase.ICP.Candid.Models.CompoundTypeTable.CompoundTypeIndexMap')
- [TryAdd(typeDef)](#M-EdjCase-ICP-Candid-Models-CompoundTypeTable-TryAdd-EdjCase-ICP-Candid-Models-Types-CandidCompoundType- 'EdjCase.ICP.Candid.Models.CompoundTypeTable.TryAdd(EdjCase.ICP.Candid.Models.Types.CandidCompoundType)')
- [CustomMapperAttribute](#T-EdjCase-ICP-Candid-Mapping-CustomMapperAttribute 'EdjCase.ICP.Candid.Mapping.CustomMapperAttribute')
- [#ctor(mapper)](#M-EdjCase-ICP-Candid-Mapping-CustomMapperAttribute-#ctor-EdjCase-ICP-Candid-Mapping-ICandidValueMapper- 'EdjCase.ICP.Candid.Mapping.CustomMapperAttribute.#ctor(EdjCase.ICP.Candid.Mapping.ICandidValueMapper)')
- [Mapper](#P-EdjCase-ICP-Candid-Mapping-CustomMapperAttribute-Mapper 'EdjCase.ICP.Candid.Mapping.CustomMapperAttribute.Mapper')
- [EmptyValue](#T-EdjCase-ICP-Candid-Models-EmptyValue 'EdjCase.ICP.Candid.Models.EmptyValue')
- [EncodedValue](#T-EdjCase-ICP-Candid-Models-HashTree-EncodedValue 'EdjCase.ICP.Candid.Models.HashTree.EncodedValue')
- [#ctor(value)](#M-EdjCase-ICP-Candid-Models-HashTree-EncodedValue-#ctor-System-Byte[]- 'EdjCase.ICP.Candid.Models.HashTree.EncodedValue.#ctor(System.Byte[])')
Expand Down Expand Up @@ -6061,33 +6058,6 @@ True if added, otherwise false
| ---- | ---- | ----------- |
| typeDef | [EdjCase.ICP.Candid.Models.Types.CandidCompoundType](#T-EdjCase-ICP-Candid-Models-Types-CandidCompoundType 'EdjCase.ICP.Candid.Models.Types.CandidCompoundType') | Type to add to table |

<a name='T-EdjCase-ICP-Candid-Mapping-CustomMapperAttribute'></a>
## CustomMapperAttribute `type`

##### Namespace

EdjCase.ICP.Candid.Mapping

##### Summary

An attribute that specifies a custom mapper for the class, struct, property or field

<a name='M-EdjCase-ICP-Candid-Mapping-CustomMapperAttribute-#ctor-EdjCase-ICP-Candid-Mapping-ICandidValueMapper-'></a>
### #ctor(mapper) `constructor`

##### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| mapper | [EdjCase.ICP.Candid.Mapping.ICandidValueMapper](#T-EdjCase-ICP-Candid-Mapping-ICandidValueMapper 'EdjCase.ICP.Candid.Mapping.ICandidValueMapper') | The object mapper to use for the decorated item |

<a name='P-EdjCase-ICP-Candid-Mapping-CustomMapperAttribute-Mapper'></a>
### Mapper `property`

##### Summary

The object mapper to use for the decorated item

<a name='T-EdjCase-ICP-Candid-Models-EmptyValue'></a>
## EmptyValue `type`

Expand Down
13 changes: 0 additions & 13 deletions src/Candid/API.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Candid/CandidConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ private ICandidValueMapper ResolveMapper(Type type)

private ICandidValueMapper ResolveUncached(Type type)
{
CustomMapperAttribute? mapperAttr = type.GetCustomAttribute<CustomMapperAttribute>();
if (mapperAttr != null)
{
return mapperAttr.Mapper;
}
ICandidValueMapper? mapper = null;
if (this._options.CustomMappers != null)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Candid/Mapping/IResolvableTypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,7 @@ private static IResolvableTypeInfo BuildRecord(Type objType)
{
tag = CandidTag.FromName(property.Name);
}
CustomMapperAttribute? customMapperAttribute = property.GetCustomAttribute<CustomMapperAttribute>();

PropertyMetaData propertyMetaData = new(property, customMapperAttribute?.Mapper);
PropertyMetaData propertyMetaData = new(property, CustomMapper: null); // TODO attribute custom mapper
propertyMetaDataMap.Add(tag, propertyMetaData);
}
List<Type> dependencies = propertyMetaDataMap
Expand Down
18 changes: 0 additions & 18 deletions src/Candid/Mapping/MapperAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@ public CandidTagAttribute(string name)
}
}

/// <summary>
/// An attribute that specifies a custom mapper for the class, struct, property or field
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field)]
public class CustomMapperAttribute : Attribute
{
/// <summary>
/// The object mapper to use for the decorated item
/// </summary>
public ICandidValueMapper Mapper { get; }

/// <param name="mapper">The object mapper to use for the decorated item</param>
public CustomMapperAttribute(ICandidValueMapper mapper)
{
this.Mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
}
}

/// <summary>
/// An attribute to ignore a property/field of a class during serialization
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/EdjCase.Cryptography.BLS/Delegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ internal static class Delegates
public delegate ulong PublicKeyDeserialize(ref Interop.PublicKey pub, [In] byte[] buf, ulong bufSize);
public delegate ulong SignatureDeserialize(ref Signature sig, [In] byte[] buf, ulong bufSize);
public delegate int Verify(in Signature sig, in PublicKey pub, [In] byte[] buf, ulong size);
public delegate int PublicKeySetHexStr(ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
}
}
23 changes: 7 additions & 16 deletions src/EdjCase.Cryptography.BLS/EdjCase.Cryptography.BLS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;osx-arm64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<RootNamespace>EdjCase.Cryptography.BLS</RootNamespace>
Expand All @@ -19,32 +20,22 @@
<DocumentationFile>API.xml</DocumentationFile>
<DocumentationMarkdown>$(MSBuildProjectDirectory)\API.md</DocumentationMarkdown>
<UseAppHost>true</UseAppHost>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>


<ItemGroup>
<None Include="README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<None Update="lib\libbls384_256.so">
<Link>libbls384_256.so</Link>
<PackagePath>runtimes\linux-x64\native</PackagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<None Include="runtimes/**/*">
<Pack>true</Pack>
</None>
<None Update="lib\libbls384_256.dylib">
<Link>libbls384_256.dylib</Link>
<PackagePath>runtimes\osx-x64\native</PackagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>true</Pack>
</None>
<None Update="lib\bls384_256.dll">
<Link>bls384_256.dll</Link>
<PackagePath>runtimes\win-x64\native</PackagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>true</Pack>
<PackagePath>runtimes</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

Expand Down
Loading

0 comments on commit bcfbb59

Please sign in to comment.