hopr_crypto_types/lib.rs
1//! This Rust crate contains implementation of common cryptographic types.
2
3extern crate core;
4
5/// Contains error enum implementation used across other `hopr-crypto-...` crates
6pub mod errors;
7/// Implements [ChainKeypair](keypairs::ChainKeypair) and [OffchainKeypair](keypairs::OffchainKeypair),
8/// the important representations of chain key and packet key.
9pub mod keypairs;
10/// Implementation of the Lioness PRP
11#[allow(deprecated)] // Until the dependency updates to newer versions of `generic-array`
12pub mod lioness;
13/// Re-exports of low-level cryptographic primitives.
14pub mod primitives;
15/// Enables randomized encryption (sealing)
16/// and decryption of data using [`OffchainKeypair`](keypairs::OffchainKeypair).
17pub mod seal;
18/// Separate module for signature algorithms.
19pub mod signing;
20/// Implements basic cryptography-related types based on [primitives], such as [Hash](types::Hash),
21/// [PublicKey](types::PublicKey) and [Signature](types::Signature).
22pub mod types;
23/// Contains small utility functions used in the other `hopr-crypto-...` crates
24pub mod utils;
25/// Contains implementation of Verifiable Random Function used in tickets
26pub mod vrf;
27
28/// Re-exports from the generic cryptographic traits.
29pub mod crypto_traits {
30 pub use cipher::{
31 Block, BlockSizeUser, Iv, IvSizeUser, Key, KeyInit, KeyIvInit, KeySizeUser, StreamCipher, StreamCipherSeek,
32 };
33 pub use digest::{Digest, FixedOutput, FixedOutputReset, Output, OutputSizeUser, Update};
34 pub use hopr_crypto_random::Randomizable;
35 pub use poly1305::universal_hash::UniversalHash;
36
37 /// Pseudo-random permutation (PRP)
38 pub trait PRP: BlockSizeUser {
39 /// Forward permutation
40 fn forward(&self, data: &mut Block<Self>);
41 /// Inverse permutation
42 fn inverse(&self, data: &mut Block<Self>);
43 }
44}
45
46#[doc(hidden)]
47pub mod prelude {
48 pub use libp2p_identity::PeerId;
49
50 pub use super::{
51 crypto_traits, errors::CryptoError, keypairs::*, primitives::*, seal::*, signing::*, types::*, utils::*, vrf::*,
52 };
53}