-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/1.12.2' into feature/mq
- Loading branch information
Showing
50 changed files
with
301 additions
and
770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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) = NetBn254.Bn254.Mul(UInt256.FromBigEndianBytes(x1), | ||
UInt256.FromBigEndianBytes(y1), | ||
UInt256.FromBigEndianBytes(s)); | ||
return (xUInt256.ToBigEndianBytes(), yUInt256.ToBigEndianBytes()); | ||
} | ||
|
||
public static (byte[] x3, byte[] y3) Bn254G1Add(byte[] x1, byte[] y1, byte[] x2, byte[] y2) | ||
{ | ||
var (x3UInt256, y3UInt256) = NetBn254.Bn254.Add(UInt256.FromBigEndianBytes(x1), | ||
UInt256.FromBigEndianBytes(y1), | ||
UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2)); | ||
return (x3UInt256.ToBigEndianBytes(), y3UInt256.ToBigEndianBytes()); | ||
} | ||
|
||
public static bool Bn254Pairing((byte[], byte[], byte[], byte[], byte[], byte[])[] input) | ||
{ | ||
var elements = new (UInt256, UInt256, UInt256, UInt256, UInt256, UInt256)[input.Length]; | ||
for (var i = 0; i < input.Length; i++) | ||
{ | ||
var (x1, y1, x2, y2, x3, y3) = input[i]; | ||
elements[i] = (UInt256.FromBigEndianBytes(x1), UInt256.FromBigEndianBytes(y1), | ||
UInt256.FromBigEndianBytes(x2), UInt256.FromBigEndianBytes(y2), | ||
UInt256.FromBigEndianBytes(x3), UInt256.FromBigEndianBytes(y3)); | ||
} | ||
|
||
return NetBn254.Bn254.Pairing(elements); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using Rebex.Security.Cryptography; | ||
|
||
namespace AElf.Cryptography.EdDSA | ||
{ | ||
public static class EdDsaHelper | ||
{ | ||
public static bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey) | ||
{ | ||
try | ||
{ | ||
var instance = new Ed25519(); | ||
instance.FromPublicKey(publicKey); | ||
return instance.VerifyMessage(message, signature); | ||
} | ||
catch (Exception e) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Nethereum.Util; | ||
|
||
namespace AElf.Cryptography.Keccak | ||
{ | ||
public static class KeccakHelper | ||
{ | ||
public static byte[] Keccak256(byte[] message) | ||
{ | ||
return Sha3Keccack.Current.CalculateHash(message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.