tendermint/crypto/
default.rs

1//! Pure Rust implementations of the cryptographic traits.
2//!
3//! Most applications using this crate should use these implementations.
4//! Alternative implementations can be useful on targets like wasm and
5//! on-chain environments, where code size is at a premium and a faster
6//! platform-native cryptographic API is available.
7
8use super::sha256::HASH_SIZE;
9use digest::Digest;
10
11/// The default implementation of the [`Sha256`][sha256trait] trait.
12///
13/// [sha256trait]: super::Sha256
14pub use sha2::Sha256;
15
16impl super::Sha256 for Sha256 {
17    fn digest(data: impl AsRef<[u8]>) -> [u8; HASH_SIZE] {
18        <Self as Digest>::digest(data).into()
19    }
20}
21
22pub mod signature;
23
24/// Types implementing the ECDSA algorithm using the Secp256k1 elliptic curve.
25#[cfg(feature = "secp256k1")]
26pub mod ecdsa_secp256k1 {
27    pub use k256::ecdsa::{Signature, SigningKey, VerifyingKey};
28}