zkWHIR 3.0 : Updated protocols for whir round integration and added mask proximity protocol (part 2)#3
zkWHIR 3.0 : Updated protocols for whir round integration and added mask proximity protocol (part 2)#3ocdbytes wants to merge 23 commits into
Conversation
# Conflicts: # src/protocols/code_switch.rs
| masks: &[M::Source], | ||
| witness: &IrsWitness<M::Source, M::Target>, | ||
| covector: &mut [M::Target], | ||
| mask_oracle: Option<&MaskOracle<M::Target>>, |
There was a problem hiding this comment.
This still represents ZK mode as zk: bool plus Option<&MaskOracle<_>> with runtime consistency checks. Can this boundary be made unrepresentable at the type/API level instead?
There was a problem hiding this comment.
This is for the ease of individual protocols. This can be done when the parameters are finalised right now protocol correctness is the main goal. These were added in tune with other protocols on how they have zk but that will also change as the Configs explicitly demand to have zk in them and other params which are not concrete
| verifier_state.verifier_message_vec(self.out_domain_samples); | ||
| let ood_answers: Vec<M::Target> = | ||
| verifier_state.prover_messages_vec(self.out_domain_samples)?; | ||
| let _ood_points: Vec<M::Target> = verifier_state.verifier_message_vec(self.ood_samples); |
There was a problem hiding this comment.
In ZK mode the verifier consumes masked OOD answers, but the corresponding mask-side check is neither performed here nor reflected in the returned Commitment. Please make that deferred obligation explicit in the API, or wire the matching verification step into this flow.
There was a problem hiding this comment.
mask proximity protocol does this that's why here there is no need to check. Will add a comment here
| pub out_domain_samples: usize, | ||
| pub mask_commit: Option<IrsConfig<Identity<M::Target>>>, | ||
| pub ood_samples: usize, | ||
| pub zk: bool, |
There was a problem hiding this comment.
This still represents ZK mode as zk: bool plus Option<&MaskOracle<_>> with runtime consistency checks. Can this boundary be made unrepresentable at the type/API level instead?
There was a problem hiding this comment.
After parameter finalisation we can do this. This is out of the scope of this PR. Only protocol correctness. Same reason : #3 (comment)
| let mut covector: Vec<F> = random_vector(&mut rng, config.source.message_length()); | ||
| let initial_mu = dot(&message, &covector); | ||
|
|
||
| // MaskOracle with a random mask polynomial. |
There was a problem hiding this comment.
test_zk() currently shows transcript plumbing, but not that the composed ZK invariant is enforced. Please add a negative integration test where the OOD masking relation is inconsistent with the companion mask-side proof and make sure the full composed flow rejects.
There was a problem hiding this comment.
we only check transcript plumbing as we can't have explicit tests for individual protocols without test logic being too complicated. (same as the last PR)
This will be tested in the orch PR as there we would have proper configs and zk comes from the top not in individual protocols
| pub type Commitment<F> = IrsCommitment<F>; | ||
|
|
||
| impl<F: Field> Config<F> { | ||
| pub fn new(c_zk_commit: IrsConfig<Identity<F>>, num_masks: usize) -> Self { |
There was a problem hiding this comment.
this protocol claims to reveal only the combined ξ*, but c_zk_commit still carries IRS out-of-domain openings by default. Since we commit [originals..., freshes...] through irs_commit, the verifier can receive raw OOD evaluations of the original masks before the γ-combination checks. That seems inconsistent with the intended ZK contract here. Can we require out_domain_samples == 0 for this protocol, or otherwise justify/encode this disclosure explicitly?
There was a problem hiding this comment.
in irs_commit
// TODO : Remove this logic after main whir protocol is updated
// as this is not required in the new construction.
this will be removed so assertion not needed here but can add for robustness.
| verify, | ||
| }; | ||
|
|
||
| /// Prover output from the base case. |
There was a problem hiding this comment.
Both are { evaluation_points: Vec, linear_form_evaluation: F }. Collapse to a single Opening (or similar).
|
The planned orchestrator order (mask_proximity.commit → sumcheck → code_switch → mask_proximity.prove) sends s before g; the paper sends them together in Step 1. This shouldn't break Fiat-Shamir soundness, but Lemma 9.9's RBR proof doesn't transfer verbatim. |
|
Right now the ZK invariant is expressed via bool + Option + runtime asserts in three separate files that the orchestrator must keep in lockstep. Type-level unification removes an entire class of bugs before PR 3 lands. |
zkWHIR 3.0 : Code Switch Protocol (part 1)
Refactors sumcheck, code-switch, and basecase protocols to extract mask commitment ownership into the orchestrator, and introduces a new mask_proximity protocol for per-iteration ZK mask verification via γ-combination.
This is the foundation for the new ZK WHIR orchestrator — each protocol component is now a clean, commitment-free building block that the orchestrator will wire together.
Changes
Sumcheck (sumcheck.rs)
Code Switch (code_switch.rs)
Basecase (basecase.rs)
Mask Proximity (mask_proximity.rs) — NEW
Mask Proximity Protocol
Implements Construction 7.2 from the paper (§7, p.43-48), specialized for zero-constraint masks (μ_i = 0, sl_{o,i} = 0).
Protocol flow:
Important
Soundness (Lemma 7.4, p.45): If ξ_i is δ-far from every C_zk codeword, then ξ*_i = s_i + γ·ξ_i is also far from s_i + γ·c for every codeword c, with high probability over γ. The spot-check catches disagreement at random positions with probability ≥ 1 − (1−δ)^{t_zk}.
Important
ZK safety (Lemma 7.3, p.44): Only ξ*_i = s_i + γ·ξ_i is revealed in full. Since s_i is uniformly random, ξ*_i is uniform regardless of ξ_i — the original mask is never exposed. The tree is opened at ≤ t_zk positions, within the ZK query budget of C_zk's encoding.
Next Steps
PR 2: Protocol Configs & Parameter Selection
PR 3: Orchestrator Prover + Verifier Loops
Caution
Cannot be merged as it depends on PR #249