1use crate::ValueVecLayout;
5
6#[allow(missing_docs)] #[derive(Debug, thiserror::Error)]
9pub enum ConstraintSystemError {
10 #[error("the public input segment must have power of two length")]
11 PublicInputPowerOfTwo,
12 #[error(
13 "the public input segment must be at least {} words, got: {pub_input_size}",
14 ValueVecLayout::MIN_WORDS_PER_SEGMENT
15 )]
16 PublicInputTooShort { pub_input_size: usize },
17 #[error(
18 "the hidden segment must be at least as long as the public segment (public: {public_len}, hidden: {hidden_len})"
19 )]
20 HiddenSegmentTooShort {
21 public_len: usize,
22 hidden_len: usize,
23 },
24 #[error("the data length doesn't match layout. Expected: {expected}, Actual: {actual}")]
25 ValueVecLenMismatch { expected: usize, actual: usize },
26 #[error(
27 "{constraint_type} #{constraint_index} uses non canonical shift in its {operand_name} operand"
28 )]
29 NonCanonicalShift {
30 constraint_type: &'static str,
31 constraint_index: usize,
32 operand_name: &'static str,
33 },
34 #[error(
35 "{constraint_type} #{constraint_index} refers to padding in its {operand_name} operand"
36 )]
37 PaddingValueIndex {
38 constraint_type: &'static str,
39 operand_name: &'static str,
40 constraint_index: usize,
41 },
42 #[error(
43 "{constraint_type} #{constraint_index} uses shift amount n={shift_amount}>={max_amount} in {operand_name} operand"
44 )]
45 ShiftAmountTooLarge {
46 constraint_type: &'static str,
47 constraint_index: usize,
48 operand_name: &'static str,
49 shift_amount: usize,
50 max_amount: usize,
51 },
52 #[error(
53 "{constraint_type} #{constraint_index} refers to out-of-range value index in {operand_name} operand (index {value_index} >= total length {total_len})"
54 )]
55 OutOfRangeValueIndex {
56 constraint_type: &'static str,
57 constraint_index: usize,
58 operand_name: &'static str,
59 value_index: u32,
60 total_len: usize,
61 },
62}