Esempio n. 1
0
        public static Key LoadNBEcKey(String base58)
        {
            byte[] b   = Multibase.Decode(base58, out MultibaseEncoding encoding);
            EcKey  key = EcKey.FromAsn1(b);

            return(new Key(key.GetPrivKeyBytes()));
        }
Esempio n. 2
0
        public static void SaveEcKey(Key nbEcKey, IResourceDataAccess resourceDataAccess)
        {
            byte[] bytes  = EcKey.ToAsn1(nbEcKey.ToBytes(), nbEcKey.PubKey.ToBytes());
            string base58 = Multibase.Encode(MultibaseEncoding.Base58Btc, bytes);

            resourceDataAccess.Save(base58);
        }
Esempio n. 3
0
        public static string sign(EcKey ecKey, string input)
        {
            // return ecKey.Sign(input);
            String hash      = Sha256Hash(input);
            var    hashBytes = hexToBytes(hash);
            var    signature = ecKey.Sign(hashBytes);
            var    bytesHex  = bytesToHex(signature);

            return(bytesHex);
            //return bytesToHex(ecKey.Sign(hexToBytes(hash)));
        }
Esempio n. 4
0
 public static String DeriveSIN(EcKey ecKey)
 {
     byte[] pubKey = ecKey.PubKey;
     return(DeriveSIN(pubKey));
 }