示例#1
0
        public void Can_verify_zero_and_one_elements(uint nodesCount)
        {
            BaselineTree baselineTree = BuildATree();
            Keccak       root         = baselineTree.Root;

            Console.WriteLine(root);
            for (int i = 0; i < nodesCount; i++)
            {
                baselineTree.Insert(_testLeaves[i]);
                Keccak newRoot = baselineTree.Root;
                Console.WriteLine(newRoot);
                newRoot.Should().NotBeEquivalentTo(root);
                root = newRoot;
                var proof0 = baselineTree.GetProof(0);
                var proof1 = baselineTree.GetProof(1);
                baselineTree.Verify(root, _testLeaves[0], proof0).Should().BeTrue("left in " + i);
                if (i > 0)
                {
                    baselineTree.Verify(root, _testLeaves[1], proof1).Should().BeTrue("right in " + i);
                }
            }
        }
示例#2
0
        public void Keccak_a_b_verify()
        {
            BaselineTree baselineTree = BuildATree();
            Keccak       root0        = baselineTree.Root;

            Console.WriteLine("root0 " + root0);
            Console.WriteLine("KeccakA " + TestItem.KeccakA);
            baselineTree.Insert(TestItem.KeccakA);
            var    proof0_0 = baselineTree.GetProof(0);
            Keccak root1    = baselineTree.Root;

            Console.WriteLine("root1 " + root1);
            Console.WriteLine("KeccakB " + TestItem.KeccakB);
            baselineTree.Insert(TestItem.KeccakB);
            Keccak root2 = baselineTree.Root;

            Console.WriteLine("root2 " + root2);
            var proof1_0 = baselineTree.GetProof(0);
            var proof1_1 = baselineTree.GetProof(1);

            baselineTree.Verify(root1, TestItem.KeccakA, proof0_0).Should().BeTrue();
            baselineTree.Verify(root2, TestItem.KeccakA, proof1_0).Should().BeTrue();
            baselineTree.Verify(root2, TestItem.KeccakB, proof1_1).Should().BeTrue();
        }