arnaucube
arnaucube/hyperplonkPublic Self-hosted repository
hyperplonk/hyperplonk/src/errors.rs
hyperplonk/src/errors.rsRaw
 1// Copyright (c) 2023 Espresso Systems (espressosys.com)
 2// This file is part of the HyperPlonk library.
 3
 4// You should have received a copy of the MIT License
 5// along with the HyperPlonk 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 subroutines::{pcs::prelude::PCSError, poly_iop::prelude::PolyIOPErrors};
14use transcript::TranscriptError;
15
16/// A `enum` specifying the possible failure modes of hyperplonk.
17#[derive(Display, Debug)]
18pub enum HyperPlonkErrors {
19    /// Invalid Prover: {0}
20    InvalidProver(String),
21    /// Invalid Verifier: {0}
22    InvalidVerifier(String),
23    /// Invalid Proof: {0}
24    InvalidProof(String),
25    /// Invalid parameters: {0}
26    InvalidParameters(String),
27    /// An error during (de)serialization: {0}
28    SerializationError(SerializationError),
29    /// PolyIOP error {0}
30    PolyIOPErrors(PolyIOPErrors),
31    /// PCS error {0}
32    PCSErrors(PCSError),
33    /// Transcript error {0}
34    TranscriptError(TranscriptError),
35    /// Arithmetic Error: {0}
36    ArithmeticErrors(ArithErrors),
37}
38
39impl From<SerializationError> for HyperPlonkErrors {
40    fn from(e: ark_serialize::SerializationError) -> Self {
41        Self::SerializationError(e)
42    }
43}
44
45impl From<PolyIOPErrors> for HyperPlonkErrors {
46    fn from(e: PolyIOPErrors) -> Self {
47        Self::PolyIOPErrors(e)
48    }
49}
50
51impl From<PCSError> for HyperPlonkErrors {
52    fn from(e: PCSError) -> Self {
53        Self::PCSErrors(e)
54    }
55}
56
57impl From<TranscriptError> for HyperPlonkErrors {
58    fn from(e: TranscriptError) -> Self {
59        Self::TranscriptError(e)
60    }
61}
62
63impl From<ArithErrors> for HyperPlonkErrors {
64    fn from(e: ArithErrors) -> Self {
65        Self::ArithmeticErrors(e)
66    }
67}