Пример #1
0
        public void DeterministicECDSA()
        {
            var privateKey = Hashes.SHA256(new byte[]{ 0x01 });
            var signer = new ECDsaSigner(new Key(privateKey));
            var signature = signer.GenerateSignature(Encoders.ASCII.Decode("hello word"));

            Assert.IsTrue(signature.R == TestUtils.HexToBigInteger("8804e75cbdac8ab296df53eaf8f64cee01c283aa4a18f3f5853317faa282d4cd"));
            Assert.IsTrue(signature.S == TestUtils.HexToBigInteger("42706d708c4fbf0dd075f3d3152872c7bd7e5ec9e2f691d33ce040d448f42002"));
        }
Пример #2
0
        public void CanSignMessage()
        {
            var dA = Hashes.SHA256(new byte[] { 0x01 });
            var k = Encoders.Hex.Decode("0098e9c07e8e6adb97b77d85b0c10a265e11737a89a3e37b");
            var rnd = new FakeRandom(k);
            var key = new Key(dA);

            var signer = new ECDsaSigner(rnd, key);

            var message = Encoders.Hex.Decode("66e98a165854cd07989b1ee0ec3f8dbe0ee3c2fb0051ef53a0be03457c4f21bc");
            var s1 = signer.GenerateSignature(message);
            Assert.IsTrue(signer.VerifySignature(message, s1));
            Assert.IsTrue(s1.R == (rnd.GetNextK()*Secp256k1.G).X%Secp256k1.N);

            Assert.IsTrue(ECDsaSigner.VerifySignature(message, s1.R, s1.S, key.PublicKey));
        }
Пример #3
0
        public ECDSASignature Sign(byte[] input)
        {
            var signer = new ECDsaSigner(this);

            return(signer.GenerateSignature(input));
        }
Пример #4
0
 public bool Verify(byte[] data, ECDSASignature signature)
 {
     return(ECDsaSigner.VerifySignature(data, signature, this));
 }
Пример #5
0
 public ECDSASignature Sign(byte[] input)
 {
     var signer = new ECDsaSigner(this);
     return signer.GenerateSignature(input);
 }