Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: incorporates tests for short absence proof verification #217

Merged
merged 24 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
16fb2d6
adds some tests
staheri14 Jun 23, 2023
6edb469
Merge branch 'master' into short-absence-proof-impl
staheri14 Jun 28, 2023
93def73
adds more tests for different short absence proofs
staheri14 Jun 28, 2023
dfadba9
Merge branch 'master' into short-absence-proof-impl
staheri14 Jun 28, 2023
5bad123
adds comment visualizing the tree structure
staheri14 Jun 28, 2023
d319f06
makes further improvements to the test w.r.t. readability
staheri14 Jun 29, 2023
1bf8b75
revises the test docs and resolves linter bugs
staheri14 Jun 29, 2023
53a96e2
fixes spacing misalignment
staheri14 Jun 29, 2023
e3242c9
updates namespaces
staheri14 Jun 29, 2023
43cc59f
fixes a typo
staheri14 Jun 29, 2023
c72bf97
removes unused tests
staheri14 Jun 29, 2023
7eb4aef
adds invalid short absence proof tests
staheri14 Jun 29, 2023
d54fdfc
clarifies the result of verification
staheri14 Jun 29, 2023
91350bf
adds godoc
staheri14 Jun 29, 2023
b524c73
fixes the mismatch bw func name and the godoc
staheri14 Jun 29, 2023
5c26003
removes underscore from var names due to linter complaints
staheri14 Jun 29, 2023
bc3162a
Merge remote-tracking branch 'origin/master' into short-absence-proof…
staheri14 Jun 29, 2023
fb9c288
updates VerifyNamespace description
staheri14 Jun 29, 2023
8674eec
wraps lines to 80 chars
staheri14 Jun 29, 2023
2adf16f
minor revisions
staheri14 Jun 29, 2023
b763911
elaborates on the nodes' suffix format
staheri14 Jul 3, 2023
5c67fe4
fixes the parameter name
staheri14 Jul 3, 2023
3b33555
removes ID
staheri14 Jul 3, 2023
1e56c61
removes leading _
staheri14 Jul 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (proof Proof) IsEmptyProof() bool {
// VerifyNamespace verifies a whole namespace, i.e. 1) it verifies inclusion of
// the provided `leaves` in the tree (or the proof.leafHash in case of
// full/short absence proof) 2) it verifies that the namespace is complete
// i.e., the data items matching the namespace ID `nID` are within the range
// i.e., the data items matching the namespace `nID` are within the range
// [`proof.start`, `proof.end`) and no data of that namespace was left out.
// VerifyNamespace deems an empty `proof` valid if the queried `nID` falls
// outside the namespace range of the supplied `root` or if the `root` is empty
Expand All @@ -159,7 +159,7 @@ func (proof Proof) IsEmptyProof() bool {
// leaves of the tree in the range of [`proof.start`, `proof.end`).
// For an absence `proof`, the `leaves` is empty.
// `leaves` items MUST be ordered according to their index in the tree,
// with `data[0]` corresponding to the namespaced leaf at index `start`,
// with `leaves[0]` corresponding to the namespaced leaf at index `start`,
// and the last element in `leaves` corresponding to the leaf at index `end-1`
// of the tree.
//
Expand Down
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
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
// / \
// / \
// 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
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
// / \ / \ / \ / \
// 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
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
// / \
// / \
// 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