#ethereum #ssz #decode #contributors #encode

ethereum_ssz

SimpleSerialize (SSZ) as used in Ethereum

13 releases (4 breaking)

1.0.0-beta.2 Dec 22, 2022
0.9.0 Apr 8, 2025
0.8.3 Feb 4, 2025
0.8.1 Dec 5, 2024
0.5.2 Mar 13, 2023

#1 in #ssz

Download history 12671/week @ 2024-12-17 8976/week @ 2024-12-24 9946/week @ 2024-12-31 17733/week @ 2025-01-07 16000/week @ 2025-01-14 16212/week @ 2025-01-21 18766/week @ 2025-01-28 23173/week @ 2025-02-04 20852/week @ 2025-02-11 18671/week @ 2025-02-18 18346/week @ 2025-02-25 17395/week @ 2025-03-04 22976/week @ 2025-03-11 24561/week @ 2025-03-18 24170/week @ 2025-03-25 23708/week @ 2025-04-01

99,046 downloads per month
Used in 37 crates (14 directly)

Apache-2.0

125KB
3K SLoC

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.


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.

Dependencies

~8MB
~152K SLoC