Skip to main content

p3_sumcheck/
error.rs

1use thiserror::Error;
2
3/// Errors from sumcheck protocol verification.
4#[derive(Error, Debug, PartialEq, Eq)]
5pub enum SumcheckError {
6    /// The proof contains a different number of rounds than expected.
7    #[error("Sumcheck round count mismatch: expected {expected}, got {actual}")]
8    RoundCountMismatch { expected: usize, actual: usize },
9
10    /// The proof is missing sumcheck data when rounds > 0.
11    #[error("Missing sumcheck data for {expected_rounds} expected rounds")]
12    MissingSumcheckData { expected_rounds: usize },
13
14    /// Proof-of-work witness verification failed.
15    #[error("Invalid proof-of-work witness")]
16    InvalidPowWitness,
17
18    /// The proof carries fewer PoW witnesses than sumcheck rounds.
19    #[error("Sumcheck PoW witness count mismatch: expected {expected}, got {actual}")]
20    PowWitnessCountMismatch { expected: usize, actual: usize },
21
22    /// HVZK sumcheck: a per-round wire payload had the wrong number of field
23    /// elements. Each round must carry `max(ℓ_zk - 1, 2)` elements (after the
24    /// linear coefficient is skipped per Lemma 6.4 / paper §6).
25    #[error("HVZK round {round}: wire size mismatch, expected {expected}, got {actual}")]
26    WireSizeMismatch {
27        round: usize,
28        expected: usize,
29        actual: usize,
30    },
31
32    /// HVZK sumcheck: the proof's claimed `ell_zk` (mask code message length)
33    /// does not match the verifier's expected value. Catches caller-side
34    /// configuration mismatch between prover and verifier before the wire
35    /// shape check.
36    #[error("HVZK ell_zk mismatch: expected {expected}, got {actual}")]
37    EllZkMismatch { expected: usize, actual: usize },
38}