コード例 #1
0
ファイル: Ed25519.cs プロジェクト: zhamppx97/PhantasmaChain
 public static void KeyPairFromSeed(ArraySegment <byte> publicKey, ArraySegment <byte> expandedPrivateKey, ArraySegment <byte> privateKeySeed)
 {
     if (publicKey.Array == null)
     {
         throw new ArgumentNullException("publicKey.Array");
     }
     if (expandedPrivateKey.Array == null)
     {
         throw new ArgumentNullException("expandedPrivateKey.Array");
     }
     if (privateKeySeed.Array == null)
     {
         throw new ArgumentNullException("privateKeySeed.Array");
     }
     if (publicKey.Count != PublicKeySizeInBytes)
     {
         throw new ArgumentException("publicKey.Count");
     }
     if (expandedPrivateKey.Count != ExpandedPrivateKeySizeInBytes)
     {
         throw new ArgumentException("expandedPrivateKey.Count");
     }
     if (privateKeySeed.Count != PrivateKeySeedSizeInBytes)
     {
         throw new ArgumentException("privateKeySeed.Count");
     }
     Ed25519Operations.crypto_sign_keypair(
         publicKey.Array, publicKey.Offset,
         expandedPrivateKey.Array, expandedPrivateKey.Offset,
         privateKeySeed.Array, privateKeySeed.Offset);
 }
コード例 #2
0
ファイル: Ed25519.cs プロジェクト: zhamppx97/PhantasmaChain
        public static bool Verify(byte[] signature, byte[] message, byte[] publicKey)
        {
            Throw.If(signature == null, "signature");
            Throw.If(message == null, "message");
            Throw.If(publicKey == null, "publicKey");
            Throw.If(signature.Length != SignatureSizeInBytes, $"Signature size must be {SignatureSizeInBytes}");
            Throw.If(publicKey.Length != PublicKeySizeInBytes, $"Public key size must be {PublicKeySizeInBytes}");

            return(Ed25519Operations.VerifySignature(signature, 0, message, 0, message.Length, publicKey, 0));
        }
コード例 #3
0
ファイル: Ed25519.cs プロジェクト: zhamppx97/PhantasmaChain
        public static void Sign(ArraySegment <byte> signature, ArraySegment <byte> message, ArraySegment <byte> expandedPrivateKey)
        {
            Throw.If(signature.Array == null, "signature.Array");
            Throw.If(signature.Count != SignatureSizeInBytes, "signature.Count");
            Throw.If(expandedPrivateKey.Array == null, "expandedPrivateKey.Array");
            Throw.If(expandedPrivateKey.Count != ExpandedPrivateKeySizeInBytes, "expandedPrivateKey.Count");
            Throw.If(message.Array == null, "message.Array");

            Ed25519Operations.GenerateSignature(signature.Array, signature.Offset, message.Array, message.Offset, message.Count, expandedPrivateKey.Array, expandedPrivateKey.Offset);
        }
コード例 #4
0
ファイル: Ed25519.cs プロジェクト: zhamppx97/PhantasmaChain
        public static void KeyPairFromSeed(out byte[] publicKey, out byte[] expandedPrivateKey, byte[] privateKeySeed)
        {
            Throw.If(privateKeySeed == null, "privateKeySeed");
            Throw.If(privateKeySeed.Length != PrivateKeySeedSizeInBytes, $"privateKeySeed length should be {PrivateKeySeedSizeInBytes}");

            var pk = new byte[PublicKeySizeInBytes];
            var sk = new byte[ExpandedPrivateKeySizeInBytes];

            Ed25519Operations.crypto_sign_keypair(pk, 0, sk, 0, privateKeySeed, 0);
            publicKey          = pk;
            expandedPrivateKey = sk;
        }
コード例 #5
0
ファイル: Ed25519.cs プロジェクト: zhamppx97/PhantasmaChain
 public static bool Verify(ArraySegment <byte> signature, ArraySegment <byte> message, ArraySegment <byte> publicKey)
 {
     Throw.If(signature.Count != SignatureSizeInBytes, $"Signature size must be {SignatureSizeInBytes}");
     Throw.If(publicKey.Count != PublicKeySizeInBytes, $"Public key size must be {PublicKeySizeInBytes}");
     return(Ed25519Operations.VerifySignature(signature.Array, signature.Offset, message.Array, message.Offset, message.Count, publicKey.Array, publicKey.Offset));
 }