Exemple #1
0
        private void OnShown(object sender, EventArgs e)
        {
            WebSocketHelpers.ClearCanvas();
            MerkleTree tree = new DemoMerkleTree();

            CreateTree(tree, (int)nudNumLeaves.Value);
            DrawTree(tree);
        }
Exemple #2
0
        private void btnAuditProof_Click(object sender, EventArgs e)
        {
            WebSocketHelpers.ClearCanvas();
            MerkleTree tree = new DemoMerkleTree();

            CreateTree(tree, (int)nudNumLeaves.Value);
            DrawTree(tree);
            int leafNum = (int)nudAuditProofNodeNumber.Value;

            Highlight(tree.RootNode.Leaves().Cast <DemoMerkleNode>().Single(n => n.Text == leafNum.ToString("X")), "Orange");
            DrawAuditProof(leafNum.ToString("X"), tree);
        }
Exemple #3
0
        private void NumLeavesChanged(object sender, EventArgs e)
        {
            WebSocketHelpers.ClearCanvas();
            MerkleTree tree = new DemoMerkleTree();

            CreateTree(tree, (int)nudNumLeaves.Value);
            DrawTree(tree);

            // Adjust maximums of our "proof" explorers.
            nudAuditProofNodeNumber.Maximum      = nudNumLeaves.Value - 1;
            nudConsistencyProofNumLeaves.Maximum = nudNumLeaves.Value - 1;
        }
Exemple #4
0
        private void btnConsistencyProof_Click(object sender, EventArgs e)
        {
            WebSocketHelpers.ClearCanvas();
            MerkleTree tree = new DemoMerkleTree();

            CreateTree(tree, (int)nudNumLeaves.Value);
            DrawTree(tree);
            int numLeaves = (int)nudConsistencyProofNumLeaves.Value;

            // Reconstruct the old root hash by creating a tree of "m" leaves.
            // We do this because in the demo, we haven't given the user the ability to append trees, so we
            // simulate that process here.
            MerkleTree oldTree = new DemoMerkleTree();

            CreateTree(oldTree, numLeaves);

            // For demo purposes, remove any () that were created by left-only branches.
            ((DemoMerkleNode)oldTree.RootNode).Text = ((DemoMerkleNode)oldTree.RootNode).Text.Replace("(", "").Replace(")", "");

            DrawConsistencyProof(tree, (DemoMerkleNode)oldTree.RootNode, numLeaves, null);
        }