8 releases

1.0.0-beta.2 Dec 22, 2022
0.7.1 Aug 23, 2024
0.6.0 Aug 14, 2024
0.5.4 May 31, 2024
0.5.1 Jan 17, 2023

#2 in #ssz

Download history 8015/week @ 2024-05-24 9789/week @ 2024-05-31 8809/week @ 2024-06-07 10333/week @ 2024-06-14 12397/week @ 2024-06-21 9998/week @ 2024-06-28 9201/week @ 2024-07-05 10606/week @ 2024-07-12 13870/week @ 2024-07-19 8752/week @ 2024-07-26 11172/week @ 2024-08-02 11462/week @ 2024-08-09 10315/week @ 2024-08-16 11393/week @ 2024-08-23 9876/week @ 2024-08-30 9138/week @ 2024-09-06

42,555 downloads per month
Used in 26 crates (11 directly)

Apache-2.0

74KB
2K 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

~5.5MB
~109K SLoC