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); }
public static string GenerateId(this Order order) { var bytes = order.GetBody(); return(AddressEncoding.FastHash(bytes, 0, bytes.Length).ToBase58()); }
private PrivateKeyAccount(byte[] privateKey, char chainId) { _publicKey = GetPublicKeyFromPrivateKey(privateKey); Address = AddressEncoding.GetAddressFromPublicKey(PublicKey, chainId); _privateKey = privateKey; }