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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
//! A collection of all possible errors encountered in PLONK.
use dusk_bytes::Error as DuskBytesError;
/// Defines all possible errors that can be encountered in PLONK.
#[derive(core::fmt::Debug)]
pub enum Error {
// FFT errors
/// This error occurs when an error triggers on any of the fft module
/// functions.
InvalidEvalDomainSize {
/// Log size of the group
log_size_of_group: u32,
/// Two adacity generated
adacity: u32,
},
// Prover/Verifier errors
/// This error occurs when a proof verification fails.
ProofVerificationError,
/// This error occurs when the circuit is not provided with all of the
/// required inputs.
CircuitInputsNotFound,
/// This error occurs when we want to verify a Proof but the pi_constructor
/// attribute is uninitialized.
UninitializedPIGenerator,
/// PublicInput serialization error
InvalidPublicInputBytes,
/// This error occurs when the Prover structure already contains a
/// preprocessed circuit inside, but you call preprocess again.
CircuitAlreadyPreprocessed,
// Preprocessing errors
/// This error occurs when an error triggers during the preprocessing
/// stage.
MismatchedPolyLen,
// KZG10 errors
/// This error occurs when the user tries to create PublicParameters
/// and supplies the max degree as zero.
DegreeIsZero,
/// This error occurs when the user tries to trim PublicParameters
/// to a degree that is larger than the maximum degree.
TruncatedDegreeTooLarge,
/// This error occurs when the user tries to trim PublicParameters
/// down to a degree that is zero.
TruncatedDegreeIsZero,
/// This error occurs when the user tries to commit to a polynomial whose
/// degree is larger than the supported degree for that proving key.
PolynomialDegreeTooLarge,
/// This error occurs when the user tries to commit to a polynomial whose
/// degree is zero.
PolynomialDegreeIsZero,
/// This error occurs when the pairing check fails at being equal to the
/// Identity point.
PairingCheckFailure,
// Serialization errors
/// Dusk-bytes serialization error
BytesError(DuskBytesError),
/// This error occurs when there are not enough bytes to read out of a
/// slice during deserialization.
NotEnoughBytes,
/// This error occurs when a malformed point is decoded from a byte array.
PointMalformed,
/// This error occurs when a malformed BLS scalar is decoded from a byte
/// array.
BlsScalarMalformed,
// Plonkup errors
/// Query element not found in lookup table
ElementNotIndexed,
/// Cannot commit to table column polynomial
TablePreProcessingError,
}
#[cfg(feature = "std")]
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::InvalidEvalDomainSize {
log_size_of_group,
adacity,
} => write!(
f,
"Log-size of the EvaluationDomain group > TWO_ADACITY\
Size: {:?} > TWO_ADACITY = {:?}",
log_size_of_group, adacity
),
Self::ProofVerificationError => {
write!(f, "proof verification failed")
}
Self::CircuitInputsNotFound => {
write!(f, "circuit inputs not found")
}
Self::UninitializedPIGenerator => {
write!(f, "PI generator uninitialized")
}
Self::InvalidPublicInputBytes => {
write!(f, "invalid public input bytes")
}
Self::MismatchedPolyLen => {
write!(f, "the length of the wires is not the same")
}
Self::CircuitAlreadyPreprocessed => {
write!(f, "circuit has already been preprocessed")
}
Self::DegreeIsZero => {
write!(f, "cannot create PublicParameters with max degree 0")
}
Self::TruncatedDegreeTooLarge => {
write!(f, "cannot trim more than the maximum degree")
}
Self::TruncatedDegreeIsZero => write!(
f,
"cannot trim PublicParameters to a maximum size of zero"
),
Self::PolynomialDegreeTooLarge => write!(
f,
"proving key is not large enough to commit to said polynomial"
),
Self::PolynomialDegreeIsZero => {
write!(f, "cannot commit to polynomial of zero degree")
}
Self::PairingCheckFailure => write!(f, "pairing check failed"),
Self::NotEnoughBytes => write!(f, "not enough bytes left to read"),
Self::PointMalformed => write!(f, "BLS point bytes malformed"),
Self::BlsScalarMalformed => write!(f, "BLS scalar bytes malformed"),
Self::BytesError(err) => write!(f, "{:?}", err),
Self::ElementNotIndexed => write!(
f,
"the requested element was not indexed in the lookup table"
),
Self::TablePreProcessingError => write!(
f,
"cannot commit to one of the table column polynomials"
),
}
}
}
impl From<DuskBytesError> for Error {
fn from(bytes_err: DuskBytesError) -> Self {
Self::BytesError(bytes_err)
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}