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

Support calculating root from consistency proof #140

Merged

Conversation

mhutchinson
Copy link
Contributor

This is useful for other teams in the transparency space and was requested via the transparency-dev Slack channel. The new method is similar in essence to RootFromInclusionProof so fits in within the API.

As noted in the CHANGELOG, this change fixes a logical bug in the previous code that would have successfully verified an empty proof from a tree size of 0 to any other tree size. In this change, trying to verify a consistency from a tree size of 0 to any other size than 0 will be considered an error, no matter what proof is provided.

This is useful for other teams in the transparency space and was requested via the transparency-dev Slack channel. The new method is similar in essence to RootFromInclusionProof so fits in within the API.

As noted in the CHANGELOG, this change fixes a logical bug in the previous code that would have successfully verified an _empty_ proof from a tree size of 0 to any other tree size. In this change, trying to verify a consistency from a tree size of 0 to any other size than 0 will be considered an error, no matter what proof is provided.
proof/verify.go Show resolved Hide resolved
proof/verify.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.93%. Comparing base (4ebea17) to head (87b17ee).
Report is 43 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #140      +/-   ##
==========================================
- Coverage   89.33%   86.93%   -2.41%     
==========================================
  Files           7        7              
  Lines         497      375     -122     
==========================================
- Hits          444      326     -118     
+ Misses         48       44       -4     
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Also updated comment on VerifyConsistency to say size1 is required to be > 0. The function is only clearly defined in this case. It's now undefined where size1 is 0.
@mhutchinson mhutchinson marked this pull request as ready for review September 18, 2024 12:15
@mhutchinson mhutchinson requested a review from a team as a code owner September 18, 2024 12:16
@mhutchinson mhutchinson merged commit 022f84c into transparency-dev:main Sep 18, 2024
11 of 12 checks passed
@mhutchinson mhutchinson deleted the rootFromConsistencyProof branch September 18, 2024 15:14
mhutchinson added a commit to mhutchinson/witness that referenced this pull request Sep 18, 2024
The tests show that this currently works, providing that the proof is empty. When the merkle library is updated to pull in transparency-dev/merkle#140, this will fail too. In both of the new test cases, the witness should ratchet forward when a new checkpoint is provided.

As a separate note, I recommend rewriting these tests at some near point in the future. They are currently quite brittle as they rely on hard coded test data with no obvious script to update them. An in-memory test log would be a great way to generate the test data in a flexible way.
mhutchinson added a commit to transparency-dev/witness that referenced this pull request Sep 19, 2024
* Added tests for witnesses updating from tree size 0

The tests show that this currently works, providing that the proof is empty. When the merkle library is updated to pull in transparency-dev/merkle#140, this will fail too. In both of the new test cases, the witness should ratchet forward when a new checkpoint is provided.

As a separate note, I recommend rewriting these tests at some near point in the future. They are currently quite brittle as they rely on hard coded test data with no obvious script to update them. An in-memory test log would be a great way to generate the test data in a flexible way.

* Support ratcheting forward from checkpoints for size 0

The only way to handle this is via a special case.
mhutchinson added a commit to mhutchinson/witness that referenced this pull request Sep 19, 2024
This is primarily to pull in transparency-dev/merkle#140 now to confirm it doesn't have any suprises while I'm still context loaded on the issue. Better that than it surprising someone down the road.
mhutchinson added a commit to transparency-dev/witness that referenced this pull request Sep 19, 2024
This is primarily to pull in transparency-dev/merkle#140 now to confirm it doesn't have any suprises while I'm still context loaded on the issue. Better that than it surprising someone down the road.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants