An implementation of the SSZ
serialization scheme defined in the consensus-specs repo.
This repo aims to remain lightweight and relatively free-standing, rather than coupled to other ethereum consensus code/dependencies.
This implementation has not been audited for security and is primarily intended for R&D use cases.
If you need a battle-tested implementation (e.g. for consensus-critical work), refer to the Lighthouse implementation.
To conform to the SSZ spec, a given Rust type should implement the SimpleSerialize
trait. Types implementing this trait then obtain:
ssz_rs
aims to add as little ceremony over the built-in Rust types as possible. The ssz_rs_derive
crate provides macros to derive the encoding and decoding routines for SSZ containers and unions (represented as Rust struct
s and enum
s, respectively).
See the ssz_rs/examples
for example usage.
This library provides the hash tree root computation for types implementing SimpleSerialize
.
- NOTE: under construction
This library provides tools for generating and verifying multiproofs of SSZ data.
This library is no-std
compatible. To build without the standard library, disable the crate's default features.
For example, in Cargo.toml
:
ssz-rs = { version = "...", default-features = false }
This repo includes a copy of the ssz_generic
consensus spec tests as integration tests for the ssz_rs
crate.
The tests are generated from a local clone of the spec tests repo and the generator script under ssz_rs/scripts
.
Refer to the README there if you need to update/change these tests.