snarkvm_posw/error.rs
1// Copyright (C) 2019-2021 Aleo Systems Inc.
2// This file is part of the snarkVM library.
3
4// The snarkVM library is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// The snarkVM library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with the snarkVM library. If not, see <https://www.gnu.org/licenses/>.
16
17use snarkvm_algorithms::errors::SNARKError;
18use snarkvm_fields::ConstraintFieldError;
19use snarkvm_parameters::errors::ParameterError;
20
21use std::io::Error as IoError;
22use thiserror::Error;
23
24#[derive(Debug, Error)]
25/// An error when generating/verifying a Proof of Succinct Work
26pub enum PoswError {
27 /// Thrown when the parameters cannot be loaded
28 #[error("could not load PoSW parameters: {0}")]
29 Parameters(#[from] ParameterError),
30
31 /// Thrown when a proof fails verification
32 #[error("could not verify PoSW")]
33 PoswVerificationFailed,
34
35 /// Thrown when there's an internal error in the underlying SNARK
36 #[error(transparent)]
37 SnarkError(#[from] SNARKError),
38
39 /// Thrown when there's an IO error
40 #[error(transparent)]
41 IoError(#[from] IoError),
42
43 /// Thrown if the mask conversion to a field element fails
44 #[error(transparent)]
45 ConstraintFieldError(#[from] ConstraintFieldError),
46}