Exemplo n.º 1
0
        private void SaveWallet(string path, string password)
        {
            var wallet = new JsonWallet
                         (
                EcdsaKeyPair.PrivateKey.ToHex(),
                HubPrivateKey.ToHex(),
                new Dictionary <ulong, string>(
                    _tpkeKeys.Select(p =>
                                     new System.Collections.Generic.KeyValuePair <ulong, string>(
                                         p.Key, p.Value.ToHex()
                                         )
                                     )
                    ),
                new Dictionary <ulong, string>(
                    _tsKeys.Select(p =>
                                   new System.Collections.Generic.KeyValuePair <ulong, string>(
                                       p.Key, p.Value.ToHex()
                                       )
                                   )
                    )
                         );
            var json             = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(wallet));
            var key              = Encoding.UTF8.GetBytes(password).KeccakBytes();
            var encryptedContent = Crypto.AesGcmEncrypt(key, json);

            File.WriteAllBytes(path, encryptedContent);
        }