Skip to content

Commit

Permalink
elaborates on the nodes' suffix format
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Jul 3, 2023
1 parent 2adf16f commit b763911
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,16 +716,20 @@ func TestVerifyNamespace_ShortAbsenceProof_Valid(t *testing.T) {
qNS := []byte{5} // does not belong to the tree
root, err := tree.Root()
assert.NoError(t, err)

// In the following illustration, nodes are suffixed with the range
// of leaves they cover, with the upper bound being non-inclusive.
// For example, Node3_4 denotes a node that covers the 3rd leaf (excluding the 4th leaf),
// while Node4_6 represents the node that covers the 4th and 5th leaves.
//
// Node_0_8 Tree Root
// / \
// / \
// Node0_4 Node4_8 Non-Leaf Node
// Node0_4 Node4_8 Non-Leaf Node
// / \ / \
// / \ / \
// Node_0_2 Node_2_4 Node4_6 Node6_8 Non-Leaf Node
// Node_0_2 Node_2_4 Node4_6 Node6_8 Non-Leaf Node
// / \ / \ / \ / \
// Node_0_1 Node_1_2 Node_2_3 Node_3_4 Node4_5 Node5_6 Node_6_7 Node_7_8 Leaf Hash
// Node0_1 Node1_2 Node2_3 Node3_4 Node4_5 Node5_6 Node6_7 Node7_8 Leaf Hash
// 1 2 3 4 6 7 8 9 Leaf namespace
// 0 1 2 3 4 5 6 7 Leaf index

Expand Down Expand Up @@ -803,16 +807,20 @@ func TestVerifyNamespace_ShortAbsenceProof_Invalid(t *testing.T) {
qNS := []byte{7} // does not belong to the tree
root, err := tree.Root()
assert.NoError(t, err)

// In the following illustration, nodes are suffixed with the range
// of leaves they cover, with the upper bound being non-inclusive.
// For example, Node3_4 denotes a node that covers the 3rd leaf (excluding the 4th leaf),
// while Node4_6 represents the node that covers the 4th and 5th leaves.
//
// Node_0_8 Tree Root
// / \
// / \
// Node0_4 Node4_8 Non-Leaf Node
// Node0_4 Node4_8 Non-Leaf Node
// / \ / \
// / \ / \
// Node_0_2 Node_2_4 Node4_6 Node6_8 Non-Leaf Node
// Node0_2 Node2_4 Node4_6 Node6_8 Non-Leaf Node
// / \ / \ / \ / \
// Node_0_1 Node_1_2 Node_2_3 Node_3_4 Node4_5 Node5_6 Node_6_7 Node_7_8 Leaf Hash
// Node0_1 Node1_2 Node2_3 Node_3_4 Node4_5 Node5_6 Node6_7 Node7_8 Leaf Hash
// 1 2 3 4 6 8 8 8 Leaf namespace
// 0 1 2 3 4 5 6 7 Leaf index

Expand Down

0 comments on commit b763911

Please sign in to comment.