Esempio n. 1
0
        public void PrivateKey_Sign_ReturnsExpectedSignatureDer()
        {
            var privateKey  = new ECPrivateSecurityService(_privateKey);
            var messageHash = HashUtil.Blake256(_message);
            var signature   = privateKey.Sign(messageHash).Serialize();

            Assert.Equal(_signature, signature);
        }
Esempio n. 2
0
        public void ECSecurityService_VerifySignature_VerifiesGeneratedSignatureAgainstPublicKey()
        {
            const bool isCompressed = false;
            var        messageHash  = HashUtil.Blake256(_message);
            var        signature    = new ECSignature(_signature);

            var privateSecurityService = new ECPrivateSecurityService(_privateKey);
            var publicKeyBytes         = privateSecurityService.GetPublicKey(isCompressed);
            var publicSecurityService  = new ECPublicSecurityService(publicKeyBytes);

            var hasValidSignature = publicSecurityService.VerifySignature(messageHash, signature);

            Assert.True(hasValidSignature);
        }
Esempio n. 3
0
 public PrivateKey(byte[] secret)
 {
     _ecPrivateSecurityService = new ECPrivateSecurityService(secret);
     Secret = secret;
 }