ark-r1cs-std/crypto-primitives/src/lib.rs
crypto-primitives/src/lib.rsRaw
1#[macro_use]
2extern crate bench_utils;
3
4#[macro_use]
5extern crate derivative;
6
7pub mod commitment;
8pub mod crh;
9pub mod mht;
10pub mod nizk;
11pub mod prf;
12pub mod signature;
13
14pub use self::{
15 commitment::CommitmentScheme,
16 crh::FixedLengthCRH,
17 mht::{HashMembershipProof, MerkleHashTree},
18 nizk::NIZK,
19 prf::PRF,
20 signature::SignatureScheme,
21};
22
23pub type Error = Box<dyn std::error::Error>;
24
25#[derive(Debug)]
26pub enum CryptoError {
27 IncorrectInputLength(usize),
28 NotPrimeOrder,
29}
30
31impl std::fmt::Display for CryptoError {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 let msg = match self {
34 CryptoError::IncorrectInputLength(len) => format!("input length is wrong: {}", len),
35 CryptoError::NotPrimeOrder => "element is not prime order".to_owned(),
36 };
37 write!(f, "{}", msg)
38 }
39}
40
41impl std::error::Error for CryptoError {
42 #[inline]
43 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
44 None
45 }
46}