Skip to content

Harden fiat-shamir challenger and WHIR verifier security surface#218

Open
XC0R wants to merge 2 commits intoleanEthereum:mainfrom
XC0R:security-hardening-fs-whir
Open

Harden fiat-shamir challenger and WHIR verifier security surface#218
XC0R wants to merge 2 commits intoleanEthereum:mainfrom
XC0R:security-hardening-fs-whir

Conversation

@XC0R
Copy link
Copy Markdown

@XC0R XC0R commented May 11, 2026

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.

  • Rejection sampling (challenger.rs): replace bitmask truncation with rejection loop to eliminate modulo bias in sample_in_range(). Rejects field elements >= floor(ORDER/2^bits) * 2^bits.
  • Merkle bounds check (merkle.rs, commit.rs): WhirMerkleTree::open() and MerkleData::open() return Option instead of panicking on out-of-bounds index.
  • Error propagation (open.rs): prove() returns ProofResult instead of panicking. open_merkle_tree_at_challenges() propagates Merkle errors. ProverError::Proof variant added.
  • Security budget audit (security_budget.rs): traces the full WHIR error budget. Confirms SECURITY_BITS=124 is achievable. Documents that 128-bit security is feasible under JohnsonBound with current parameters and 16-bit PoW (test_128bit_feasibility passes — the SECURITY_BITS TODO 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:

  • Core: rejection sampling + Merkle bounds check (returns Option) + test suite. All within fiat-shamir/ + whir/.
  • API: prove() returns ProofResult, error propagation through lean_prover/.

The test suite and rejection sampling are independent of the API change.

Files changed

File Change
fiat-shamir/src/challenger.rs Rejection sampling in sample_in_range()
whir/src/merkle.rs open() returns Option
whir/src/commit.rs MerkleData::open() returns Option
whir/src/open.rs prove() returns ProofResult, error propagation
lean_prover/src/lib.rs ProverError::Proof variant
lean_prover/src/prove_execution.rs Handle prove() Result
fiat-shamir/tests/challenger_hardening.rs 4 tests: uniformity, transcript sync, determinism
whir/tests/security_budget.rs 4 tests: budget audit, 124-bit, 128-bit feasibility
whir/tests/run_whir.rs Handle prove() Result

Closes #184. Closes #177.

XC0R added 2 commits May 10, 2026 22:22
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.
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.

Biased sampling by truncation may weaken soundness security [M-5] Out-of-range Merkle opening causes panic DoS

1 participant