Ejemplo n.º 1
0
        public void TestVerifyWithImportedPublicKey()
        {
            var privateKey     = _context.GeneratePrivateKey();
            var publicKey      = _context.GetPublicKeyFromPrivateKey(privateKey);
            var data           = Encoding.UTF8.GetBytes("Testing testing 1 2 3");
            var signingContext = Encoding.UTF8.GetBytes("Testing testing 1 2 3 context");
            var signature      = _context.Sign(privateKey, data, signingContext);

            var blob = _context.ExportPublicKey(publicKey);

            var importedKey = _context.GetPublicKeyFromBytes(blob);
            var signatureWithImportedKey = _context.GetSignatureFromBytes(signature.SignatureBytes, importedKey.Bytes);

            _context.Verify(signatureWithImportedKey, data, signingContext).Should()
            .BeTrue("signature should verify with imported public key");
        }