equix/err.rs
1//! Error types for the `equix` crate
2
3pub use hashx::Error as HashError;
4
5/// Errors applicable to constructing and verifying Equi-X puzzles
6#[derive(Clone, Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9 /// Errors inherited from [`hashx`]
10 ///
11 /// Notably, [`HashError::ProgramConstraints`] needs to be handled
12 /// by any program which generates new challenge strings, and
13 /// [`HashError::Compiler`] may show up if you've chosen
14 /// [`crate::RuntimeOption::CompileOnly`] via [`crate::EquiXBuilder`].
15 #[error("hash construction error: {0}")]
16 Hash(#[from] HashError),
17
18 /// A solution does not meet Equi-X's ordering requirements.
19 ///
20 /// This error occurs independently of the specific challenge
21 /// string. The lexicographic ordering constraints of a well
22 /// formed Equi-X solution were not met.
23 #[error("failed order constraint, Equi-X solution is not well formed")]
24 Order,
25
26 /// Failed hash sum verification of a challenge and solution.
27 ///
28 /// The tree of hash sums computed from the solution and challenge
29 /// are required to have a number of low bits zeroed on each level.
30 /// One of these tests failed, and the solution is not valid.
31 #[error("failed to verify hash sum constraints for a specific Equi-X challenge and solution")]
32 HashSum,
33}