Ejemplo n.º 1
0
        public static string EncryptToJson(byte[] privateKey, string password)
        {
            byte[]          publicKey  = Secp256k1.DerivePublicKey(privateKey);
            string          address    = SimpleWallet.PublicKeyToAddress(publicKey);
            KeyStoreService keyStore   = new KeyStoreService();
            string          jsonString = keyStore.EncryptAndGenerateDefaultKeyStoreAsJson(password, privateKey, address);
            JObject         json       = JObject.Parse(jsonString);

            json["address"] = json["address"].ToString().Replace("0x", "");
            return(json.ToString());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// return address starts with '0x'.
 /// </summary>
 /// <param name="priKey"></param>
 /// <returns></returns>
 public static string PrivateKeyToAddress(byte[] priKey)
 {
     byte[] pubKey = Secp256k1.DerivePublicKey(priKey);
     return(SimpleWallet.PublicKeyToAddress(pubKey));
 }
Ejemplo n.º 3
0
 public static string RecoverAddress(byte[] msgHash, byte[] signature)
 {
     byte[] publickey = Secp256k1.RecoverPublickey(msgHash, signature);
     return(SimpleWallet.PublicKeyToAddress(publickey));
 }
Ejemplo n.º 4
0
 public SimpleWallet(byte[] priKey)
 {
     this._privateKey = priKey;
     this._publicKey  = Secp256k1.DerivePublicKey(this._privateKey);
     this.address     = SimpleWallet.PublicKeyToAddress(this._publicKey);
 }