6 releases ()

1.0.0-beta.2 Dec 22, 2022
0.5.3 Jun 14, 2023
0.5.2 Mar 13, 2023
0.5.1 Jan 17, 2023
0.5.0 Jan 16, 2023

#1964 in Magic Beans

Download history 4355/week @ 2023-12-14 3602/week @ 2023-12-21 3578/week @ 2023-12-28 4914/week @ 2024-01-04 5679/week @ 2024-01-11 6274/week @ 2024-01-18 7188/week @ 2024-01-25 7815/week @ 2024-02-01 7075/week @ 2024-02-08 8008/week @ 2024-02-15 7867/week @ 2024-02-22 8180/week @ 2024-02-29 10665/week @ 2024-03-07 10661/week @ 2024-03-14 8098/week @ 2024-03-21 6916/week @ 2024-03-28

38,175 downloads per month
Used in 14 crates (4 directly)

Apache-2.0

71KB
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

~1MB
~17K SLoC