mmr_crypto_primitives/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(
3 unused,
4 future_incompatible,
5 nonstandard_style,
6 rust_2018_idioms,
7 )]
9#![forbid(unsafe_code)]
10
11#[macro_use]
12extern crate ark_std;
13
14#[macro_use]
15extern crate derivative;
16
17pub(crate) use ark_std::{borrow::ToOwned, boxed::Box, vec::Vec};
18mod macros;
19
20pub mod commitment;
21pub mod crh;
22pub mod merkle_tree;
23
24pub mod encryption;
25pub mod prf;
26pub mod signature;
27pub mod snark;
28pub mod mmr;
29
30pub use self::{
31 commitment::CommitmentScheme,
32 crh::CRHScheme,
33 merkle_tree::{MerkleTree, Path},
34 mmr::{MerkleMountainRange, Path as MMRPath},
35 prf::PRF,
36 signature::SignatureScheme,
37 snark::{CircuitSpecificSetupSNARK, UniversalSetupSNARK, SNARK},
38};
39
40#[cfg(feature = "r1cs")]
41pub use self::{
42 commitment::CommitmentGadget, crh::CRHSchemeGadget, merkle_tree::constraints::PathVar,
43 prf::PRFGadget, signature::SigRandomizePkGadget, snark::SNARKGadget,
44};
45
46pub type Error = Box<dyn ark_std::error::Error>;
47
48#[derive(Debug)]
49pub enum CryptoError {
50 IncorrectInputLength(usize),
51 NotPrimeOrder,
52}
53
54impl core::fmt::Display for CryptoError {
55 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56 let msg = match self {
57 CryptoError::IncorrectInputLength(len) => format!("input length is wrong: {}", len),
58 CryptoError::NotPrimeOrder => "element is not prime order".to_owned(),
59 };
60 write!(f, "{}", msg)
61 }
62}
63
64impl ark_std::error::Error for CryptoError {}