Expand description
SimpleSerialize (SSZ) codec with hash_tree_root.
Implements the Ethereum consensus SSZ wire format plus two jar-specific
extensions (MissingOr, SparseList) that allow precomputed subtree
roots to substitute transparently for materialized leaves.
The default hash function is SHA-256 (via the optional sha2 feature);
the HashTreeRoot trait is generic over any digest::Digest with a
32-byte output, so callers can plug in alternative hashes at compile time.
§Wire format
See encoding
for the spec we implement. Notable deviations:
Option/ SSZ Union: byte 0 = None (no payload), byte 1 = Some(T) + T’s bytes.MissingOr: byte 0 = Materialized + T’s bytes, byte 1 = Missing + 32 raw bytes.SparseList: same wire format as aList<T, N>plus a length prefix.
Re-exports§
pub use bits::Bitlist;pub use bits::Bitvector;pub use list::List;pub use merkle::merkleize;pub use merkle::mix_in_length;pub use merkle::mix_in_selector;pub use merkle::pack_bytes;pub use merkle::zero_hash;pub use missing::MissingOr;pub use primitives::U256;pub use sparse::SparseList;pub use vector::FixedVector;pub use digest;
Modules§
- bits
Bitvector<N>andBitlist<N>— bit-packed homogeneous boolean storage.- collections
- SSZ blanket impls for
alloc::collections::BTreeMap. - list
List<T, N>— variable-length list with compile-time cap ofNelements.- merkle
- SSZ merkleization primitives.
- missing
MissingOr<T>— first-class summary placeholder for SSZ subtree substitution.- primitives
- SSZ blanket impls for built-in scalar and array types.
- sparse
SparseList<T, N>— a list view that may omit materializing parts of the tree, using cached subtree roots or zero-hashes for empty regions.- union
- Helpers for SSZ Union types (used by
Option<T>and derived enums). - vector
FixedVector<T, N>— homogeneous list with compile-time-fixed length.
Enums§
- Decode
Error - Errors encountered while decoding an SSZ-encoded byte slice.
Constants§
- BYTES_
PER_ CHUNK - Chunk size in bytes for SSZ merkleization.
- BYTES_
PER_ LENGTH_ OFFSET - The number of bytes used to encode a variable-length list offset.
Traits§
- Decode
- SSZ decoding trait.
- Encode
- SSZ encoding trait.
- Hash
Tree Root - Computes a 32-byte hash tree root for SSZ types.
Functions§
- hash_
tree_ root - Convenience SHA-256 entry point.
Derive Macros§
- Decode
- Derive the
ssz::Decodetrait for a struct or enum. - Encode
- Derive the
ssz::Encodetrait for a struct or enum. - Hash
Tree Root - Derive the
ssz::HashTreeRoottrait for a struct or enum.