winter_verifier/errors.rs
1// Copyright (c) Facebook, Inc. and its affiliates.
2//
3// This source code is licensed under the MIT license found in the
4// LICENSE file in the root directory of this source tree.
5
6//! Contains common error types for prover and verifier.
7
8use alloc::string::String;
9use core::fmt;
10
11// VERIFIER ERROR
12// ================================================================================================
13/// Represents an error returned by the verifier during an execution of the protocol.
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub enum VerifierError {
16 /// This error occurs when base field read by a verifier from a proof does not match the
17 /// base field of AIR with which the verifier was instantiated.
18 InconsistentBaseField,
19 /// This error occurs when the base field in which the proof was generated does not support
20 /// field extension of degree specified by the proof.
21 UnsupportedFieldExtension(usize),
22 /// This error occurs when a verifier cannot deserialize the specified proof.
23 ProofDeserializationError(String),
24 /// This error occurs when a verifier fails to draw a random value from a random coin
25 /// within a specified number of tries.
26 RandomCoinError,
27 /// This error occurs when constraints evaluated over out-of-domain trace rows do not match
28 /// evaluations of the constraint composition polynomial at the out-of-domain point.
29 InconsistentOodConstraintEvaluations,
30 /// This error occurs when the batch opening proof fails to verify for trace queries.
31 TraceQueryDoesNotMatchCommitment,
32 /// This error occurs when the batch opening proof fails to verify for constraint evaluation
33 /// queries.
34 ConstraintQueryDoesNotMatchCommitment,
35 /// This error occurs when the proof-of-work nonce hashed with the current state of the public
36 /// coin resolves to a value which does not meet the proof-of-work threshold specified by the
37 // proof options.
38 QuerySeedProofOfWorkVerificationFailed,
39 /// This error occurs when the DEEP composition polynomial evaluations derived from trace and
40 /// constraint evaluation queries do not represent a polynomial of the degree expected by the
41 /// verifier.
42 FriVerificationFailed(fri::VerifierError),
43 /// This error occurs when the parameters, that were used to generate the proof, do not provide
44 /// a conjectured security level greater than or equal to the conjectured security level
45 /// expected by the verifier.
46 InsufficientConjecturedSecurity(u32, u32),
47 /// This error occurs when the parameters, that were used to generate the proof, do not provide
48 /// a proven security level greater than or equal to the proven security level expected by
49 /// the verifier.
50 InsufficientProvenSecurity(u32, u32),
51 /// This error occurs when the parameters, that were used to generate the proof, do not match
52 /// any of the set of parameters expected by the verifier.
53 UnacceptableProofOptions,
54}
55
56impl fmt::Display for VerifierError {
57 #[rustfmt::skip]
58 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
59 match self {
60 Self::InconsistentBaseField => {
61 write!(f, "base field of the proof does not match base field of the specified AIR")
62 }
63 Self::UnsupportedFieldExtension(degree) => {
64 write!(f, "field extension of degree {degree} is not supported for the proof base field")
65 }
66 Self::ProofDeserializationError(msg) => {
67 write!(f, "proof deserialization failed: {msg}")
68 }
69 Self::RandomCoinError => {
70 write!(f, "failed to draw a random value from a random coin")
71 }
72 Self::InconsistentOodConstraintEvaluations => {
73 write!(f, "constraint evaluations over the out-of-domain frame are inconsistent")
74 }
75 Self::TraceQueryDoesNotMatchCommitment => {
76 write!(f, "failed to open trace query against the given commitment")
77 }
78 Self::ConstraintQueryDoesNotMatchCommitment => {
79 write!(f, "failed to open constraint query against the given commitment")
80 }
81 Self::QuerySeedProofOfWorkVerificationFailed => {
82 write!(f, "query seed proof-of-work verification failed")
83 }
84 Self::FriVerificationFailed(err) => {
85 write!(f, "verification of low-degree proof failed: {err}")
86 }
87 Self::InsufficientConjecturedSecurity(minimal_security, proof_security)=> {
88 write!(f, "insufficient proof security level: expected at least {minimal_security} bits of conjectured security, but was {proof_security} bits")
89 }
90 Self::InsufficientProvenSecurity(minimal_security, proof_security)=> {
91 write!(f, "insufficient proof security level: expected at least {minimal_security} bits of proven security, but was {proof_security} bits")
92 }
93 Self::UnacceptableProofOptions => {write!(f, "invalid proof options: security parameters do not match the acceptable parameter set")}
94 }
95 }
96}
97
98impl core::error::Error for VerifierError {}