https://github.com/blockblaz/ssz.zig
A ziglang implementation of the SSZ serialization protocol
https://github.com/blockblaz/ssz.zig
Last synced: 9 months ago
JSON representation
A ziglang implementation of the SSZ serialization protocol
- Host: GitHub
- URL: https://github.com/blockblaz/ssz.zig
- Owner: blockblaz
- License: unlicense
- Created: 2020-12-15T09:32:18.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-21T18:12:46.000Z (9 months ago)
- Last Synced: 2025-04-28T15:51:53.286Z (9 months ago)
- Language: Zig
- Size: 217 KB
- Stars: 25
- Watchers: 3
- Forks: 8
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-zig - blockblaz/ssz.zig - A Zig implementation of the [SSZ serialization protocol](https://github.com/ethereum/eth2.0-specs/blob/dev/ssz/simple-serialize.md). (Web3 Framework / Large Language Model)
README
[](https://github.com/gballet/ssz.zig/actions/workflows/ci.yml)
# ssz.zig
A [Zig](https://ziglang.org) implementation of the [SSZ serialization protocol](https://github.com/ethereum/eth2.0-specs/blob/dev/ssz/simple-serialize.md).
Tested with zig 0.14.0.
## Serialization
Use `serialize` to write a serialized object to a byte buffer.
Currently supported types:
* `BitVector[N]`
* `uintN`
* `boolean`
* structures
* optionals
* `null`
* `Vector[N]`
* **tagged** unions
* `List[N]`
* `Bitlist[N]`
Ziglang has the limitation that it's not possible to determine which union field is active without tags.
## Deserialization
Use `deserialize` to turn a byte array containing a serialized payload, into an object.
`deserialize` does not allocate any new memory. Scalar values will be copied, and vector values use references to the serialized data. Make a copy of the data if you need to free the serialized payload. Future versions will include a version of `deserialize` that expects an allocator.
Supported types:
* `uintN`
* `boolean`
* structures
* strings
* `BitVector[N]`
* `Vector[N]`
* unions
* optionals
* `List[N]`
* `Bitlist[N]`
## Merkelization (experimental)
Use `tree_root_hash` to calculate the root hash of an object.
Supported types:
* `Bitvector[N]`
* `boolean`
* `uintN`
* `Vector[N]`
* structures
* strings
* optionals
* unions
* `List[N]`
* `Bitlist[N]`
## Contributing
Simply create an issue or a PR.