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 override DictionaryObject GetJson() { var result = new DictionaryObject { { "type", (byte)TransactionType.Alias }, { "senderPublicKey", SenderPublicKey.ToBase58() }, { "alias", Alias }, { "fee", Assets.ZBS.AmountToLong(Fee) }, { "timestamp", Timestamp.ToLong() } }; if (Sender != null) { result.Add("sender", AddressEncoding.GetAddressFromPublicKey(SenderPublicKey, ChainId)); } return(result); }
public static byte[] GenerateBinaryId <T>(this T transaction) where T : Transaction { var bodyBytes = transaction.GetIdBytes(); return(AddressEncoding.FastHash(bodyBytes, 0, bodyBytes.Length)); }
public static string GenerateId <T>(this T transaction) where T : Transaction { var bodyBytes = transaction.GetIdBytes(); return(AddressEncoding.FastHash(bodyBytes, 0, bodyBytes.Length).ToBase58()); }
private PrivateKeyAccount(byte[] privateKey, char chainId) { _publicKey = GetPublicKeyFromPrivateKey(privateKey); Address = AddressEncoding.GetAddressFromPublicKey(PublicKey, chainId); _privateKey = privateKey; }
public static string GenerateId(this Order order) { var bytes = order.GetBytes(); return(AddressEncoding.FastHash(bytes, 0, bytes.Length).ToBase58()); }