noah_algebra/
errors.rs

1use ark_std::{error, fmt};
2
3#[derive(Debug, Copy, Clone, Eq, PartialEq)]
4#[allow(missing_docs)]
5pub enum AlgebraError {
6    ArgumentVerificationError,
7    BitConversionError,
8    CommitmentInputError,
9    CommitmentVerificationError,
10    DecompressElementError,
11    DeserializationError,
12    SerializationError,
13    IndexError,
14    ParameterError,
15    InconsistentStructureError,
16    SignatureError,
17    GroupInversionError,
18}
19
20impl fmt::Display for AlgebraError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        use AlgebraError::*;
23        f.write_str(match self {
24            ArgumentVerificationError => "Proof(argument) not valid for statement",
25            BitConversionError => "Bit conversion is not valid",
26            CommitmentInputError => "The number of messages to be committed is invalid",
27            CommitmentVerificationError => "Commitment verification failed",
28            DecompressElementError => "Could not decompress group Element",
29            DeserializationError => "Could not deserialize object",
30            SerializationError => "Could not serialize object",
31            IndexError => "Index out of bounds",
32            ParameterError => "Unexpected parameter for method or function",
33            SignatureError => "Signature verification failed",
34            InconsistentStructureError => "Noah Structure is inconsistent",
35            GroupInversionError => "Group Element not invertible",
36        })
37    }
38}
39
40impl error::Error for AlgebraError {
41    fn description(&self) -> &str {
42        use AlgebraError::*;
43        match self {
44            ArgumentVerificationError => "Proof(argument) not valid for statement",
45            BitConversionError => "Bit conversion is not valid",
46            CommitmentInputError => "The number of messages to be committed is invalid",
47            CommitmentVerificationError => "Commitment verification failed",
48            DecompressElementError => "Could not decompress group Element",
49            DeserializationError => "Could not deserialize object",
50            SerializationError => "Could not serialize object",
51            IndexError => "Index out of bounds",
52            ParameterError => "Unexpected parameter for method or function",
53            SignatureError => "Signature verification failed",
54            InconsistentStructureError => "Noah Structure is inconsistent",
55            GroupInversionError => "Group Element not invertible",
56        }
57    }
58}
59
60#[derive(Debug, Clone, Eq, PartialEq)]
61#[allow(missing_docs)]
62pub enum NoahError {
63    AXfrProverParamsError,
64    AXfrVerifierParamsError,
65    AXfrVerificationError,
66    AXfrProofError,
67    AnonFeeProofError,
68    ArgumentVerificationError,
69    CommitmentInputError,
70    CommitmentVerificationError,
71    DecompressElementError,
72    EncryptionError,
73    RangeProofProveError,
74    RangeProofVerifyError,
75    DeserializationError,
76    SerializationError,
77    DecryptionError,
78    IndexError,
79    ParameterError,
80    InconsistentStructureError,
81    SignatureError,
82    XfrVerifyAssetAmountError,
83    XfrVerifyConfidentialAssetError,
84    XfrCreationAssetAmountError,
85    XfrVerifyAssetTracingAssetAmountError,
86    XfrVerifyAssetTracingIdentityError,
87    XfrVerifyAssetTracingEmptyProofError,
88    XfrVerifyConfidentialAmountError,
89    ElGamalVerificationError,
90    ElGamalDecryptionError,
91    IdentityRevealVerifyError,
92    AssetMixerVerificationError,
93    XfrNotSupported,
94    MerkleTreeVerificationError,
95    WhitelistVerificationError,
96    WhitelistProveError,
97    SolvencyInputError,
98    SolvencyProveError,
99    SolvencyVerificationError,
100    ZKProofVerificationError,
101    ZKProofBatchVerificationError,
102    GroupSignatureTraceError,
103    AssetTracingExtractionError,
104    IdentityTracingExtractionError,
105    AnonymousCredentialSignError,
106    R1CSProofError,
107    NoMemoInAssetTracerMemo,
108    BogusAssetTracerMemo,
109    MissingURSError,
110    MissingSRSError,
111    MissingVerifierParamsError,
112    AbarToBarParamsError,
113}
114
115impl fmt::Display for NoahError {
116    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
117        use NoahError::*;
118        f.write_str(match self {
119            AXfrProverParamsError => "Could not preprocess anonymous transfer prover",
120            AXfrVerifierParamsError => "Could not preprocess anonymous transfer verifier",
121            AXfrVerificationError => "Invalid AXfrBody for merkle root",
122            AXfrProofError => "Could not create anonymous transfer proof",
123            AbarToBarParamsError => "Could not preprocess Abr2Bar conversion prover",
124            AnonFeeProofError => "Could not create anonymous transfer proof",
125            ArgumentVerificationError => "Proof not valid for statement",
126            CommitmentInputError => "The number of messages to be committed is invalid",
127            CommitmentVerificationError => "Commitment verification failed",
128            DecompressElementError => "Could not decompress group Element",
129            RangeProofProveError => "Could not create range proof due to incorrect input or parameters",
130            RangeProofVerifyError => "Range proof invalid for input commitments or parameters",
131            DeserializationError => "Could not deserialize object",
132            SerializationError => "Could not serialize object",
133            EncryptionError => "Ciphertext encryption failed",
134            DecryptionError => "Ciphertext failed authentication verification",
135            IndexError => "Index out of bounds",
136            ParameterError => "Unexpected parameter for method or function",
137            SignatureError => "Signature verification failed",
138            XfrVerifyAssetAmountError => "Invalid total amount per asset in non confidential asset transfer",
139            XfrVerifyConfidentialAmountError => "Invalid amount in non confidential asset transfer",
140            XfrVerifyAssetTracingAssetAmountError => "Asset Tracking error. Asset commitment and asset ciphertext do not match",
141            XfrVerifyAssetTracingIdentityError => "Asset Tracking error. Identity reveal proof does not hold",
142            XfrVerifyAssetTracingEmptyProofError => "Asset Tracking error. Tracked assets must contain asset tracking proof",
143            XfrVerifyConfidentialAssetError => "Invalid asset type in non confidential asset transfer",
144            XfrCreationAssetAmountError => "Invalid total amount per asset in non confidential asset transfer",
145            ElGamalVerificationError => "ElGamal Ciphertext not valid for proposed scalar message",
146            ElGamalDecryptionError => "ElGamal Ciphertext could not be decrypted",
147            InconsistentStructureError => "Noah Structure is inconsistent",
148            IdentityRevealVerifyError => "Verification error for confidential identity reveal proof",
149            AssetMixerVerificationError => "Verification error for asset mixing proof",
150            XfrNotSupported => "Transaction type not supported",
151            MerkleTreeVerificationError => "Invalid proof for merkle tree inclusion",
152            WhitelistVerificationError => "Invalid proof for whitelist inclusion",
153            WhitelistProveError => "Cannot build proof for whitelist",
154            SolvencyVerificationError => "Invalid proof for solvency",
155            SolvencyProveError => "Cannot build proof of solvency",
156            SolvencyInputError => "Invalid input for solvency",
157            ZKProofVerificationError => "Invalid proof",
158            ZKProofBatchVerificationError => "Batch proof instance contains an error",
159            GroupSignatureTraceError => "Trace test did not match",
160            AssetTracingExtractionError => "Cannot extract correct data from tracing ciphertext",
161            IdentityTracingExtractionError => "Cannot extract identity attributes from tracing ciphertext",
162            AnonymousCredentialSignError => "The number of attributes passed as parameter differs from the number of attributes of the AC issuer public key",
163            R1CSProofError =>  "Could not create R1CSProof",
164            NoMemoInAssetTracerMemo => "Cannot decrypt asset tracer memo, try brute force decoding",
165            BogusAssetTracerMemo => "AssetTracerMemo decryption yields inconsistent data, try brute force decoding",
166            MissingURSError => "The Noah library is compiled without URS. Such parameters must be created first",
167            MissingSRSError => "The Noah library is compiled without SRS, which prevents proof generation",
168            MissingVerifierParamsError => "The program is loading verifier parameters that are not hardcoded. Such parameters must be created first",
169        })
170    }
171}
172
173impl error::Error for NoahError {}