Data for SSZ Serialization are represented by one or a combination of these Types:
Uint8, Uint16, Uint32, Uint64, Uint128, Uint256
Bit, 0 or 1, True or False
"Fixed Length" sequence of elements of same **Type** (homogeneous)
"Variable Length" sequence of elements of the same **Type** (homogenous)
Heterogeneous ordered collection of elements
A "Union Type" containing SSZ Types
A Uint256 that represents the
Bytes32 hash_tree_root of a nested merkle tree
Different types may merkleize to the same root:
root
uint256(123)
and uint8(123)
have the same root.Container
with 4 Bytes32
fields can have the same root as a Vector[uint64, 16]
.All SSZ Types have a default "zeroed" value
Uint
: 0Boolean
: FalseVector
: Sequence of default valuesList
: Empty ListContainer
: Default value for each type in containerUnion
: Default value of "Type_0"Default values are recursive; elements in composite types such as containers are initialized with their respective default initializations
is_zero
An SSZ object is called zeroed (and thus, is_zero(object)
returns true) if it is equal to the default value for that type.
Vector[type, 0]
, Bitvector[0]
) are illegal.null
type is only legal as the first type in a union subtype (i.e. with type index zero). Every type deterministically describes the shape of the **Merkle Tree** representing the type - No two different values _of the same type_ can merkleize to the same root - No two roots can be derived for the same value _of the type used for the root_.
All simple types (boolean / uintN) undergo simple byte conversion, resulting in a single leaf Merkle Tree
var a: Type<boolean>
var b: Type<uint8>
var c: Type<uint16>
var d: Type<Vector<byte, 4>>
a.defaultValue() = false
a.defaultValue() = 0
a.defaultValue() = 0
a.defaultValue() = 0000