Expand description
Optimized SHA256 for use in Ethereum.
The initial purpose of this crate was to provide an abstraction over the hash function used in the beacon chain. The hash function changed during the specification process, so defining it once in this crate made it easy to replace.
Now this crate serves primarily as a wrapper over two SHA256 crates: sha2
and ring
– which
it switches between at runtime based on the availability of SHA intrinsics.
Re-exports§
pub use self::DynamicContext as Context;
Structs§
- Ring
Impl - Implementation of SHA256 using the
ring
crate (fastest on CPUs without SHA extensions).
Enums§
- Dynamic
Context - Context encapsulating all implemenation contexts.
- Dynamic
Impl - Default dynamic implementation that switches between available implementations.
Constants§
- HASH_
LEN - Length of a SHA256 hash in bytes.
- ZERO_
HASHES_ MAX_ INDEX - The max index that can be used with
ZERO_HASHES
.
Statics§
- ZERO_
HASHES - Cached zero hashes where
ZERO_HASHES[i]
is the hash of a Merkle tree with 2^i zero leaves.
Traits§
- Sha256
- Top-level trait implemented by both
sha2
andring
implementations. - Sha256
Context - Context trait for abstracting over implementation contexts.
Functions§
- hash
- Returns the digest of
input
using the best available implementation. - hash32_
concat - Compute the hash of two slices concatenated.
- hash_
fixed - Hash function returning a fixed-size array (to save on allocations).
- have_
sha_ extensions