Beispiel #1
0
        public void hash160()
        {
            var data   = new byte[] { 1, 2, 3, 4 };
            var result = Hashes.Hash160(data);

            Assert.Equal("706ea1768da7f0c489bf931b362c2d26d8cbd2ec", result.ToString());
        }
Beispiel #2
0
        public void siphash()
        {
            var hasher = new Hashes.SipHasher(0x0706050403020100UL, 0x0F0E0D0C0B0A0908UL);

            Assert.Equal(0x726fdb47dd0e0e31UL, hasher.Finalize());
            var t0 = new byte[] { 0 };

            hasher.Write(t0);
            Assert.Equal(0x74f839c593dc67fdUL, hasher.Finalize());
            var t1 = new byte[] { 1, 2, 3, 4, 5, 6, 7 };

            hasher.Write(t1);
            Assert.Equal(0x93f5f5799a932462UL, hasher.Finalize());
            hasher.Write(0x0F0E0D0C0B0A0908UL);
            Assert.Equal(0x3f2acc7f57c29bdbUL, hasher.Finalize());
            var t2 = new byte[] { 16, 17 };

            hasher.Write(t2);
            Assert.Equal(0x4bc1b3f0968dd39cUL, hasher.Finalize());
            var t3 = new byte[] { 18, 19, 20, 21, 22, 23, 24, 25, 26 };

            hasher.Write(t3);
            Assert.Equal(0x2f2e6163076bcfadUL, hasher.Finalize());
            var t4 = new byte[] { 27, 28, 29, 30, 31 };

            hasher.Write(t4);
            Assert.Equal(0x7127512f72f27cceUL, hasher.Finalize());
            hasher.Write(0x2726252423222120UL);
            Assert.Equal(0x0e3ea96b5304a7d0UL, hasher.Finalize());
            hasher.Write(0x2F2E2D2C2B2A2928UL);
            Assert.Equal(0xe612a3cb9ecba951UL, hasher.Finalize());

            Assert.Equal(0x7127512f72f27cceUL, Hashes.SipHash(0x0706050403020100UL, 0x0F0E0D0C0B0A0908UL, new uint256("1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100")));

            // Check test vectors from spec, one byte at a time
            var hasher2 = new Hashes.SipHasher(0x0706050403020100UL, 0x0F0E0D0C0B0A0908UL);

            for (byte x = 0; x < this.siphash_4_2_testvec.Length; ++x)
            {
                Assert.Equal(hasher2.Finalize(), this.siphash_4_2_testvec[x]);
                hasher2.Write(new byte[] { x });
            }
            // Check test vectors from spec, eight bytes at a time
            var hasher3 = new Hashes.SipHasher(0x0706050403020100UL, 0x0F0E0D0C0B0A0908UL);

            for (int x = 0; x < this.siphash_4_2_testvec.Length; x += 8)
            {
                Assert.Equal(hasher3.Finalize(), this.siphash_4_2_testvec[x]);
                hasher3.Write(uint64_t(x) | (uint64_t(x + 1) << 8) | (uint64_t(x + 2) << 16) | (uint64_t(x + 3) << 24) |
                              (uint64_t(x + 4) << 32) | (uint64_t(x + 5) << 40) | (uint64_t(x + 6) << 48) | (uint64_t(x + 7) << 56));
            }
        }
Beispiel #3
0
 private void T(uint expected, uint seed, string data)
 {
     Assert.Equal(Hashes.MurmurHash3(seed, Encoders.Hex.DecodeData(data)), expected);
 }
            public uint256 BlindMessage(byte[] message, PubKey rpubKey, PubKey signerPubKey)
            {
                var msg = new uint256(Hashes.SHA256(message));

                return(BlindMessage(msg, rpubKey, signerPubKey));
            }
            public bool VerifyUnblindedSignature(UnblindedSignature signature, byte[] data)
            {
                var hash = new uint256(Hashes.SHA256(data));

                return(SchnorrBlinding.VerifySignature(hash, signature, Key.PubKey));
            }