You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
  1. #[macro_use]
  2. extern crate bench_utils;
  3. #[macro_use]
  4. extern crate derivative;
  5. pub mod commitment;
  6. pub mod crh;
  7. pub mod merkle_tree;
  8. pub mod nizk;
  9. pub mod prf;
  10. pub mod signature;
  11. pub use self::{
  12. commitment::CommitmentScheme,
  13. crh::FixedLengthCRH,
  14. merkle_tree::{MerkleHashTree, MerkleTreePath},
  15. nizk::NIZK,
  16. prf::PRF,
  17. signature::SignatureScheme,
  18. };
  19. #[cfg(feature = "r1cs")]
  20. pub use self::{
  21. commitment::CommitmentGadget, crh::FixedLengthCRHGadget,
  22. merkle_tree::constraints::MerkleTreePathGadget, nizk::NIZKVerifierGadget, prf::PRFGadget,
  23. signature::SigRandomizePkGadget,
  24. };
  25. pub type Error = Box<dyn std::error::Error>;
  26. #[derive(Debug)]
  27. pub enum CryptoError {
  28. IncorrectInputLength(usize),
  29. NotPrimeOrder,
  30. }
  31. impl 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. impl std::error::Error for CryptoError {
  41. #[inline]
  42. fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
  43. None
  44. }
  45. }