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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#[derive(Debug)]
pub enum PCError {
AnyhowError(anyhow::Error),
MissingPolynomial {
label: String,
},
MissingEvaluation {
label: String,
},
MissingRng,
DegreeIsZero,
TooManyCoefficients {
num_coefficients: usize,
num_powers: usize,
},
HidingBoundIsZero,
HidingBoundToolarge {
hiding_poly_degree: usize,
num_powers: usize,
},
LagrangeBasisSizeIsNotPowerOfTwo,
LagrangeBasisSizeIsTooLarge,
TrimmingDegreeTooLarge,
EquationHasDegreeBounds(String),
UnsupportedDegreeBound(usize),
UnsupportedLagrangeBasisSize(usize),
IncorrectDegreeBound {
poly_degree: usize,
degree_bound: usize,
supported_degree: usize,
label: String,
},
Terminated,
}
impl snarkvm_utilities::error::Error for PCError {}
impl From<anyhow::Error> for PCError {
fn from(other: anyhow::Error) -> Self {
Self::AnyhowError(other)
}
}
impl core::fmt::Display for PCError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::AnyhowError(error) => write!(f, "{error}"),
Self::MissingPolynomial { label } => {
write!(f, "`QuerySet` refers to polynomial \"{}\", but it was not provided.", label)
}
Self::MissingEvaluation { label } => write!(
f,
"`QuerySet` refers to polynomial \"{}\", but `Evaluations` does not contain an evaluation for it.",
label
),
Self::MissingRng => write!(f, "hiding commitments require `Some(rng)`"),
Self::DegreeIsZero => write!(f, "this scheme does not support committing to degree 0 polynomials"),
Self::TooManyCoefficients { num_coefficients, num_powers } => write!(
f,
"the number of coefficients in the polynomial ({:?}) is greater than\
the maximum number of powers in `Powers` ({:?})",
num_coefficients, num_powers
),
Self::HidingBoundIsZero => write!(f, "this scheme does not support non-`None` hiding bounds that are 0"),
Self::HidingBoundToolarge { hiding_poly_degree, num_powers } => write!(
f,
"the degree of the hiding poly ({:?}) is not less than the maximum number of powers in `Powers` ({:?})",
hiding_poly_degree, num_powers
),
Self::TrimmingDegreeTooLarge => write!(f, "the degree provided to `trim` was too large"),
Self::EquationHasDegreeBounds(e) => {
write!(f, "the eqaution \"{}\" contained degree-bounded polynomials", e)
}
Self::UnsupportedDegreeBound(bound) => {
write!(f, "the degree bound ({:?}) is not supported by the parameters", bound)
}
Self::LagrangeBasisSizeIsNotPowerOfTwo => {
write!(f, "the Lagrange Basis size is not a power of two")
}
Self::UnsupportedLagrangeBasisSize(size) => {
write!(f, "the Lagrange basis size ({:?}) is not supported by the parameters", size)
}
Self::LagrangeBasisSizeIsTooLarge => {
write!(f, "the Lagrange Basis size larger than max supported degree")
}
Self::IncorrectDegreeBound { poly_degree, degree_bound, supported_degree, label } => write!(
f,
"the degree bound ({:?}) for the polynomial {} \
(having degree {:?}) is greater than the maximum \
supported degree ({:?})",
degree_bound, label, poly_degree, supported_degree
),
Self::Terminated => write!(f, "terminated"),
}
}
}