Example #1
0
 public static void KeyPairFromSeed(ArraySegment <byte> publicKey, ArraySegment <byte> expandedPrivateKey,
                                    ArraySegment <byte> privateKeySeed)
 {
     if (publicKey.Array == null)
     {
         throw new ArgumentNullException(nameof(publicKey));
     }
     if (expandedPrivateKey.Array == null)
     {
         throw new ArgumentNullException(nameof(publicKey));
     }
     if (privateKeySeed.Array == null)
     {
         throw new ArgumentNullException(nameof(publicKey));
     }
     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.CryptoSignKeypair(
         publicKey.Array, publicKey.Offset,
         expandedPrivateKey.Array, expandedPrivateKey.Offset,
         privateKeySeed.Array, privateKeySeed.Offset);
 }
Example #2
0
        public static void KeyPairFromSeed(out byte[] publicKey, out byte[] expandedPrivateKey, byte[] privateKeySeed)
        {
            if (privateKeySeed == null)
            {
                throw new ArgumentNullException(nameof(privateKeySeed));
            }
            if (privateKeySeed.Length != PrivateKeySeedSizeInBytes)
            {
                throw new ArgumentException("privateKeySeed");
            }
            var pk = new byte[PublicKeySizeInBytes];
            var sk = new byte[ExpandedPrivateKeySizeInBytes];

            Ed25519Operations.CryptoSignKeypair(pk, 0, sk, 0, privateKeySeed, 0);
            publicKey          = pk;
            expandedPrivateKey = sk;
        }