10 unstable releases (3 breaking)

1.0.0-beta.2 Dec 22, 2022
0.8.1 Dec 5, 2024
0.8.0 Sep 20, 2024
0.5.4 May 31, 2024
0.5.2 Mar 13, 2023

#1 in #ssz

Download history 11246/week @ 2024-09-02 9200/week @ 2024-09-09 8613/week @ 2024-09-16 8426/week @ 2024-09-23 6975/week @ 2024-09-30 6832/week @ 2024-10-07 10760/week @ 2024-10-14 14483/week @ 2024-10-21 12992/week @ 2024-10-28 11102/week @ 2024-11-04 9885/week @ 2024-11-11 12427/week @ 2024-11-18 13142/week @ 2024-11-25 14669/week @ 2024-12-02 14643/week @ 2024-12-09 12446/week @ 2024-12-16

55,753 downloads per month
Used in 30 crates (13 directly)

Apache-2.0

125KB
3K SLoC

ethereum_ssz

SimpleSerialize (SSZ) implementation optimised for speed and security.

Maintained by Sigma Prime for use in Lighthouse, with an eye to being useful in the Rust Ethereum ecosystem more broadly. We welcome new contributors!

Please see the docs for more information.


lib.rs:

Provides encoding (serialization) and decoding (deserialization) in the SimpleSerialize (SSZ) format designed for use in Ethereum 2.0.

Adheres to the Ethereum 2.0 SSZ specification at v0.12.1.

Example

use ssz_derive::{Encode, Decode};
use ssz::{Decode, Encode};

#[derive(PartialEq, Debug, Encode, Decode)]
struct Foo {
    a: u64,
    b: Vec<u16>,
}

fn ssz_encode_decode_example() {
    let foo = Foo {
        a: 42,
        b: vec![1, 3, 3, 7]
    };

    let ssz_bytes: Vec<u8> = foo.as_ssz_bytes();

    let decoded_foo = Foo::from_ssz_bytes(&ssz_bytes).unwrap();

    assert_eq!(foo, decoded_foo);
}

See examples/ for manual implementations of the Encode and Decode traits.

Dependencies

~8MB
~145K SLoC