Skip to content

Commit

Permalink
Adjust zk code
Browse files Browse the repository at this point in the history
  • Loading branch information
chopin-fan committed Dec 29, 2024
1 parent a2ef9a6 commit c752104
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 300 deletions.
14 changes: 0 additions & 14 deletions AElf.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.Core", "src\AElf.Kernel.FeatureDisable.Core\AElf.Kernel.FeatureDisable.Core.csproj", "{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Spec", "src\AElf.Sdk.CSharp.Spec\AElf.Sdk.CSharp.Spec.csproj", "{45A77C41-142E-4296-A14A-D53067EC8B75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Internal", "src\AElf.Sdk.CSharp.Internal\AElf.Sdk.CSharp.Internal.csproj", "{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1111,14 +1107,6 @@ Global
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.Build.0 = Release|Any CPU
{45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.Build.0 = Release|Any CPU
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1313,7 +1301,5 @@ Global
{A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
{8C0D86A4-D1A7-4B61-AC44-755F5AC75D67} = {4E54480A-D155-43ED-9736-1A5BE7957211}
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
{45A77C41-142E-4296-A14A-D53067EC8B75} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using AElf.Sdk.CSharp;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ private void WhitelistCryptographyHelpers(Whitelist whitelist)
{
whitelist
// Selectively allowed types and members
.Namespace("AElf.Cryptography.SecretSharing", Permission.Denied, type => type
.Type(typeof(SecretSharingHelper), Permission.Denied, member => member
.Member(nameof(SecretSharingHelper.DecodeSecret), Permission.Allowed)
))
.Namespace("AElf.Cryptography.Bn254", Permission.Denied, type => type
.Type(typeof(Bn254Helper), Permission.Denied, member => member
.Member(nameof(Bn254Helper.Bn254Pairing), Permission.Allowed)
Expand Down Expand Up @@ -229,7 +225,6 @@ private void WhitelistAElfTypes(Whitelist whitelist)
// Selectively allowed types and members
.Namespace("AElf.Cryptography.SecretSharing", Permission.Denied, type => type
.Type(typeof(SecretSharingHelper), Permission.Denied, member => member
.Member(nameof(SecretSharingHelper.DecodeSecret), Permission.Allowed)
));
.Member(nameof(SecretSharingHelper.DecodeSecret), Permission.Allowed)));
}
}
7 changes: 4 additions & 3 deletions src/AElf.Cryptography/Bn254/Bn254Helper.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
using Bn254.Net;
using NetBn254 = Bn254.Net;

namespace AElf.Cryptography.Bn254
{
public static class Bn254Helper
{
public static (byte[] x, byte[] y) Bn254G1Mul(byte[] x1, byte[] y1, byte[] s)
{
var (xUInt256, yUInt256) = global::Bn254.Net.Bn254.Mul(UInt256.FromBigEndianBytes(x1),
var (xUInt256, yUInt256) = NetBn254.Bn254.Mul(UInt256.FromBigEndianBytes(x1),
UInt256.FromBigEndianBytes(y1),
UInt256.FromBigEndianBytes(s));
return (xUInt256.ToBigEndianBytes(), yUInt256.ToBigEndianBytes());
}

Check warning on line 14 in src/AElf.Cryptography/Bn254/Bn254Helper.cs

View check run for this annotation

Codecov / codecov/patch

src/AElf.Cryptography/Bn254/Bn254Helper.cs#L9-L14

Added lines #L9 - L14 were not covered by tests

public static (byte[] x3, byte[] y3) Bn254G1Add(byte[] x1, byte[] y1, byte[] x2, byte[] y2)
{
var (x3UInt256, y3UInt256) = global::Bn254.Net.Bn254.Add(UInt256.FromBigEndianBytes(x1),
var (x3UInt256, y3UInt256) = NetBn254.Bn254.Add(UInt256.FromBigEndianBytes(x1),
UInt256.FromBigEndianBytes(y1),
UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2));
return (x3UInt256.ToBigEndianBytes(), y3UInt256.ToBigEndianBytes());
Expand All @@ -31,7 +32,7 @@ public static bool Bn254Pairing((byte[], byte[], byte[], byte[], byte[], byte[])
UInt256.FromBigEndianBytes(x3), UInt256.FromBigEndianBytes(y3));
}

Check warning on line 33 in src/AElf.Cryptography/Bn254/Bn254Helper.cs

View check run for this annotation

Codecov / codecov/patch

src/AElf.Cryptography/Bn254/Bn254Helper.cs#L28-L33

Added lines #L28 - L33 were not covered by tests

return global::Bn254.Net.Bn254.Pairing(elements);
return NetBn254.Bn254.Pairing(elements);
}

Check warning on line 36 in src/AElf.Cryptography/Bn254/Bn254Helper.cs

View check run for this annotation

Codecov / codecov/patch

src/AElf.Cryptography/Bn254/Bn254Helper.cs#L35-L36

Added lines #L35 - L36 were not covered by tests
}
}
28 changes: 0 additions & 28 deletions src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj

This file was deleted.

3 changes: 0 additions & 3 deletions src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs

This file was deleted.

61 changes: 0 additions & 61 deletions src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj

This file was deleted.

10 changes: 0 additions & 10 deletions src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<ProjectReference Include="..\AElf.Cryptography\AElf.Cryptography.csproj" />
<ProjectReference Include="..\AElf.CSharp.Core\AElf.CSharp.Core.csproj" />
<ProjectReference Include="..\AElf.Kernel.SmartContract.Shared\AElf.Kernel.SmartContract.Shared.csproj" />
<ProjectReference Include="..\AElf.Sdk.CSharp.Internal\AElf.Sdk.CSharp.Internal.csproj" />
</ItemGroup>

</Project>
5 changes: 2 additions & 3 deletions src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using AElf.Kernel.SmartContract;
using AElf.Types;
using AElf.Sdk.CSharp.Spec;

namespace AElf.Sdk.CSharp;

Expand All @@ -21,6 +20,6 @@ protected void Assert(bool asserted, string message = "Assertion failed!")
}

internal abstract void InternalInitialize(ISmartContractBridgeContext bridgeContext);
public IBuiltIns BuiltIns { get; internal set; }

// public IBuiltIns BuiltIns { get; internal set; }
}
2 changes: 0 additions & 2 deletions src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using AElf.Kernel.SmartContract;
using AElf.Sdk.CSharp.Internal;
using AElf.Sdk.CSharp.Spec;
using AElf.Types;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using AElf.Cryptography.ECDSA;
using AElf.CSharp.Core.Extension;
using AElf.Kernel;
using AElf.Sdk.CSharp;
using AElf.Standards.ACS3;
using AElf.Types;
using Google.Protobuf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AElf.Sdk.CSharp;
using AElf.Types;
using AElf.Types;
using Google.Protobuf.WellKnownTypes;

namespace AElf.Contracts.TestContract.VirtualTransactionEvent;
Expand Down
Loading

0 comments on commit c752104

Please sign in to comment.