public DataPassword Encrypt(string password)
        {
            var privKey = _rsaProvider.ExportParameters(false);
            var pub     = _rsaProvider.ExportParameters(true);

            _xml = _rsaProvider.ToXmlString(true);
            _rsaProvider.ImportParameters(privKey);

            var publicKey = PublicKey.From(_xml);
            var pass      = _rsaProvider.Encrypt(ConvertToByte($"{ _Internalkey }_{ password }"), false);

            return(new DataPassword(pass, publicKey));
        }
예제 #2
0
        /// Determines the public key for which `sig` is a valid signature for
        /// `msg`. Requires a verify-capable context.
        public PublicKey Recover(Message msg, RecoverableSigniture sig)

        {
            if (Caps == ContextFlag.SignOnly || Caps == ContextFlag.None)
            {
                throw new Exception("IncapableContext");
            }

            var pkBytes = new byte[64];


            if (Proxy.secp256k1_ecdsa_recover(Ctx, pkBytes, sig.Value, msg.Value) != 1)
            {
                throw new Exception("InvalidSignature");
            }
            return(PublicKey.From(pkBytes));
        }