コード例 #1
0
 public HDNode(ExtKey masterKey)
 {
     this._masterKey = masterKey;
     this.PrivateKey = masterKey.PrivateKey.ToBytes();
     this.PublicKey  = Secp256k1.DerivePublicKey(this.PrivateKey);
     this.ChainCode  = masterKey.ChainCode;
     this.NodeType   = HDNodeType.PrivateKey;
 }
コード例 #2
0
ファイル: Keystore.cs プロジェクト: furuknap/VeChainTest
        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());
        }
コード例 #3
0
        public static byte[] Sign(byte[] msgHash, byte[] privatekey)
        {
            ECKey ecKey = new ECKey(privatekey, true);
            var   sign  = ecKey.Sign(msgHash);
            var   recId = Secp256k1.CalculateRecId(ecKey, sign, msgHash);

            sign.V = new byte[1] {
                Convert.ToByte(recId)
            };
            List <byte> signature = new List <byte>();

            signature.AddRange(sign.R.ToByteArrayUnsigned());
            signature.AddRange(sign.S.ToByteArrayUnsigned());
            signature.AddRange(sign.V);
            return(signature.ToArray());
        }
コード例 #4
0
ファイル: SimpleWallet.cs プロジェクト: furuknap/VeChainTest
 public static string RecoverAddress(byte[] msgHash, byte[] signature)
 {
     byte[] publickey = Secp256k1.RecoverPublickey(msgHash, signature);
     return(SimpleWallet.PublicKeyToAddress(publickey));
 }
コード例 #5
0
ファイル: SimpleWallet.cs プロジェクト: furuknap/VeChainTest
 public byte[] Sign(byte[] msgHash)
 {
     return(Secp256k1.Sign(msgHash, this._privateKey));
 }
コード例 #6
0
ファイル: SimpleWallet.cs プロジェクト: furuknap/VeChainTest
 /// <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));
 }
コード例 #7
0
ファイル: SimpleWallet.cs プロジェクト: furuknap/VeChainTest
 public SimpleWallet(byte[] priKey)
 {
     this._privateKey = priKey;
     this._publicKey  = Secp256k1.DerivePublicKey(this._privateKey);
     this.address     = SimpleWallet.PublicKeyToAddress(this._publicKey);
 }