/// <summary>
 /// Calculate key pair from the key seed.
 /// </summary>
 /// <param name="publicKey">Public key</param>
 /// <param name="expandedPrivateKey">Expanded form of the private key</param>
 /// <param name="privateKeySeed">Private key seed value</param>
 public static void KeyPairFromSeed(ArraySegment <byte> publicKey, ArraySegment <byte> expandedPrivateKey, ArraySegment <byte> privateKeySeed)
 {
     Ed25519Operations.crypto_sign_keypair(
         publicKey.Array, publicKey.Offset,
         expandedPrivateKey.Array, expandedPrivateKey.Offset,
         privateKeySeed.Array, privateKeySeed.Offset);
 }
Example #2
0
 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);
 }
        public static byte[] PublicKeyFromPrivateKey(byte[] privateKey)
        {
            byte[] publicKey = new byte[PublicKeySizeInBytes];

            Ed25519Operations.crypto_sign_keypair(publicKey, 0, privateKey, 0);
            //CryptoBytes.Wipe(privateKey);
            return(publicKey);
        }
        /// <summary>
        /// Calculate key pair from the key seed.
        /// </summary>
        /// <param name="publicKey">Public key</param>
        /// <param name="expandedPrivateKey">Expanded form of the private key</param>
        /// <param name="privateKeySeed">Private key seed value</param>
        public static void KeyPairFromSeed(out byte[] publicKey, out byte[] expandedPrivateKey, byte[] privateKeySeed)
        {
            var pk = new byte[PublicKeySize];
            var sk = new byte[ExpandedPrivateKeySize];

            Ed25519Operations.crypto_sign_keypair(pk, 0, sk, 0, privateKeySeed, 0);
            publicKey          = pk;
            expandedPrivateKey = sk;
        }
Example #5
0
        /// <summary>
        /// Calculate key pair from the key seed.
        /// </summary>
        /// <param name="publicKey">Public key</param>
        /// <param name="expandedPrivateKey">Expanded form of the private key</param>
        /// <param name="privateKeySeed">Private key seed value</param>
        public static void KeyPairFromSeed(ArraySegment <byte> publicKey, ArraySegment <byte> expandedPrivateKey, ArraySegment <byte> privateKeySeed)
        {
            Contract.Requires <ArgumentNullException>(publicKey.Array != null && expandedPrivateKey.Array != null && privateKeySeed.Array != null);
            Contract.Requires <ArgumentException>(expandedPrivateKey.Count == ExpandedPrivateKeySize && privateKeySeed.Count == PrivateKeySeedSize);
            Contract.Requires <ArgumentException>(publicKey.Count == PublicKeySize);

            Ed25519Operations.crypto_sign_keypair(
                publicKey.Array, publicKey.Offset,
                expandedPrivateKey.Array, expandedPrivateKey.Offset,
                privateKeySeed.Array, privateKeySeed.Offset);
        }
Example #6
0
        /// <summary>
        /// Calculate key pair from the key seed.
        /// </summary>
        /// <param name="publicKey">Public key</param>
        /// <param name="expandedPrivateKey">Expanded form of the private key</param>
        /// <param name="privateKeySeed">Private key seed value</param>
        public static void KeyPairFromSeed(out byte[] publicKey, out byte[] expandedPrivateKey, byte[] privateKeySeed)
        {
            Contract.Requires <ArgumentNullException>(privateKeySeed != null);
            Contract.Requires <ArgumentException>(privateKeySeed.Length == PrivateKeySeedSize);

            var pk = new byte[PublicKeySize];
            var sk = new byte[ExpandedPrivateKeySize];

            Ed25519Operations.crypto_sign_keypair(pk, 0, sk, 0, privateKeySeed, 0);
            publicKey          = pk;
            expandedPrivateKey = sk;
        }
Example #7
0
 public static void KeyPairFromSeed(Span <byte> publicKey, Span <byte> expandedPrivateKey, ReadOnlySpan <byte> privateKeySeed)
 {
     if (publicKey.Length != PublicKeySizeInBytes)
     {
         throw new ArgumentException("publicKey.Count");
     }
     if (expandedPrivateKey.Length != ExpandedPrivateKeySizeInBytes)
     {
         throw new ArgumentException("expandedPrivateKey.Count");
     }
     if (privateKeySeed.Length != PrivateKeySeedSizeInBytes)
     {
         throw new ArgumentException("privateKeySeed.Count");
     }
     Ed25519Operations.crypto_sign_keypair(publicKey, expandedPrivateKey, privateKeySeed);
 }
Example #8
0
        public static void KeyPairFromSeed(out byte[] publicKey, out byte[] expandedPrivateKey, byte[] privateKeySeed)
        {
            if (privateKeySeed == null)
            {
                throw new ArgumentNullException("privateKeySeed");
            }
            if (privateKeySeed.Length != PrivateKeySeedSizeInBytes)
            {
                throw new ArgumentException("privateKeySeed");
            }
            var pk = new byte[PublicKeySizeInBytes];
            var sk = new byte[ExpandedPrivateKeySizeInBytes];

            Ed25519Operations.crypto_sign_keypair(pk, 0, sk, 0, privateKeySeed, 0);
            publicKey          = pk;
            expandedPrivateKey = sk;
        }
Example #9
0
        internal static void KeyPairFromSeed(out byte[] internalKey, out byte[] expandedPrivateKey, byte[] privateKeySeed)
        {
            if (privateKeySeed == null)
            {
                throw new ArgumentNullException(nameof(privateKeySeed));
            }
            if (privateKeySeed.Length != 32 && privateKeySeed.Length != 33)
            {
                throw new ArgumentException("privateKeySeed");
            }
            var pk = new byte[internalKeySizeInBytes];
            var sk = new byte[ExpandedPrivateKeySizeInBytes];

            Ed25519Operations.crypto_sign_keypair(pk, 0, sk, 0, privateKeySeed, 0);
            internalKey        = pk;
            expandedPrivateKey = sk;
        }