Skip to main content

nova_snark/
errors.rs

1//! This module defines errors returned by the library.
2use crate::frontend::SynthesisError;
3use core::fmt::Debug;
4use thiserror::Error;
5
6/// Errors returned by Nova
7#[derive(Clone, Debug, Eq, PartialEq, Error)]
8#[non_exhaustive]
9pub enum NovaError {
10  /// returned if the supplied row or col in (row,col,val) tuple is out of range
11  #[error("InvalidIndex")]
12  InvalidIndex,
13  /// returned if the step circuit calls inputize or alloc_io in its synthesize method
14  /// instead of passing output with the return value
15  #[error("InvalidStepCircuitIO")]
16  InvalidStepCircuitIO,
17  /// returned if the supplied input is not of the right length
18  #[error("InvalidInputLength")]
19  InvalidInputLength,
20  /// returned if the supplied witness is not of the right length
21  #[error("InvalidWitnessLength")]
22  InvalidWitnessLength,
23  /// returned if the supplied witness is not a satisfying witness to a given shape and instance
24  #[error("UnSat: {reason}")]
25  UnSat {
26    /// The reason for circuit UnSat failure
27    reason: String,
28  },
29  /// returned if proof verification fails
30  #[error("ProofVerifyError")]
31  ProofVerifyError {
32    /// The reason for the proof verification error
33    reason: String,
34  },
35  /// returned if the provided commitment key is not of sufficient length
36  #[error("InvalidCommitmentKeyLength")]
37  InvalidCommitmentKeyLength,
38  /// returned if a commitment key contains a point that is not on the curve,
39  /// or (for points in G2) not in the prime-order subgroup
40  #[error("InvalidCommitmentKey: {reason}")]
41  InvalidCommitmentKey {
42    /// The reason the commitment key is invalid
43    reason: String,
44  },
45  /// returned if the provided number of steps is zero
46  #[error("InvalidNumSteps")]
47  InvalidNumSteps,
48  /// returned when an invalid PCS evaluation argument is provided
49  #[error("InvalidPCS")]
50  InvalidPCS,
51  /// returned when an invalid sum-check proof is provided
52  #[error("InvalidSumcheckProof")]
53  InvalidSumcheckProof,
54  /// returned when the initial input to an incremental computation differs from a previously declared arity
55  #[error("InvalidInitialInputLength")]
56  InvalidInitialInputLength,
57  /// returned when the step execution produces an output whose length differs from a previously declared arity
58  #[error("InvalidStepOutputLength")]
59  InvalidStepOutputLength,
60  /// returned when the transcript engine encounters an overflow of the round number
61  #[error("InternalTranscriptError")]
62  InternalTranscriptError,
63  /// returned when the multiset check fails
64  #[error("InvalidMultisetProof")]
65  InvalidMultisetProof,
66  /// returned when the product proof check fails
67  #[error("InvalidProductProof")]
68  InvalidProductProof,
69  /// returned when the consistency with public IO and assignment used fails
70  #[error("IncorrectWitness")]
71  IncorrectWitness,
72  /// returned when error during synthesis
73  #[error("SynthesisError: {reason}")]
74  SynthesisError {
75    /// The reason for circuit synthesis failure
76    reason: String,
77  },
78  /// returned when there is an error creating a digest
79  #[error("DigestError")]
80  DigestError,
81  /// returned when the prover cannot prove the provided statement due to completeness error
82  #[error("InternalError")]
83  InternalError,
84  /// returned when a GPU operation fails
85  #[error("GpuError: {0}")]
86  GpuError(String),
87  /// returned when there is an error reading/writing a ptau file
88  #[error("PtauFileError: {0}")]
89  PtauFileError(String),
90  /// returned when insecure setup is attempted in production builds
91  #[error("SetupError: {0}")]
92  SetupError(String),
93  /// returned when zero instances are provided where at least one is required
94  #[error("InvalidNumInstances")]
95  InvalidNumInstances,
96}
97
98impl From<SynthesisError> for NovaError {
99  fn from(err: SynthesisError) -> Self {
100    Self::SynthesisError {
101      reason: err.to_string(),
102    }
103  }
104}