From e7f8d1145531b0b8ec45507e92d3a6f26829fce8 Mon Sep 17 00:00:00 2001 From: Srinath Setty Date: Tue, 31 Jan 2023 18:31:34 -0800 Subject: [PATCH] use thiserror (#135) --- Cargo.toml | 1 + src/errors.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 994ee28..0db164b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ bincode = "1.2.1" flate2 = "1.0" bitvec = "1.0" byteorder = "1.4.3" +thiserror = "1.0" [target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies] pasta-msm = { version = "0.1.0", package = "lurk-pasta-msm" } diff --git a/src/errors.rs b/src/errors.rs index cc2081b..2887d3d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,31 +1,44 @@ //! This module defines errors returned by the library. use core::fmt::Debug; +use thiserror::Error; /// Errors returned by Nova -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Error)] pub enum NovaError { /// returned if the supplied row or col in (row,col,val) tuple is out of range + #[error("InvalidIndex")] InvalidIndex, /// returned if the supplied input is not even-sized + #[error("OddInputLength")] OddInputLength, /// returned if the supplied input is not of the right length + #[error("InvalidInputLength")] InvalidInputLength, /// returned if the supplied witness is not of the right length + #[error("InvalidWitnessLength")] InvalidWitnessLength, /// returned if the supplied witness is not a satisfying witness to a given shape and instance + #[error("UnSat")] UnSat, /// returned when the supplied compressed commitment cannot be decompressed + #[error("DecompressionError")] DecompressionError, /// returned if proof verification fails + #[error("ProofVerifyError")] ProofVerifyError, /// returned if the provided number of steps is zero + #[error("InvalidNumSteps")] InvalidNumSteps, /// returned when an invalid inner product argument is provided + #[error("InvalidIPA")] InvalidIPA, /// returned when an invalid sum-check proof is provided + #[error("InvalidSumcheckProof")] InvalidSumcheckProof, /// returned when the initial input to an incremental computation differs from a previously declared arity + #[error("InvalidInitialInputLength")] InvalidInitialInputLength, /// returned when the step execution produces an output whose length differs from a previously declared arity + #[error("InvalidStepOutputLength")] InvalidStepOutputLength, }