Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public static byte[] GenerateBinaryId <T>(this T transaction) where T : Transaction
        {
            var bodyBytes = transaction.GetIdBytes();

            return(AddressEncoding.FastHash(bodyBytes, 0, bodyBytes.Length));
        }
Пример #4
0
        public static string GenerateId <T>(this T transaction) where T : Transaction
        {
            var bodyBytes = transaction.GetIdBytes();

            return(AddressEncoding.FastHash(bodyBytes, 0, bodyBytes.Length).ToBase58());
        }
Пример #5
0
 private PrivateKeyAccount(byte[] privateKey, char chainId)
 {
     _publicKey  = GetPublicKeyFromPrivateKey(privateKey);
     Address     = AddressEncoding.GetAddressFromPublicKey(PublicKey, chainId);
     _privateKey = privateKey;
 }
Пример #6
0
        public static string GenerateId(this Order order)
        {
            var bytes = order.GetBytes();

            return(AddressEncoding.FastHash(bytes, 0, bytes.Length).ToBase58());
        }