ssz / org.apache.tuweni.ssz / SSZ

SSZ

class SSZ (source)

Simple Serialize (SSZ) encoding and decoding.

Functions

decode

static fun <T : Any> decode(source: Bytes, fn: Function<SSZReader, T>): T

Read and decode SSZ from a Bytes value.

decodeAddress

static fun decodeAddress(source: Bytes): Bytes

Read a 20-byte address from the SSZ source.

decodeAddressList

static fun decodeAddressList(source: Bytes): MutableList<Bytes>

Read a list of 20-byte addresses from the SSZ source.

decodeBigInteger

static fun decodeBigInteger(source: Bytes, bitLength: Int): BigInteger

Read a SSZ encoded two's-compliment big integer from a Bytes value.

decodeBigIntegerList

static fun decodeBigIntegerList(source: Bytes, bitLength: Int): MutableList<BigInteger>

Read a list of two's-compliment big integer values from the SSZ source.

decodeBoolean

static fun decodeBoolean(source: Bytes): Boolean

Read a boolean value from the SSZ source.

decodeBooleanList

static fun decodeBooleanList(source: Bytes): MutableList<Boolean>

Read a list of booleans from the SSZ source.

decodeByteArrayList

static fun decodeByteArrayList(source: Bytes): MutableList<ByteArray>

Read a list of byte arrays from the SSZ source. Note: prefer to use #decodeByteArrayList(Bytes, int) instead, especially when reading untrusted data.

static fun decodeByteArrayList(source: Bytes, limit: Int): MutableList<ByteArray>

Read a list of byte arrays from the SSZ source.

decodeBytes

static fun decodeBytes(source: Bytes): Bytes

Read a SSZ encoded bytes from a Bytes value. Note: prefer to use #decodeBytes(Bytes, int) instead, especially when reading untrusted data.

static fun decodeBytes(source: Bytes, limit: Int): Bytes

Read a SSZ encoded bytes from a Bytes value.

decodeBytesList

static fun decodeBytesList(source: Bytes): MutableList<Bytes>

Read a list of Bytes from the SSZ source. Note: prefer to use #decodeBytesList(Bytes, int) instead, especially when reading untrusted data.

static fun decodeBytesList(source: Bytes, limit: Int): MutableList<Bytes>

Read a list of Bytes from the SSZ source.

decodeHash

static fun decodeHash(source: Bytes, hashLength: Int): Bytes

Read a 32-byte hash from the SSZ source.

decodeHashList

static fun decodeHashList(source: Bytes, hashLength: Int): MutableList<Bytes>

Read a list of 32-byte hashes from the SSZ source.

decodeInt

static fun decodeInt(source: Bytes, bitLength: Int): Int

Read a SSZ encoded two's-compliment integer from a Bytes value.

decodeInt16

static fun decodeInt16(source: Bytes): Int

Read a 16-bit two's-compliment integer from the SSZ source.

decodeInt16List

static fun decodeInt16List(source: Bytes): MutableList<Int>

Read a list of 16-bit two's-compliment int values from the SSZ source.

decodeInt32

static fun decodeInt32(source: Bytes): Int

Read a 32-bit two's-compliment integer from the SSZ source.

decodeInt32List

static fun decodeInt32List(source: Bytes): MutableList<Int>

Read a list of 32-bit two's-compliment int values from the SSZ source.

decodeInt64

static fun decodeInt64(source: Bytes): Long

Read a 64-bit two's-compliment integer from the SSZ source.

decodeInt64List

static fun decodeInt64List(source: Bytes): MutableList<Long>

Read a list of 64-bit two's-compliment int values from the SSZ source.

decodeInt8

static fun decodeInt8(source: Bytes): Int

Read an 8-bit two's-compliment integer from the SSZ source.

decodeInt8List

static fun decodeInt8List(source: Bytes): MutableList<Int>

Read a list of 8-bit two's-compliment int values from the SSZ source.

decodeIntList

static fun decodeIntList(source: Bytes, bitLength: Int): MutableList<Int>

Read a list of two's-compliment int values from the SSZ source.

decodeLong

static fun decodeLong(source: Bytes, bitLength: Int): Long

Read a SSZ encoded two's-compliment long integer from a Bytes value.

decodeLongIntList

static fun decodeLongIntList(source: Bytes, bitLength: Int): MutableList<Long>

Read a list of two's-compliment long int values from the SSZ source.

decodeString

static fun decodeString(source: Bytes): String

Read a SSZ encoded string from a Bytes value. Note: prefer to use #decodeString(Bytes, int) instead, especially when reading untrusted data.

static fun decodeString(source: Bytes, limit: Int): String

Read a SSZ encoded string from a Bytes value.

decodeStringList

static fun decodeStringList(source: Bytes): MutableList<String>

Read a list of strings from the SSZ source. Note: prefer to use #decodeStringList(Bytes, int) instead, especially when reading untrusted data.

static fun decodeStringList(source: Bytes, limit: Int): MutableList<String>

Read a list of strings from the SSZ source.

decodeUInt

static fun decodeUInt(source: Bytes, bitLength: Int): Int

Read a SSZ encoded unsigned integer from a Bytes value.

decodeUInt16

static fun decodeUInt16(source: Bytes): Int

Read a 16-bit unsigned integer from the SSZ source.

decodeUInt16List

static fun decodeUInt16List(source: Bytes): MutableList<Int>

Read a list of 16-bit unsigned int values from the SSZ source.

decodeUInt256

static fun decodeUInt256(source: Bytes): UInt256

Read a 256-bit unsigned integer from the SSZ source.

decodeUInt256List

static fun decodeUInt256List(source: Bytes): MutableList<UInt256>

Read a list of 256-bit unsigned int values from the SSZ source.

decodeUInt32

static fun decodeUInt32(source: Bytes): Long

Read a 32-bit unsigned integer from the SSZ source.

decodeUInt32List

static fun decodeUInt32List(source: Bytes): MutableList<Long>

Read a list of 32-bit unsigned int values from the SSZ source.

decodeUInt384

static fun decodeUInt384(source: Bytes): UInt384

Read a 384-bit unsigned integer from the SSZ source.

decodeUInt384List

static fun decodeUInt384List(source: Bytes): MutableList<UInt384>

Read a list of 384-bit unsigned int values from the SSZ source.

decodeUInt64

static fun decodeUInt64(source: Bytes): Long

Read a 64-bit unsigned integer from the SSZ source.

decodeUInt64List

static fun decodeUInt64List(source: Bytes): MutableList<Long>

Read a list of 64-bit unsigned int values from the SSZ source.

decodeUInt8

static fun decodeUInt8(source: Bytes): Int

Read an 8-bit unsigned integer from the SSZ source.

decodeUInt8List

static fun decodeUInt8List(source: Bytes): MutableList<Int>

Read a list of 8-bit unsigned int values from the SSZ source.

decodeUIntList

static fun decodeUIntList(source: Bytes, bitLength: Int): MutableList<Int>

Read a list of unsigned int values from the SSZ source.

decodeULong

static fun decodeULong(source: Bytes, bitLength: Int): Long

Read a SSZ encoded unsigned long integer from a Bytes value.

decodeULongIntList

static fun decodeULongIntList(source: Bytes, bitLength: Int): MutableList<Long>

Read a list of unsigned long int values from the SSZ source.

decodeUnsignedBigInteger

static fun decodeUnsignedBigInteger(source: Bytes, bitLength: Int): BigInteger

Read a SSZ encoded unsigned big integer from a Bytes value.

decodeUnsignedBigIntegerList

static fun decodeUnsignedBigIntegerList(source: Bytes, bitLength: Int): MutableList<BigInteger>

Read a list of unsigned big integer values from the SSZ source.

encode

static fun encode(fn: Consumer<SSZWriter>): Bytes

Encode values to a Bytes value.

encodeAddress

static fun encodeAddress(address: Bytes): Bytes

Encode a 20-byte address to a Bytes value.

encodeAddressList

static fun encodeAddressList(vararg elements: Bytes): Bytes
static fun encodeAddressList(elements: MutableList<out Bytes>): Bytes

Encode a list of addresses.

encodeBigInteger

static fun encodeBigInteger(value: BigInteger, bitLength: Int): Bytes

Encode a big integer to a Bytes value.

encodeBigIntegerList

static fun encodeBigIntegerList(bitLength: Int, vararg elements: BigInteger): Bytes
static fun encodeBigIntegerList(bitLength: Int, elements: MutableList<BigInteger>): Bytes

Encode a list of big integers.

encodeBigIntegerToByteArray

static fun encodeBigIntegerToByteArray(value: BigInteger, bitLength: Int): ByteArray

encodeBoolean

static fun encodeBoolean(value: Boolean): Bytes

Encode a boolean to a Bytes value.

encodeBooleanList

static fun encodeBooleanList(vararg elements: Boolean): Bytes
static fun encodeBooleanList(elements: MutableList<Boolean>): Bytes

Encode a list of booleans.

encodeByteArray

static fun encodeByteArray(value: ByteArray): Bytes

Encode a value to a Bytes value.

encodeBytes

static fun encodeBytes(value: Bytes): Bytes

Encode Bytes.

encodeBytesList

static fun encodeBytesList(vararg elements: Bytes): Bytes
static fun encodeBytesList(elements: MutableList<out Bytes>): Bytes

Encode a list of bytes.

encodeHash

static fun encodeHash(hash: Bytes): Bytes

Encode a hash to a Bytes value.

encodeHashList

static fun encodeHashList(vararg elements: Bytes): Bytes
static fun encodeHashList(elements: MutableList<out Bytes>): Bytes

Encode a list of hashes.

encodeInt

static fun encodeInt(value: Int, bitLength: Int): Bytes

Encode a two's-compliment integer to a Bytes value.

encodeInt16

static fun encodeInt16(value: Int): Bytes

Encode a 16-bit two's-compliment integer to a Bytes value.

encodeInt16List

static fun encodeInt16List(vararg elements: Int): Bytes
static fun encodeInt16List(elements: MutableList<Int>): Bytes

Encode a list of 16-bit two's compliment integers.

encodeInt32

static fun encodeInt32(value: Int): Bytes

Encode a 32-bit two's-compliment integer to a Bytes value.

encodeInt32List

static fun encodeInt32List(vararg elements: Int): Bytes
static fun encodeInt32List(elements: MutableList<Int>): Bytes

Encode a list of 32-bit two's compliment integers.

encodeInt64

static fun encodeInt64(value: Long): Bytes

Encode a 64-bit two's-compliment integer to a Bytes value.

encodeInt64List

static fun encodeInt64List(vararg elements: Long): Bytes
static fun encodeInt64List(elements: MutableList<Long>): Bytes

Encode a list of 64-bit two's compliment integers.

encodeInt8

static fun encodeInt8(value: Int): Bytes

Encode an 8-bit two's-compliment integer to a Bytes value.

encodeInt8List

static fun encodeInt8List(vararg elements: Int): Bytes
static fun encodeInt8List(elements: MutableList<Int>): Bytes

Encode a list of 8-bit two's compliment integers.

encodeIntList

static fun encodeIntList(bitLength: Int, vararg elements: Int): Bytes
static fun encodeIntList(bitLength: Int, elements: MutableList<Int>): Bytes

Encode a list of two's compliment integers.

encodeLong

static fun encodeLong(value: Long, bitLength: Int): Bytes

Encode a two's-compliment long integer to a Bytes value.

encodeLongIntList

static fun encodeLongIntList(bitLength: Int, vararg elements: Long): Bytes
static fun encodeLongIntList(bitLength: Int, elements: MutableList<Long>): Bytes

Encode a list of two's compliment long integers.

encodeString

static fun encodeString(str: String): Bytes

Encode a string to a Bytes value.

encodeStringList

static fun encodeStringList(vararg elements: String): Bytes

Encode a list of strings.

static fun encodeStringList(elements: MutableList<String>): Bytes

Encode a list of strings

encodeTo

static fun <T : ByteBuffer> encodeTo(buffer: T, fn: Consumer<SSZWriter>): T

Encode values to a ByteBuffer.

encodeUBigInteger

static fun encodeUBigInteger(value: BigInteger, bitLength: Int): Bytes

Encode an unsigned big integer to a Bytes value.

encodeUBigIntegerToByteArray

static fun encodeUBigIntegerToByteArray(value: BigInteger, bitLength: Int): ByteArray

encodeUInt

static fun encodeUInt(value: Int, bitLength: Int): Bytes

Encode an unsigned integer to a Bytes value. Note that value is a native signed int, but will be interpreted as an unsigned value.

encodeUInt16

static fun encodeUInt16(value: Int): Bytes

Encode a 16-bit unsigned integer to a Bytes value.

encodeUInt16List

static fun encodeUInt16List(vararg elements: Int): Bytes
static fun encodeUInt16List(elements: MutableList<Int>): Bytes

Encode a list of 16-bit unsigned integers.

encodeUInt256

static fun encodeUInt256(value: UInt256): Bytes

Encode a 256-bit unsigned integer to a little-endian Bytes value.

encodeUInt256List

static fun encodeUInt256List(vararg elements: UInt256): Bytes
static fun encodeUInt256List(elements: MutableList<UInt256>): Bytes

Encode a list of UInt256.

encodeUInt32

static fun encodeUInt32(value: Long): Bytes

Encode a 32-bit unsigned integer to a Bytes value.

encodeUInt32List

static fun encodeUInt32List(vararg elements: Long): Bytes
static fun encodeUInt32List(elements: MutableList<Long>): Bytes

Encode a list of 32-bit unsigned integers.

encodeUInt384

static fun encodeUInt384(value: UInt384): Bytes

Encode a 384-bit unsigned integer to a little-endian Bytes value.

encodeUInt384List

static fun encodeUInt384List(vararg elements: UInt384): Bytes
static fun encodeUInt384List(elements: MutableList<UInt384>): Bytes

Encode a list of UInt384.

encodeUInt64

static fun encodeUInt64(value: Long): Bytes

Encode a 64-bit unsigned integer to a Bytes value. Note that value is a native signed long, but will be interpreted as an unsigned value.

encodeUInt64List

static fun encodeUInt64List(vararg elements: Long): Bytes
static fun encodeUInt64List(elements: MutableList<Long>): Bytes

Encode a list of 64-bit unsigned integers. Note that the elements are native signed longs, but will be interpreted as an unsigned values.

encodeUInt8

static fun encodeUInt8(value: Int): Bytes

Encode an 8-bit unsigned integer to a Bytes value.

encodeUInt8List

static fun encodeUInt8List(vararg elements: Int): Bytes
static fun encodeUInt8List(elements: MutableList<Int>): Bytes

Encode a list of 8-bit unsigned integers.

encodeUIntList

static fun encodeUIntList(bitLength: Int, vararg elements: Int): Bytes
static fun encodeUIntList(bitLength: Int, elements: MutableList<Int>): Bytes

Encode a list of unsigned integers. Note that the elements are native signed ints, but will be interpreted as an unsigned values.

encodeULong

static fun encodeULong(value: Long, bitLength: Int): Bytes

Encode an unsigned long integer to a Bytes value. Note that value is a native signed long, but will be interpreted as an unsigned value.

encodeULongIntList

static fun encodeULongIntList(bitLength: Int, vararg elements: Long): Bytes
static fun encodeULongIntList(bitLength: Int, elements: MutableList<Long>): Bytes

Encode a list of unsigned long integers. Note that the elements are native signed longs, but will be interpreted as an unsigned values.

hashTreeRoot

static fun hashTreeRoot(vararg bytes: Bytes): Bytes32

Create the hash tree root of a set of values