示例#1
0
        public void SignatureKeyCheck()
        {
            DigitalSignatureUtils.RetrieveKeyPair("addr1");

            var pubKey = DigitalSignatureUtils.RetrievePublicKey();

            Assert.IsTrue(pubKey != null);
        }
示例#2
0
        public void SignatureValidationBetweenTwoUsers()
        {
            //User1
            DigitalSignatureUtils.AssignKeyPair("addr1");

            //User1 public key
            var pubKey = DigitalSignatureUtils.RetrievePublicKey();

            //Hashed data
            var hash = HashUtils.ComputeHashSha256(Encoding.UTF8.GetBytes("TestData"));

            //User1 signatured data
            var signature = DigitalSignatureUtils.SignData(hash);

            //User2
            DigitalSignatureUtils.AssignKeyPair("addr2");

            //Data validation
            var isValid = DigitalSignatureUtils.VerifySignature(hash, signature, pubKey);

            Assert.IsTrue(isValid);
        }