Exemplo n.º 1
0
        public void TestGetPublicKeyFromPrivate()
        {
            var privateKey = _wrapper.GeneratePrivateKey();
            var publicKey  = _wrapper.GetPublicKeyFromPrivateKey(privateKey);

            publicKey.Bytes.Length.Should().Be(_wrapper.PublicKeyLength);
        }
Exemplo n.º 2
0
        public void TestFailureSigningVerification()
        {
            var key1 = _context.GeneratePrivateKey();

            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(key1, data, signingContext);

            var key2       = _context.GeneratePrivateKey();
            var publicKey2 = _context.GetPublicKeyFromPrivateKey(key2);

            var invalidSignature = _context.GetSignatureFromBytes(signature.SignatureBytes, publicKey2.Bytes);

            _context.Verify(invalidSignature, data, signingContext)
            .Should().BeFalse("signature should not verify with incorrect key");
        }