Пример #1
0
        public static PubKey FromBase58(string base58)
        {
            var curve = Curves.GetCurve(base58.Substring(0, 4));
            var bytes = Base58.Parse(base58, curve.PrivateKeyPrefix);

            return(new PubKey(bytes, curve.Kind, true));
        }
Пример #2
0
        internal PubKey(byte[] bytes, ECKind kind, bool flush = false)
        {
            if (bytes.Length < 32)
            {
                throw new ArgumentException("Invalid public key length", nameof(bytes));
            }

            Curve = Curves.GetCurve(kind);
            Store = new PlainSecretStore(bytes);

            if (flush)
            {
                bytes.Flush();
            }
        }
Пример #3
0
        }                                                                       //TODO: check key strength

        internal Key(byte[] bytes, ECKind kind, bool flush = false)
        {
            if (bytes.Length < 32)
            {
                throw new ArgumentException("Invalid private key length", nameof(bytes));
            }

            Curve = Curves.GetCurve(kind);

            var privateKey = Curve.GetPrivateKey(bytes);

            Store = new PlainSecretStore(privateKey);

            privateKey.Flush();
            if (flush)
            {
                bytes.Flush();
            }
        }