arnaucube
arnaucube/hyperplonkPublic Self-hosted repository
hyperplonk/subroutines/src/pcs/errors.rs
subroutines/src/pcs/errors.rsRaw
 1// Copyright (c) 2022 Espresso Systems (espressosys.com)
 2// This file is part of the Jellyfish library.
 3
 4// You should have received a copy of the MIT License
 5// along with the Jellyfish library. If not, see <https://mit-license.org/>.
 6
 7//! Error module.
 8
 9use arithmetic::ArithErrors;
10use ark_serialize::SerializationError;
11use ark_std::string::String;
12use displaydoc::Display;
13use transcript::TranscriptError;
14
15/// A `enum` specifying the possible failure modes of the PCS.
16#[derive(Display, Debug)]
17pub enum PCSError {
18    /// Invalid Prover: {0}
19    InvalidProver(String),
20    /// Invalid Verifier: {0}
21    InvalidVerifier(String),
22    /// Invalid Proof: {0}
23    InvalidProof(String),
24    /// Invalid parameters: {0}
25    InvalidParameters(String),
26    /// An error during (de)serialization: {0}
27    SerializationError(SerializationError),
28    /// Transcript error {0}
29    TranscriptError(TranscriptError),
30    /// ArithErrors error {0}
31    ArithErrors(ArithErrors),
32}
33
34impl From<SerializationError> for PCSError {
35    fn from(e: ark_serialize::SerializationError) -> Self {
36        Self::SerializationError(e)
37    }
38}
39
40impl From<TranscriptError> for PCSError {
41    fn from(e: TranscriptError) -> Self {
42        Self::TranscriptError(e)
43    }
44}
45
46impl From<ArithErrors> for PCSError {
47    fn from(e: ArithErrors) -> Self {
48        Self::ArithErrors(e)
49    }
50}