ark_crypto_primitives_zypher/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(
3    unused,
4    future_incompatible,
5    nonstandard_style,
6    rust_2018_idioms,
7    // missing_docs
8)]
9#![forbid(unsafe_code)]
10
11#[macro_use]
12extern crate ark_std;
13
14#[allow(unused_imports)]
15#[macro_use]
16extern crate derivative;
17
18#[allow(unused_imports)]
19pub(crate) use ark_std::{borrow::ToOwned, boxed::Box, vec::Vec};
20mod macros;
21
22#[cfg(feature = "commitment")]
23pub mod commitment;
24
25#[cfg(feature = "crh")]
26pub mod crh;
27
28#[cfg(feature = "merkle_tree")]
29pub mod merkle_tree;
30
31#[cfg(feature = "encryption")]
32pub mod encryption;
33
34#[cfg(feature = "prf")]
35pub mod prf;
36
37#[cfg(feature = "signature")]
38pub mod signature;
39
40#[cfg(feature = "snark")]
41pub mod snark;
42
43#[cfg(feature = "sponge")]
44pub mod sponge;
45
46#[derive(Debug)]
47pub enum Error {
48    IncorrectInputLength(usize),
49    NotPrimeOrder,
50    GenericError(Box<dyn ark_std::error::Error + Send>),
51    SerializationError(ark_serialize::SerializationError),
52}
53
54impl core::fmt::Display for Error {
55    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56        match self {
57            Self::IncorrectInputLength(len) => write!(f, "incorrect input length: {len}"),
58            Self::NotPrimeOrder => write!(f, "element is not prime order"),
59            Self::GenericError(e) => write!(f, "{e}"),
60            Self::SerializationError(e) => write!(f, "{e}"),
61        }
62    }
63}
64
65impl ark_std::error::Error for Error {}
66
67impl From<ark_serialize::SerializationError> for Error {
68    fn from(e: ark_serialize::SerializationError) -> Self {
69        Self::SerializationError(e)
70    }
71}