module SSZ

Defined in:

ssz.cr
ssz/constants.cr
ssz/hash.cr
ssz/hash_tree_root.cr
ssz/merkleization.cr
ssz/serialization.cr

Constant Summary

BITS_PER_BYTE = 8
BYTES_PER_CHUNK = 32
BYTES_PER_LENGTH_OFFSET = 4
EMPTY_CHUNK = Bytes.new(BYTES_PER_CHUNK, 0_u8)
NUM_ZERO_HASHES = 100
VERSION = "0.1.0"
ZERO_HASHES = make_zero_hashes

Class Method Summary

Class Method Detail

def self.bit_length(n : Int) : UInt64 #

[View source]
def self.bitwise_merkleize(chunks : Enumerable(Bytes), padding : UInt64) : Bytes #

Given ordered SSZ::BYTES_PER_CHUNK-byte chunks, if necessary utilize zero chunks so that the number of chunks is a power of two, Merkleize the chunks, and return the root. Note that merkleize on a single chunk is simply that chunk, i.e. the identity when the number of chunks is one.


[View source]
def self.hash(data : Bytes) : Bytes #

[View source]
def self.merge_chunks(layers : Array(Bytes), current_root : Bytes, i, count, depth : UInt64) #

[View source]
def self.mix_in_length(root : Bytes, length : Bytes) : Bytes #

Returns Merkle root of given root and a length (UInt256 little-endian serialization)


[View source]
def self.mix_in_type(root : Bytes, type_index : Bytes) : Bytes #

Returns Merkle root of given root and a type_index (UInt256 little-endian serialization)


[View source]
def self.mix_in_type(root : Bytes, type_index : SSZ::Offset) #

Returns Merkle root of given root and a type_index (UInt256 little-endian serialization)


[View source]
def self.pack(serialized_items : Enumerable(Bytes)) : Array(Bytes) #

Packs SSZ-encoded objects into SSZ::BYTES_PER_CHUNK-byte chunks, right-pad the last chunk with zero bytes, and return the chunks.


[View source]