Ethereum SSZ (Simple Serialize) specification and Merkleization
Project description
SSZ Specs
Simple Serialize (SSZ) is a serialization and hashing scheme used by Ethereum. This project is a reference implementation written in Python which serves as the official specifications.
Development
This project uses uv and
just.
just check # Run code quality checks
just fix # Run code quality fixers
just test # Run unit tests
just fill # Generate reference tests
Tests
This project generates JSON reference tests, included in each release, that SSZ implementations can run to ensure compliance with the specifications.
Releases
Each release ships the eth-ssz-specs package on PyPI and the reference tests on the
releases page, both built from
the tagged commit.
pip install eth-ssz-specs
TAG=v0.1.0
curl -sSLO "https://github.com/leanEthereum/ssz-specs/releases/download/$TAG/ssz-test-vectors-$TAG.tar.gz"
curl -sSLO "https://github.com/leanEthereum/ssz-specs/releases/download/$TAG/ssz-test-vectors-$TAG.tar.gz.sha256"
sha256sum --check "ssz-test-vectors-$TAG.tar.gz.sha256"
tar -xzf "ssz-test-vectors-$TAG.tar.gz" # extracts fixtures/
Types
Boolean
A true or false value.
Boolean(True)
Bit
A zero or one value.
Bit(1)
Byte
Eight bits of opaque data.
Byte(0xFF)
Uint8
An 8-bit unsigned integer.
Uint8(0xFF)
Uint16
A 16-bit unsigned integer.
Uint16(0xFFFF)
Uint32
A 32-bit unsigned integer.
Uint32(0xFFFFFFFF)
Uint64
A 64-bit unsigned integer.
Uint64(0xFFFFFFFFFFFFFFFF)
Uint128
A 128-bit unsigned integer.
Uint128(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
Uint256
A 256-bit unsigned integer.
Uint256(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
Vector
A fixed number of elements.
class Color(Vector[Uint8]):
LENGTH = 3
Color(data=[255, 128, 0])
List
A variable number of elements up to a limit.
class Scores(List[Uint64]):
LIMIT = 8
Scores(data=[10, 20, 30])
ByteVector
A fixed number of bytes.
class Serial(ByteVector):
LENGTH = 4
Serial(b"\x01\x02\x03\x04")
ByteList
A variable number of bytes up to a limit.
class Message(ByteList):
LIMIT = 32
Message(data=b"hello")
BitVector
A fixed number of bits.
class Weekdays(BitVector):
LENGTH = 7
Weekdays(data=[1, 0, 0, 1, 0, 1, 0])
BitList
A variable number of bits up to a limit.
class Answers(BitList):
LIMIT = 20
Answers(data=[1, 0, 1])
ProgressiveList
A variable number of elements with no limit.
class Temperatures(ProgressiveList[Uint16]):
pass
Temperatures(data=[20, 21, 19])
ProgressiveBitList
A variable number of bits with no limit.
ProgressiveBitList(data=[1, 0, 1])
Container
A fixed set of named fields.
class Point(Container):
x: Uint64
y: Uint64
Point(x=1, y=2)
ProgressiveContainer
Named fields that keep their positions as the set changes.
class Square(ProgressiveContainer):
ACTIVE_FIELDS = active_fields(width=3, gaps=(1,))
side: Uint16 # position 0
color: Uint8 # position 2
Square(side=0x1234, color=0x42)
CompatibleUnion
A choice between options that share one tree shape.
class Shape(CompatibleUnion):
OPTIONS = {1: Square, 2: Circle}
Shape(selector=1, data=Square(side=0x1234, color=0x42))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eth_ssz_specs-0.0.1.dev1.tar.gz.
File metadata
- Download URL: eth_ssz_specs-0.0.1.dev1.tar.gz
- Upload date:
- Size: 82.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28b94d7d180545f8e716d63ba72c2b90199244dbc97833d3fdff1f2d2bf7fff7
|
|
| MD5 |
8cfa95efaa5137174b94af39b52046b7
|
|
| BLAKE2b-256 |
c4a1c98da5fdfe00b587f0dd438c88060ebfcf28b47f43bf561fed1debb1b6f9
|
Provenance
The following attestation bundles were made for eth_ssz_specs-0.0.1.dev1.tar.gz:
Publisher:
release.yaml on leanEthereum/ssz-specs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eth_ssz_specs-0.0.1.dev1.tar.gz -
Subject digest:
28b94d7d180545f8e716d63ba72c2b90199244dbc97833d3fdff1f2d2bf7fff7 - Sigstore transparency entry: 2277940836
- Sigstore integration time:
-
Permalink:
leanEthereum/ssz-specs@545f94cf3f37b2060665f5c1751060acbe52c0db -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leanEthereum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@545f94cf3f37b2060665f5c1751060acbe52c0db -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file eth_ssz_specs-0.0.1.dev1-py3-none-any.whl.
File metadata
- Download URL: eth_ssz_specs-0.0.1.dev1-py3-none-any.whl
- Upload date:
- Size: 62.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a81b912730b0e2615ab27c4fd1e0b235cde8425a1d3c4dc24388e362540409b0
|
|
| MD5 |
541ab99a51634f24c516b8a888eef659
|
|
| BLAKE2b-256 |
2f4f44ad81f995d4fd67a3dd1935870b7d2a56e28ac63ae0d27aeb75b7c49141
|
Provenance
The following attestation bundles were made for eth_ssz_specs-0.0.1.dev1-py3-none-any.whl:
Publisher:
release.yaml on leanEthereum/ssz-specs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eth_ssz_specs-0.0.1.dev1-py3-none-any.whl -
Subject digest:
a81b912730b0e2615ab27c4fd1e0b235cde8425a1d3c4dc24388e362540409b0 - Sigstore transparency entry: 2277940892
- Sigstore integration time:
-
Permalink:
leanEthereum/ssz-specs@545f94cf3f37b2060665f5c1751060acbe52c0db -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leanEthereum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@545f94cf3f37b2060665f5c1751060acbe52c0db -
Trigger Event:
workflow_dispatch
-
Statement type: