From 88ce934bd7902dd21cca932fba9de62e1fe2de90 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 28 Oct 2021 11:56:39 -0700 Subject: [PATCH] Derive thiserror::Error for ProofError --- zk-token-sdk/src/errors.rs | 19 ++++++++++--------- zk-token-sdk/src/instruction/mod.rs | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/zk-token-sdk/src/errors.rs b/zk-token-sdk/src/errors.rs index 2aee36d4b..b2d47026c 100644 --- a/zk-token-sdk/src/errors.rs +++ b/zk-token-sdk/src/errors.rs @@ -1,19 +1,20 @@ //! Errors related to proving and verifying proofs. +use thiserror::Error; -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Error, Clone, Debug, Eq, PartialEq)] pub enum ProofError { - /// This error occurs when a proof failed to verify. + #[error("proof failed to verify")] VerificationError, - /// This error occurs when the proof encoding is malformed. + #[error("malformed proof")] FormatError, - /// This error occurs during proving if the number of blinding - /// factors does not match the number of values. + #[error("number of blinding factors do not match the number of values")] WrongNumBlindingFactors, - /// This error occurs when attempting to create a proof with - /// bitsize other than \\(8\\), \\(16\\), \\(32\\), or \\(64\\). + #[error("attempted to create a proof with bitsize other than \\(8\\), \\(16\\), \\(32\\), or \\(64\\)")] InvalidBitsize, - /// This error occurs when there are insufficient generators for the proof. + #[error("insufficient generators for the proof")] InvalidGeneratorsLength, - /// This error occurs a `zk_token_elgamal::pod::ElGamalCiphertext` contains invalid ElGamalCiphertext ciphertext + #[error( + "`zk_token_elgamal::pod::ElGamalCiphertext` contains invalid ElGamalCiphertext ciphertext" + )] InconsistentCTData, } diff --git a/zk-token-sdk/src/instruction/mod.rs b/zk-token-sdk/src/instruction/mod.rs index 8c5b5a19f..62d563e0e 100644 --- a/zk-token-sdk/src/instruction/mod.rs +++ b/zk-token-sdk/src/instruction/mod.rs @@ -16,7 +16,7 @@ pub trait Verifiable { } #[cfg(not(target_arch = "bpf"))] -#[derive(Debug,Copy,Clone)] +#[derive(Debug, Copy, Clone)] pub enum Role { Source, Dest,