p3-sumcheck 0.7.0

Sumcheck protocol engine (product polynomials, SVO, HVZK masks)
Documentation
use thiserror::Error;

/// Errors from sumcheck protocol verification.
#[derive(Error, Debug, PartialEq, Eq)]
pub enum SumcheckError {
    /// The proof contains a different number of rounds than expected.
    #[error("Sumcheck round count mismatch: expected {expected}, got {actual}")]
    RoundCountMismatch { expected: usize, actual: usize },

    /// The proof is missing sumcheck data when rounds > 0.
    #[error("Missing sumcheck data for {expected_rounds} expected rounds")]
    MissingSumcheckData { expected_rounds: usize },

    /// Proof-of-work witness verification failed.
    #[error("Invalid proof-of-work witness")]
    InvalidPowWitness,

    /// The proof carries fewer PoW witnesses than sumcheck rounds.
    #[error("Sumcheck PoW witness count mismatch: expected {expected}, got {actual}")]
    PowWitnessCountMismatch { expected: usize, actual: usize },

    /// HVZK sumcheck: a per-round wire payload had the wrong number of field
    /// elements. Each round must carry `max(ℓ_zk - 1, 2)` elements (after the
    /// linear coefficient is skipped per Lemma 6.4 / paper §6).
    #[error("HVZK round {round}: wire size mismatch, expected {expected}, got {actual}")]
    WireSizeMismatch {
        round: usize,
        expected: usize,
        actual: usize,
    },

    /// HVZK sumcheck: the proof's claimed `ell_zk` (mask code message length)
    /// does not match the verifier's expected value. Catches caller-side
    /// configuration mismatch between prover and verifier before the wire
    /// shape check.
    #[error("HVZK ell_zk mismatch: expected {expected}, got {actual}")]
    EllZkMismatch { expected: usize, actual: usize },

    /// An opening claim's evaluations do not match the requested column shape.
    ///
    /// The evaluations come from the proof, so a malformed proof must be
    /// rejected here rather than aborting the verifier.
    #[error(
        "Opening shape mismatch for table {table_idx}: requested {expected_current} current and {expected_next} next, got {actual_current} current and {actual_next} next"
    )]
    OpeningShapeMismatch {
        table_idx: usize,
        expected_current: usize,
        expected_next: usize,
        actual_current: usize,
        actual_next: usize,
    },
}