fix: Verify prover-supplied FRI query points#17
Open
Tabaie wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the verifier doesn't double-check that the FRI query leaf IDs in the proof are correctly computed from the transcript. This PR adds that check and a regression test that would have caught the soundness issue. It also consolidates some planning logic duplicated in the Base and Ext cases into the same function.
I would have preferred to change the Merkle proof struct and the Verify function slightly so that the leaf index is not part of the proof at all, as it is conceptually part of the statement. So ideally the signature would be
Verify(root hash.Digest, leaf hash.Digest, leafIdx int, proof Proof, nh NodeHasher) bool. But trying this created integration issues because it seems like some components outside FRI use the same query indices.Note
High Risk
This changes cryptographic FRI verification behavior and closes a soundness issue; incorrect checks could break valid proofs or leave a vulnerability open.
Overview
Closes a FRI soundness gap where the verifier accepted Merkle openings without confirming that
Path.LeafIdxmatches the query position derived from the Fiat–Shamir transcript (s→base = s % (N_j/2)).checkQuery/checkQueryExtnow reject running-path and extra-level openings when the prover-supplied leaf index disagrees with that value; extra levels usecheckLevelQueryBaseon the sharedlevelIntroductionsplan.Prove/Verify planning is refactored so
newLevelIntroductionsbuilds round↔level mappings once (replacing duplicated logic inbuildProvePlanandVerify). A regression testTestCheckQueryRejectsOpeningAtWrongLeafIndexdocuments the prior bug.Reviewed by Cursor Bugbot for commit 7ce8b21. Bugbot is set up for automated code reviews on this repo. Configure here.