snarkvm_algorithms/snark/varuna/ahp/
errors.rs

1// Copyright 2024 Aleo Network Foundation
2// This file is part of the snarkVM library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7
8// http://www.apache.org/licenses/LICENSE-2.0
9
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16/// Describes the failure modes of the AHP scheme.
17#[derive(Debug, Error)]
18pub enum AHPError {
19    #[error("{}", _0)]
20    AnyhowError(#[from] anyhow::Error),
21
22    #[error("Batch size was zero; must be at least 1.")]
23    BatchSizeIsZero,
24
25    #[error("An error occurred during constraint generation.")]
26    ConstraintSystemError(crate::r1cs::errors::SynthesisError),
27
28    #[error("The instance generated during proving does not match that in the index.")]
29    InstanceDoesNotMatchIndex,
30
31    #[error("The number of public inputs is incorrect.")]
32    InvalidPublicInputLength,
33
34    #[error("During verification, a required evaluation is missing: {}", _0)]
35    MissingEval(String),
36
37    #[error("Currently we only support square constraint matrices.")]
38    NonSquareMatrix,
39
40    #[error("During synthesis, our polynomials ended up being too high of degree.")]
41    PolyTooLarge,
42}
43
44impl From<crate::r1cs::errors::SynthesisError> for AHPError {
45    fn from(other: crate::r1cs::errors::SynthesisError) -> Self {
46        AHPError::ConstraintSystemError(other)
47    }
48}