Skip to content

fix end proof verification #1801

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

Merged
merged 4 commits into from
Aug 3, 2023
Merged

fix end proof verification #1801

merged 4 commits into from
Aug 3, 2023

Conversation

danlaine
Copy link

@danlaine danlaine commented Aug 2, 2023

Why this should be merged

The invariant for RangeProof's EndProof field says:

// If no upper range bound was given, [KeyValues] is empty,
// and [StartProof] is non-empty, this is empty.
//
// If no upper range bound was given, [KeyValues] is empty,
// and [StartProof] is empty, this is the root.
//
// If an upper range bound was given and [KeyValues] is empty,
// this is a proof for the upper range bound.
//
// Otherwise, this is a proof for the largest key in [KeyValues].
EndProof []ProofNode

But in RangeProof.Verify we check:

case len(proof.EndProof) == 0 && len(end) > 0:
	return ErrNoEndProof

This should be:

case len(end) > 0 && len(proof.KeyValues) == 0 && len(proof.EndProof) == 0:
	return ErrNoEndProof

i.e. the invariant says there should be an end proof iff all of [start proof, key values, upper bound] are empty but in the check we only look at two of those three (namely, we weren't checking the key values)

How this works

See above

How this was tested

HyperSDK CI

@danlaine danlaine added bug Something isn't working merkledb labels Aug 2, 2023
@danlaine danlaine merged commit 1d1a596 into dev Aug 3, 2023
@danlaine danlaine deleted the sync-cleanup-rangeproof-verify branch August 3, 2023 15:07
@danlaine danlaine self-assigned this Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working merkledb
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants