core_utils/circuit/
errors.rs1use primitives::algebra::elliptic_curve::Curve;
2
3use crate::circuit::{AlgebraicType, Gate, GateIndex};
4
5#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
6pub enum ConversionError {
7 #[error("Cannot transform AlgebraicType {0:?} into FieldType")]
8 IntoFieldTypeError(AlgebraicType),
9}
10
11#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
12pub enum SliceError {
13 #[error("Expected non-negative index, found {0}")]
14 NegativeIndex(i32),
15}
16
17#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
18#[error("Batch size must be a strictly positive integer, found {0}")]
19pub struct BatchSizeError(pub usize);
20
21#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
22#[error("Internal error: {0}")]
23pub struct InternalError(pub String);
24
25#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
26pub enum CircuitError<C: Curve> {
27 #[error("Invalid gate {0:?}: {1}")]
28 InvalidGate(Gate<C>, String),
29 #[error("Gate index {0} out-of-bounds [0,{1})")]
30 GateIndexOutOfBounds(GateIndex, GateIndex),
31 #[error("Conversion error: {0}")]
32 ConversionError(#[from] ConversionError),
33 #[error("Invalid gate input count, expected {expected} inputs found {found}")]
34 InvalidGateInputCount { expected: usize, found: usize },
35 #[error("Invalid gate algebraic type, expected {expected:?} found {found:?}")]
36 InvalidGateAlgebraicType {
37 expected: AlgebraicType,
38 found: AlgebraicType,
39 },
40 #[error("Circuit is limited to a maximum of 2^32 gates")]
41 CircuitTooBig,
42 #[error("Slice error: {0}")]
43 SliceError(#[from] SliceError),
44 #[error("{0}")]
45 InternalError(#[from] InternalError),
46 #[error("{0}")]
47 BatchSizeError(#[from] BatchSizeError),
48}