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()); }
/// <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)); }
public static string RecoverAddress(byte[] msgHash, byte[] signature) { byte[] publickey = Secp256k1.RecoverPublickey(msgHash, signature); return(SimpleWallet.PublicKeyToAddress(publickey)); }
public SimpleWallet(byte[] priKey) { this._privateKey = priKey; this._publicKey = Secp256k1.DerivePublicKey(this._privateKey); this.address = SimpleWallet.PublicKeyToAddress(this._publicKey); }