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;
10pub mod lioness;
11/// Re-exports of low-level cryptographic primitives.
12pub mod primitives;
13/// Enables randomized encryption (sealing)
14/// and decryption of data using [`OffchainKeypair`](keypairs::OffchainKeypair).
15pub mod seal;
16/// Separate module for signature algorithms.
17pub mod signing;
18/// Implements basic cryptography-related types based on [primitives], such as [Hash](types::Hash),
19/// [PublicKey](types::PublicKey) and [Signature](types::Signature).
20pub mod types;
21/// Contains small utility functions used in the other `hopr-crypto-...` crates
22pub mod utils;
23/// Contains implementation of Verifiable Random Function used in tickets
24pub mod vrf;
25
26/// Re-exports from the generic cryptographic traits.
27pub mod crypto_traits {
28    pub use cipher::{
29        Block, BlockSizeUser, Iv, IvSizeUser, Key, KeyInit, KeyIvInit, KeySizeUser, StreamCipher, StreamCipherSeek,
30    };
31    pub use digest::{Digest, FixedOutput, FixedOutputReset, Output, OutputSizeUser, Update};
32    pub use hopr_crypto_random::Randomizable;
33    pub use poly1305::universal_hash::UniversalHash;
34
35    /// Pseudo-random permutation (PRP)
36    pub trait PRP: BlockSizeUser {
37        /// Forward permutation
38        fn forward(&self, data: &mut Block<Self>);
39        /// Inverse permutation
40        fn inverse(&self, data: &mut Block<Self>);
41    }
42}
43
44#[doc(hidden)]
45pub mod prelude {
46    pub use libp2p_identity::PeerId;
47
48    pub use super::{
49        crypto_traits, errors::CryptoError, keypairs::*, primitives::*, seal::*, signing::*, types::*, utils::*, vrf::*,
50    };
51}