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