use p3_sumcheck::ring_switch::bits::{BitRingSwitchError, BitRingSwitchProofError};
use p3_whir::{VerifierError, WhirConfigError};
use thiserror::Error;
use crate::packing::PackError;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum BooleanWhirError {
#[error("a bit witness of {actual} variables cannot absorb {needed} into one element")]
WitnessTooNarrow {
needed: usize,
actual: usize,
},
#[error("the schedule commits {actual} variables, the packing holds {expected}")]
ConfigArity {
expected: usize,
actual: usize,
},
#[error("the packed witness has {actual} variables, expected {expected}")]
WitnessArity {
expected: usize,
actual: usize,
},
#[error("an opening needs at least one point")]
NoPoints,
#[error("{expected} points against {values} values and {reductions} reductions")]
ClaimCount {
expected: usize,
values: usize,
reductions: usize,
},
#[error("the opening point names {actual} variables, expected {expected}")]
PointArity {
expected: usize,
actual: usize,
},
#[error("opening {index} asks for no reading")]
NoReading {
index: usize,
},
#[error("opening {index} steps within {row_variables} rows of {num_variables} variables")]
RowVariables {
index: usize,
row_variables: usize,
num_variables: usize,
},
#[error("the readings of opening {index} do not match what it asks for")]
ReadingShape {
index: usize,
},
#[error(transparent)]
Packing(PackError),
#[error(transparent)]
Reduction(BitRingSwitchError),
#[error(transparent)]
ReductionProof(BitRingSwitchProofError),
#[error(transparent)]
Commit(WhirConfigError),
#[error(transparent)]
Opening(VerifierError),
#[error("a surviving claim does not match the opened value")]
SurvivingClaim,
}
#[derive(Clone, Copy, Debug, Error, PartialEq, Eq)]
#[non_exhaustive]
pub enum BudgetError {
#[error("{actual} opened positions exceed the budget of {budget}")]
Queries {
actual: usize,
budget: usize,
},
#[error("{actual} proof bytes exceed the budget of {budget}")]
Bytes {
actual: usize,
budget: usize,
},
#[error("{actual} grinding bits exceed the budget of {budget}")]
Grinding {
actual: usize,
budget: usize,
},
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ProfileError {
#[error(transparent)]
Schedule(WhirConfigError),
#[error("the schedule needs {required} grinding bits, one witness allows {ceiling}")]
Grinding {
required: usize,
ceiling: usize,
},
#[error("the derived schedule opens no position, so it accepts any codeword")]
ZeroQueries,
}