1use core::fmt;
7
8use crypto::RandomCoinError;
9
10#[derive(Debug, Clone, PartialEq, Eq)]
15pub enum VerifierError {
16 RandomCoinError(RandomCoinError),
18 UnsupportedFoldingFactor(usize),
21 NumPositionEvaluationMismatch(usize, usize),
23 LayerCommitmentMismatch,
25 InvalidLayerFolding(usize),
27 RemainderCommitmentMismatch,
29 InvalidRemainderFolding,
31 RemainderDegreeNotValid,
33 RemainderDegreeMismatch(usize),
35 DegreeTruncation(usize, usize, usize),
38}
39
40impl fmt::Display for VerifierError {
41 #[rustfmt::skip]
42 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43 match self {
44 Self::RandomCoinError(err) => {
45 write!(f, "failed to draw a random value from the public coin: {err}")
46 }
47 Self::UnsupportedFoldingFactor(value) => {
48 write!(f, "folding factor {value} is not currently supported")
49 }
50 Self::NumPositionEvaluationMismatch(num_positions, num_evaluations) => write!(f,
51 "the number of query positions must be the same as the number of polynomial evaluations, but {num_positions} and {num_evaluations} were provided"
52 ),
53 Self::LayerCommitmentMismatch => {
54 write!(f, "FRI queries did not match layer commitment made by the prover")
55 }
56 Self::InvalidLayerFolding(layer) => {
57 write!(f, "degree-respecting projection is not consistent at layer {layer}")
58 }
59 Self::RemainderCommitmentMismatch => {
60 write!(f, "FRI remainder did not match the commitment")
61 }
62 Self::InvalidRemainderFolding => {
63 write!(f, "degree-respecting projection is inconsistent at the last FRI layer")
64 }
65 Self::RemainderDegreeNotValid => {
66 write!(f, "FRI remainder expected degree is greater than number of remainder values")
67 }
68 Self::RemainderDegreeMismatch(degree) => {
69 write!(f, "FRI remainder is not a valid degree {degree} polynomial")
70 }
71 Self::DegreeTruncation(degree, folding, layer) => {
72 write!(f, "degree reduction from {degree} by {folding} at layer {layer} results in degree truncation")
73 }
74 }
75 }
76}
77
78impl core::error::Error for VerifierError {}