Exemplo n.º 1
0
 private PrivateKeyAccount(byte[] privateKey, char scheme)
 {
     this.scheme     = scheme;
     publicKey       = GetPublicKeyFromPrivateKey(privateKey);
     address         = AddressEncoding.GetAddressFromPublicKey(publicKey, scheme);
     this.privateKey = privateKey;
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                { "type", (byte)TransactionType.Alias },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "alias", Alias },
                { "fee", Assets.WAVES.AmountToLong(Fee) },
                { "timestamp", Timestamp.ToLong() }
            };

            if (Sender != null)
            {
                result.Add("sender", AddressEncoding.GetAddressFromPublicKey(SenderPublicKey, ChainId));
            }

            return(result);
        }
        public static string GenerateId <T>(this T transaction) where T : Transaction
        {
            var bodyBytes = transaction.GetIdBytes();

            return(AddressEncoding.FastHash(bodyBytes, 0, bodyBytes.Length).ToBase58());
        }
Exemplo n.º 5
0
        public static byte[] GenerateBinaryId <T>(this T transaction) where T : Transaction
        {
            var bodyBytes = transaction.GetIdBytes();

            return(AddressEncoding.FastHash(bodyBytes, 0, bodyBytes.Length));
        }
Exemplo n.º 6
0
 private PrivateKeyAccount(byte[] privateKey, char scheme)
 {
     _publicKey  = GetPublicKeyFromPrivateKey(privateKey);
     Address     = AddressEncoding.GetAddressFromPublicKey(PublicKey, scheme);
     _privateKey = privateKey;
 }
Exemplo n.º 7
0
        public static string GenerateId(this Order order)
        {
            var bytes = order.GetBody();

            return(AddressEncoding.FastHash(bytes, 0, bytes.Length).ToBase58());
        }
Exemplo n.º 8
0
        public static byte[] GenerateBinaryId <T>(this T transaction) where T : Transaction
        {
            var txBytesForId = transaction.GetBytesForId();

            return(AddressEncoding.FastHash(txBytesForId, 0, txBytesForId.Length));
        }