1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use bellperson::SynthesisError;
pub type Result<T> = ::std::result::Result<T, Error>;
#[derive(Debug, Fail)]
pub enum Error {
#[fail(display = "Bytes could not be converted to Fr")]
BadFrBytes,
#[fail(
display = "Could not create PieceInclusionProof (probably bad piece commitment: comm_p)"
)]
BadPieceCommitment,
#[fail(display = "Out of bounds access {} > {}", _0, _1)]
OutOfBounds(usize, usize),
#[fail(
display = "mismatch of data, node_size and nodes {} != {} * {}",
_0, _1, _2
)]
InvalidMerkleTreeArgs(usize, usize, usize),
#[fail(display = "{}", _0)]
Synthesis(#[cause] SynthesisError),
#[fail(display = "{}", _0)]
Io(#[cause] ::std::io::Error),
#[fail(display = "tree root and commitment do not match")]
InvalidCommitment,
#[fail(display = "malformed input")]
MalformedInput,
#[fail(display = "malformed merkle tree")]
MalformedMerkleTree,
#[fail(display = "invalid input size")]
InvalidInputSize,
#[fail(display = "merkle tree generation error: {}", _0)]
MerkleTreeGenerationError(String),
#[fail(display = "Cannot (yet) generate inclusion proof for unaligned piece.")]
UnalignedPiece,
#[fail(display = "{}", _0)]
Serde(#[cause] serde_json::error::Error),
#[fail(display = "unclassified error: {}", _0)]
Unclassified(String),
}
impl From<SynthesisError> for Error {
fn from(inner: SynthesisError) -> Error {
Error::Synthesis(inner)
}
}
impl From<::std::io::Error> for Error {
fn from(inner: ::std::io::Error) -> Error {
Error::Io(inner)
}
}
impl From<serde_json::error::Error> for Error {
fn from(inner: serde_json::error::Error) -> Error {
Error::Serde(inner)
}
}