errors.rs
1 // Copyright (c) 2025-2026 ACDC Network 2 // This file is part of the alphavm library. 3 // 4 // Alpha Chain | Delta Chain Protocol 5 // International Monetary Graphite. 6 // 7 // Derived from Aleo (https://aleo.org) and ProvableHQ (https://provable.com). 8 // They built world-class ZK infrastructure. We installed the EASY button. 9 // Their cryptography: elegant. Our modifications: bureaucracy-compatible. 10 // Original brilliance: theirs. Robert's Rules: ours. Bugs: definitely ours. 11 // 12 // Original Aleo/ProvableHQ code subject to Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0 13 // All modifications and new work: CC0 1.0 Universal Public Domain Dedication. 14 // No rights reserved. No permission required. No warranty. No refunds. 15 // 16 // https://creativecommons.org/publicdomain/zero/1.0/ 17 // SPDX-License-Identifier: CC0-1.0 18 19 pub type SynthesisResult<T> = Result<T, SynthesisError>; 20 21 /// This is an error that could occur during circuit synthesis contexts, 22 /// such as CRS generation, proving or verification. 23 #[derive(Debug, Error)] 24 pub enum SynthesisError { 25 #[error("{}", _0)] 26 AnyhowError(#[from] anyhow::Error), 27 /// During synthesis, we lacked knowledge of a variable assignment. 28 #[error("An assignment for a variable could not be computed")] 29 AssignmentMissing, 30 /// Handles a failed conversion of objects into constraint field elements. 31 #[error("Failed to convert object into constraint field elements")] 32 ConstraintFieldError(#[from] alphavm_fields::ConstraintFieldError), 33 /// During synthesis, we divided by zero. 34 #[error("Division by zero during synthesis")] 35 DivisionByZero, 36 /// During synthesis, we constructed an unsatisfiable constraint system. 37 #[error("Unsatisfiable constraint system")] 38 Unsatisfiable, 39 /// During synthesis, our polynomials ended up being too high of degree 40 #[error("Polynomial degree is too large")] 41 PolyTooLarge, 42 /// During proof generation, we encountered an identity in the CRS 43 #[error("Encountered an identity element in the CRS")] 44 UnexpectedIdentity, 45 /// During proof generation, we encountered an I/O error with the CRS 46 #[error("Encountered an I/O error")] 47 IoError(std::io::Error), 48 /// During verification, our verifying key was malformed. 49 #[error("Malformed verifying key, public input count was {} but expected {}", _0, _1)] 50 MalformedVerifyingKey(usize, usize), 51 /// During CRS generation, we observed an unconstrained auxiliary variable 52 #[error("Auxiliary variable was unconstrained")] 53 UnconstrainedVariable, 54 } 55 56 impl From<std::io::Error> for SynthesisError { 57 fn from(e: std::io::Error) -> SynthesisError { 58 SynthesisError::IoError(e) 59 } 60 }