Example #1
0
 /// <summary>
 /// Creates an ECDSA instance with a freshly generated keypair.
 /// </summary>
 /// <returns>Returns the ECDSA instance which has the generated keypair.</returns>
 public static EthereumEcdsa Generate(IAccountDerivation accountFactory)
 {
     if (UseNativeLib)
     {
         return(EthereumEcdsaNative.Generate(accountFactory));
     }
     else
     {
         return(EthereumEcdsaBouncyCastle.Generate(accountFactory));
     }
 }
Example #2
0
 /// <summary>
 /// Creates an ECDSA instance with a freshly generated keypair.
 /// </summary>
 /// <returns>Returns the ECDSA instance which has the generated keypair.</returns>
 public static IEnumerable <EthereumEcdsa> Generate(int count, IAccountDerivation accountFactory)
 {
     if (UseNativeLib)
     {
         return(EthereumEcdsaNative.Generate(count, accountFactory));
     }
     else
     {
         return(EthereumEcdsaBouncyCastle.Generate(count, accountFactory));
     }
 }
Example #3
0
 /// <summary>
 /// Creates an ECDSA instance by recovering a public key given a hash, recovery ID, and r and s components of the resulting signature of the hash. Throws an exception if recovery is not possible.
 /// </summary>
 /// <param name="hash">The hash of the data which was signed.</param>
 /// <param name="recoveryId">The recovery ID of ECDSA during signing.</param>
 /// <param name="ecdsa_r">The r component of the ECDSA signature for the provided hash.</param>
 /// <param name="ecdsa_s">The s component of the ECDSA signature for the provided hash.</param>
 /// <returns>Returns the quotient/public key which was used to sign this hash.</returns>
 public static EthereumEcdsa Recover(Span <byte> hash, byte recoveryId, BigInteger ecdsa_r, BigInteger ecdsa_s)
 {
     if (UseNativeLib)
     {
         return(EthereumEcdsaNative.Recover(hash, recoveryId, ecdsa_r, ecdsa_s));
     }
     else
     {
         return(EthereumEcdsaBouncyCastle.Recover(hash, recoveryId, ecdsa_r, ecdsa_s));
     }
 }
Example #4
0
        /// <summary>
        /// Creates an ECDSA instance with a freshly generated keypair.
        /// </summary>
        /// <returns>Returns the ECDSA instance which has the generated keypair.</returns>
        public static EthereumEcdsa Generate(IAccountDerivation accountFactory = null)
        {
            // If the account factory is null, we use a random factory
            if (accountFactory == null)
            {
                accountFactory = new SystemRandomAccountDerivation();
            }

            // Determine which library to use
            if (UseNativeLib)
            {
                return(EthereumEcdsaNative.Generate(accountFactory));
            }
            else
            {
                return(EthereumEcdsaBouncyCastle.Generate(accountFactory));
            }
        }