hyperplonk/subroutines/src/poly_iop/errors.rs
subroutines/src/poly_iop/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 crate::pcs::prelude::PCSError;
10use arithmetic::ArithErrors;
11use ark_std::string::String;
12use displaydoc::Display;
13use transcript::TranscriptError;
14
15/// A `enum` specifying the possible failure modes of the PolyIOP.
16#[derive(Display, Debug)]
17pub enum PolyIOPErrors {
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 /// Invalid challenge: {0}
27 InvalidChallenge(String),
28 /// Should not arrive to this point
29 ShouldNotArrive,
30 /// An error during (de)serialization: {0}
31 SerializationErrors(ark_serialize::SerializationError),
32 /// Transcript Error: {0}
33 TranscriptErrors(TranscriptError),
34 /// Arithmetic Error: {0}
35 ArithmeticErrors(ArithErrors),
36 /// PCS error {0}
37 PCSErrors(PCSError),
38}
39
40impl From<ark_serialize::SerializationError> for PolyIOPErrors {
41 fn from(e: ark_serialize::SerializationError) -> Self {
42 Self::SerializationErrors(e)
43 }
44}
45
46impl From<TranscriptError> for PolyIOPErrors {
47 fn from(e: TranscriptError) -> Self {
48 Self::TranscriptErrors(e)
49 }
50}
51
52impl From<ArithErrors> for PolyIOPErrors {
53 fn from(e: ArithErrors) -> Self {
54 Self::ArithmeticErrors(e)
55 }
56}
57
58impl From<PCSError> for PolyIOPErrors {
59 fn from(e: PCSError) -> Self {
60 Self::PCSErrors(e)
61 }
62}