Пример #1
0
        public void TestKeyLength()
        {
            var signing = new Signing(null);
            var key     = signing.Key(Converter.ToTrits(TEST_SEED), 5, 1);

            Assert.AreEqual(Signing.KeyLength, key.Length);
            key = signing.Key(Converter.ToTrits(TEST_SEED), 5, 2);
            Assert.AreEqual(2 * Signing.KeyLength, key.Length);
            key = signing.Key(Converter.ToTrits(TEST_SEED), 5, 3);
            Assert.AreEqual(3 * Signing.KeyLength, key.Length);
        }
Пример #2
0
        public void TestKeyLength()
        {
            Signing signing = new Signing();

            sbyte[] key = signing.Key(Converter.ToTrits(TEST_SEED), 5, 1);
            Assert.AreEqual(Constants.KEY_LENGTH, key.Length);
            key = signing.Key(Converter.ToTrits(TEST_SEED), 5, 2);
            Assert.AreEqual(2 * Constants.KEY_LENGTH, key.Length);
            key = signing.Key(Converter.ToTrits(TEST_SEED), 5, 3);
            Assert.AreEqual(3 * Constants.KEY_LENGTH, key.Length);
        }
Пример #3
0
        public void TestSigning()
        {
            // we can sign any hash, so for convenience we will sign the first
            // address of our test seed
            // (but remove the checksum) with the key of our fifth address
            var hashToSign     = FIRST_ADDR.RemoveChecksum();
            var signing        = new Signing(null);
            var key            = signing.Key(Converter.ToTrits(TEST_SEED), 5, 2);
            var normalizedHash = new Bundle().NormalizedBundle(hashToSign);

            var subKey            = new int[6561];
            var subNormalizedHash = new int[27];

            Array.Copy(key, 0, subKey, 0, 6561);
            Array.Copy(normalizedHash, 0, subNormalizedHash, 0, 27);
            var signature = signing.SignatureFragment(
                subNormalizedHash,
                subKey);

            Assert.AreEqual(SIGNATURE1, Converter.ToTrytes(signature));

            Array.Copy(key, 6561, subKey, 0, 6561);
            Array.Copy(normalizedHash, 27, subNormalizedHash, 0, 27);
            var signature2 = signing.SignatureFragment(
                subNormalizedHash,
                subKey);

            Assert.AreEqual(SIGNATURE2, Converter.ToTrytes(signature2));
        }
Пример #4
0
        public void TestLongSeedKeyGeneration()
        {
            ICurl curl    = new Kerl();
            var   signing = new Signing(curl);
            var   seed    = "EV9QRJFJZVFNLYUFXWKXMCRRPNAZYQVEYB9VEPUHQNXJCWKZFVUCTQJFCUAMXAHMMIUQUJDG9UGGQBPIY";

            for (var i = 1; i < 5; i++)
            {
                var key1 = signing.Key(Converter.ToTrits(seed), 0, i);
                Assert.AreEqual(Signing.KeyLength * i, key1.Length);
                var key2 = signing.Key(Converter.ToTrits(seed + seed), 0, i);
                Assert.AreEqual(Signing.KeyLength * i, key2.Length);
                var key3 = signing.Key(Converter.ToTrits(seed + seed + seed), 0, i);
                Assert.AreEqual(Signing.KeyLength * i, key3.Length);
            }
        }
Пример #5
0
        public void TestLongSeedKeyGeneration()
        {
            ICurl   curl    = SpongeFactory.Create(SpongeFactory.Mode.KERL);
            Signing signing = new Signing(curl);
            string  seed    = "EV9QRJFJZVFNLYUFXWKXMCRRPNAZYQVEYB9VEPUHQNXJCWKZFVUCTQJFCUAMXAHMMIUQUJDG9UGGQBPIY";

            for (int i = Constants.MIN_SECURITY_LEVEL; i < Constants.MAX_SECURITY_LEVEL; i++)
            {
                sbyte[] key1 = signing.Key(Converter.ToTrits(seed), 0, i);
                Assert.AreEqual(Constants.KEY_LENGTH * i, key1.Length);
                sbyte[] key2 = signing.Key(Converter.ToTrits(seed + seed), 0, i);
                Assert.AreEqual(Constants.KEY_LENGTH * i, key2.Length);
                sbyte[] key3 = signing.Key(Converter.ToTrits(seed + seed + seed), 0, i);
                Assert.AreEqual(Constants.KEY_LENGTH * i, key3.Length);
            }
        }
Пример #6
0
        public void TestSigning()
        {
            // we can sign any hash, so for convenience we will sign the first
            // address of our test seed
            // (but remove the checksum) with the key of our fifth address
            string  hashToSign = FIRST_ADDR.RemoveChecksum();
            Signing signing    = new Signing();

            sbyte[] key            = signing.Key(Converter.ToTrits(TEST_SEED), 5, 2);
            sbyte[] normalizedHash = new Bundle().NormalizedBundle(hashToSign);
            sbyte[] signature      = signing.SignatureFragment(
                ArrayUtils.SubArray(normalizedHash, 0, 27),
                ArrayUtils.SubArray(key, 0, 6561));
            Assert.AreEqual(SIGNATURE1, Converter.ToTrytes(signature));

            sbyte[] signature2 = signing.SignatureFragment(
                ArrayUtils.SubArray(normalizedHash, 27, 27 * 2),
                ArrayUtils.SubArray(key, 6561, 6561 * 2));
            Assert.AreEqual(SIGNATURE2, Converter.ToTrytes(signature2));
        }