public static new EthereumEcdsaNative Generate(IAccountDerivation accountFactory) { using (AutoObjectPool <Secp256k1> .Get(out var secp256k1)) { return(Generate(0, secp256k1, accountFactory)); } }
static EthereumEcdsaBouncyCastle GenerateSingle(uint accountIndex, IAccountDerivation accountFactory) { var privateKey = accountFactory.GeneratePrivateKey(accountIndex); var keyBigInt = BigIntegerConverter.GetBigInteger(privateKey, signed: false, byteCount: PRIVATE_KEY_SIZE); keyBigInt = Secp256k1Curve.EnforceLowS(keyBigInt); // Return our private key instance. return(new EthereumEcdsaBouncyCastle(privateKey, EthereumEcdsaKeyType.Private)); }
public static new IEnumerable <EthereumEcdsaNative> Generate(int count, IAccountDerivation accountFactory) { using (AutoObjectPool <Secp256k1> .Get(out var secp256k1)) { for (uint i = 0; i < count; i++) { yield return(Generate(i, secp256k1, accountFactory)); } } }
/// <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)); } }
/// <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)); } }
/// <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)); } }
static EthereumEcdsaNative Generate(uint accountIndex, Secp256k1 secp256k1, IAccountDerivation accountFactory) { var privateKey = accountFactory.GeneratePrivateKey(accountIndex); if (!secp256k1.SecretKeyVerify(privateKey)) { var errMsg = "Unmanaged EC library failed to valid private key. "; if (IncludeKeyDataInExceptions) { errMsg += $"Private key: {privateKey.ToHexString()}"; } throw new Exception(errMsg); } var keyBigInt = BigIntegerConverter.GetBigInteger(privateKey, signed: false, byteCount: PRIVATE_KEY_SIZE); keyBigInt = Secp256k1Curve.EnforceLowS(keyBigInt); privateKey = BigIntegerConverter.GetBytes(keyBigInt, PRIVATE_KEY_SIZE); return(new EthereumEcdsaNative(privateKey, EthereumEcdsaKeyType.Private)); }
public static new IEnumerable <EthereumEcdsaBouncyCastle> Generate(int count, IAccountDerivation accountFactory) { for (uint i = 0; i < count; i++) { yield return(GenerateSingle(i, accountFactory)); } }
public static new EthereumEcdsaBouncyCastle Generate(IAccountDerivation accountFactory) { return(GenerateSingle(0, accountFactory)); }