private static byte[] GeneratePrivateKey(byte[] seed, int nonce) { var stream = new MemoryStream(seed.Length + 4); var writer = new BinaryWriter(stream); writer.Write(nonce); writer.Write(seed); var accountSeed = AddressEncoding.SecureHash(stream.ToArray(), 0, stream.ToArray().Length); var hashedSeed = SHA256.ComputeHash(accountSeed, 0, accountSeed.Length); var privateKey = hashedSeed.ToArray(); privateKey[0] &= 248; privateKey[31] &= 127; privateKey[31] |= 64; return(privateKey); }
private PrivateKeyAccount(byte[] privateKey, char scheme) { _publicKey = GetPublicKeyFromPrivateKey(privateKey); Address = AddressEncoding.GetAddressFromPublicKey(PublicKey, scheme); _privateKey = privateKey; }