|
| 1 | +use num_bigint::{BigInt, TryFromBigIntError}; |
| 2 | +use starknet_types_core::felt::FeltIsZeroError; |
| 3 | + |
| 4 | +#[cfg(feature = "std")] |
| 5 | +use thiserror::Error; |
| 6 | + |
| 7 | +#[cfg(feature = "std")] |
| 8 | +#[derive(Error, Debug)] |
| 9 | +pub enum CompositionPolyEvalError { |
| 10 | + #[error("segment not present {segment}")] |
| 11 | + SegmentMissing { segment: usize }, |
| 12 | + |
| 13 | + #[error("value out of range")] |
| 14 | + ValueOutOfRange, |
| 15 | + |
| 16 | + #[error("dynamic params missing")] |
| 17 | + DynamicParamsMissing, |
| 18 | + |
| 19 | + #[error("field element is zero")] |
| 20 | + FeltIsZero(#[from] FeltIsZeroError), |
| 21 | +} |
| 22 | + |
| 23 | +#[cfg(feature = "std")] |
| 24 | +#[derive(Error, Debug)] |
| 25 | +pub enum OodsPolyEvalError { |
| 26 | + #[error("dynamic params missing")] |
| 27 | + DynamicParamsMissing, |
| 28 | + |
| 29 | + #[error("field element is zero")] |
| 30 | + FeltIsZero(#[from] FeltIsZeroError), |
| 31 | +} |
| 32 | + |
| 33 | +#[cfg(feature = "std")] |
| 34 | +#[derive(Error, Debug)] |
| 35 | +pub enum PublicInputError { |
| 36 | + #[error("max steps exceeded")] |
| 37 | + MaxSteps, |
| 38 | + |
| 39 | + #[error("trace length invalid")] |
| 40 | + TraceLengthInvalid, |
| 41 | + |
| 42 | + #[error("segment not present {segment}")] |
| 43 | + SegmentMissing { segment: usize }, |
| 44 | + |
| 45 | + #[error("layout code invalid")] |
| 46 | + LayoutCodeInvalid, |
| 47 | + |
| 48 | + #[error("range_check invalid")] |
| 49 | + RangeCheckInvalid, |
| 50 | + |
| 51 | + #[error("invalid number of builtin uses")] |
| 52 | + UsesInvalid, |
| 53 | + |
| 54 | + #[error("invalid number of builtin copies")] |
| 55 | + CopiesInvalid, |
| 56 | + |
| 57 | + #[error("invalid number of segments")] |
| 58 | + InvalidSegments, |
| 59 | + |
| 60 | + #[error("dynamic params missing")] |
| 61 | + DynamicParamsMissing, |
| 62 | + |
| 63 | + #[error("BigInt conversion Error")] |
| 64 | + TryFromBigInt(#[from] TryFromBigIntError<BigInt>), |
| 65 | + |
| 66 | + #[error("field element is zero")] |
| 67 | + FeltIsZero(#[from] FeltIsZeroError), |
| 68 | + |
| 69 | + #[error("dynamic params check failed")] |
| 70 | + CheckAsserts(#[from] CheckAssertsError), |
| 71 | +} |
| 72 | + |
| 73 | +#[cfg(feature = "std")] |
| 74 | +#[derive(Error, Debug)] |
| 75 | +pub enum CheckAssertsError { |
| 76 | + #[error("value is not power of two")] |
| 77 | + NotPowerOfTwo, |
| 78 | + |
| 79 | + #[error("value out of range")] |
| 80 | + OutOfRange, |
| 81 | + |
| 82 | + #[error("value not boolean")] |
| 83 | + NotBoolean, |
| 84 | + |
| 85 | + #[error("field element is zero")] |
| 86 | + FeltIsZero(#[from] FeltIsZeroError), |
| 87 | + |
| 88 | + #[error("field multiplication fail")] |
| 89 | + SafeMult(#[from] SafeMultError), |
| 90 | + |
| 91 | + #[error("segment not present {segment}")] |
| 92 | + SegmentMissing { segment: usize }, |
| 93 | +} |
| 94 | + |
| 95 | +#[cfg(feature = "std")] |
| 96 | +#[derive(Error, Debug)] |
| 97 | +pub enum SafeMultError { |
| 98 | + #[error("value multiplication overflowed actual {actual}, expected {expected}")] |
| 99 | + Overflow { actual: BigInt, expected: BigInt }, |
| 100 | +} |
| 101 | + |
| 102 | +#[cfg(not(feature = "std"))] |
| 103 | +use thiserror_no_std::Error; |
| 104 | + |
| 105 | +#[cfg(not(feature = "std"))] |
| 106 | +#[derive(Error, Debug)] |
| 107 | +pub enum CompositionPolyEvalError { |
| 108 | + #[error("segment not present {segment}")] |
| 109 | + SegmentMissing { segment: usize }, |
| 110 | + |
| 111 | + #[error("value out of range")] |
| 112 | + ValueOutOfRange, |
| 113 | + |
| 114 | + #[error("dynamic params missing")] |
| 115 | + DynamicParamsMissing, |
| 116 | + |
| 117 | + #[error("field element is zero")] |
| 118 | + FeltIsZero(#[from] FeltIsZeroError), |
| 119 | +} |
| 120 | + |
| 121 | +#[cfg(not(feature = "std"))] |
| 122 | +#[derive(Error, Debug)] |
| 123 | +pub enum OodsPolyEvalError { |
| 124 | + #[error("dynamic params missing")] |
| 125 | + DynamicParamsMissing, |
| 126 | + |
| 127 | + #[error("field element is zero")] |
| 128 | + FeltIsZero(#[from] FeltIsZeroError), |
| 129 | +} |
| 130 | + |
| 131 | +#[cfg(not(feature = "std"))] |
| 132 | +#[derive(Error, Debug)] |
| 133 | +pub enum PublicInputError { |
| 134 | + #[error("max steps exceeded")] |
| 135 | + MaxSteps, |
| 136 | + |
| 137 | + #[error("trace length invalid")] |
| 138 | + TraceLengthInvalid, |
| 139 | + |
| 140 | + #[error("segment not present {segment}")] |
| 141 | + SegmentMissing { segment: usize }, |
| 142 | + |
| 143 | + #[error("layout code invalid")] |
| 144 | + LayoutCodeInvalid, |
| 145 | + |
| 146 | + #[error("range_check invalid")] |
| 147 | + RangeCheckInvalid, |
| 148 | + |
| 149 | + #[error("invalid number of builtin uses")] |
| 150 | + UsesInvalid, |
| 151 | + |
| 152 | + #[error("invalid number of builtin copies")] |
| 153 | + CopiesInvalid, |
| 154 | + |
| 155 | + #[error("invalid number of segments")] |
| 156 | + InvalidSegments, |
| 157 | + |
| 158 | + #[error("dynamic params missing")] |
| 159 | + DynamicParamsMissing, |
| 160 | + |
| 161 | + #[error("BigInt conversion Error")] |
| 162 | + TryFromBigInt(#[from] TryFromBigIntError<BigInt>), |
| 163 | + |
| 164 | + #[error("field element is zero")] |
| 165 | + FeltIsZero(#[from] FeltIsZeroError), |
| 166 | + |
| 167 | + #[error("dynamic params check failed")] |
| 168 | + CheckAsserts(#[from] CheckAssertsError), |
| 169 | +} |
| 170 | + |
| 171 | +#[cfg(not(feature = "std"))] |
| 172 | +#[derive(Error, Debug)] |
| 173 | +pub enum CheckAssertsError { |
| 174 | + #[error("value is not power of two")] |
| 175 | + NotPowerOfTwo, |
| 176 | + |
| 177 | + #[error("value out of range")] |
| 178 | + OutOfRange, |
| 179 | + |
| 180 | + #[error("value not boolean")] |
| 181 | + NotBoolean, |
| 182 | + |
| 183 | + #[error("field element is zero")] |
| 184 | + FeltIsZero(#[from] FeltIsZeroError), |
| 185 | + |
| 186 | + #[error("field multiplication fail")] |
| 187 | + SafeMult(#[from] SafeMultError), |
| 188 | + |
| 189 | + #[error("segment not present {segment}")] |
| 190 | + SegmentMissing { segment: usize }, |
| 191 | +} |
| 192 | + |
| 193 | +#[cfg(not(feature = "std"))] |
| 194 | +#[derive(Error, Debug)] |
| 195 | +pub enum SafeMultError { |
| 196 | + #[error("value multiplication overflowed actual {actual}, expected {expected}")] |
| 197 | + Overflow { actual: BigInt, expected: BigInt }, |
| 198 | +} |
0 commit comments