Harden fiat-shamir challenger and WHIR verifier security surface#218
Open
XC0R wants to merge 2 commits intoleanEthereum:mainfrom
Open
Harden fiat-shamir challenger and WHIR verifier security surface#218XC0R wants to merge 2 commits intoleanEthereum:mainfrom
XC0R wants to merge 2 commits intoleanEthereum:mainfrom
Conversation
Addresses leanEthereum#184 (biased sampling) and leanEthereum#177 (Merkle panic DoS), plus surrounding error propagation and security budget validation. Changes: - challenger.rs: replace bitmask truncation with rejection sampling in sample_in_range(). Rejects field elements >= floor(ORDER/2^bits)*2^bits to eliminate modulo bias. Breaking: changes FS transcript when rejection occurs (probability < 1/p per sample for typical parameters). - merkle.rs, commit.rs: WhirMerkleTree::open() and MerkleData::open() return Option instead of panicking on out-of-bounds index. - open.rs: prove() returns ProofResult instead of panicking on internal errors. open_merkle_tree_at_challenges() returns ProofResult. All Merkle open calls propagate errors via ?. - lean_prover/lib.rs: add ProverError::Proof variant with From<ProofError>. - tests/challenger_hardening.rs: chi-squared uniformity tests (4-bit, 8-bit), prover-verifier transcript sync, deterministic output. - tests/security_budget.rs: full WHIR security budget audit. Confirms SECURITY_BITS=124 is achievable. Documents that 128-bit security is feasible under JohnsonBound with current parameters (test_128bit_ feasibility passes). - tests/run_whir.rs: handle prove() Result (consequence of API change). Split option: if the prove() return type change is too broad, the Merkle bounds check can be surfaced as a clear panic message instead. The rejection sampling and test suite are independent of the API change.
prove() now returns ProofResult after error-propagation change; the benchmark test doesn't inspect the result.
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.
Summary
Security-surface audit of the fiat-shamir challenger and WHIR verifier boundary. Addresses #184 and #177, plus surrounding error propagation and security budget validation.
challenger.rs): replace bitmask truncation with rejection loop to eliminate modulo bias insample_in_range(). Rejects field elements>= floor(ORDER/2^bits) * 2^bits.merkle.rs,commit.rs):WhirMerkleTree::open()andMerkleData::open()returnOptioninstead of panicking on out-of-bounds index.open.rs):prove()returnsProofResultinstead of panicking.open_merkle_tree_at_challenges()propagates Merkle errors.ProverError::Proofvariant added.security_budget.rs): traces the full WHIR error budget. ConfirmsSECURITY_BITS=124is achievable. Documents that 128-bit security is feasible under JohnsonBound with current parameters and 16-bit PoW (test_128bit_feasibilitypasses — theSECURITY_BITSTODO may be resolvable without larger digests).Breaking change
Rejection sampling changes the Fiat-Shamir transcript when a sampled field element falls in the rejection zone. For typical parameters (bits <= 24, KoalaBear p = 2^31 - 2^24 + 1), rejection probability is < 1/p per sample — effectively never triggered.
Split option
If the
prove()return type change (MultilinearPoint<EF>→ProofResult<MultilinearPoint<EF>>) is too broad for this PR, it can be split:Option) + test suite. All withinfiat-shamir/+whir/.prove()returnsProofResult, error propagation throughlean_prover/.The test suite and rejection sampling are independent of the API change.
Files changed
fiat-shamir/src/challenger.rssample_in_range()whir/src/merkle.rsopen()returnsOptionwhir/src/commit.rsMerkleData::open()returnsOptionwhir/src/open.rsprove()returnsProofResult, error propagationlean_prover/src/lib.rsProverError::Proofvariantlean_prover/src/prove_execution.rsprove()Resultfiat-shamir/tests/challenger_hardening.rswhir/tests/security_budget.rswhir/tests/run_whir.rsprove()ResultCloses #184. Closes #177.