tuweni / org.apache.tuweni.ssz / SSZ

SSZ

class SSZ (source)

Simple Serialize (SSZ) encoding and decoding.

Functions

decode

Read and decode SSZ from a Bytes value.

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

decodeAddress

Read a 20-byte address from the SSZ source.

static fun decodeAddress(source: Bytes!): Bytes!

decodeAddressList

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

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

decodeBigInteger

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

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

decodeBigIntegerList

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

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

decodeBoolean

Read a boolean value from the SSZ source.

static fun decodeBoolean(source: Bytes!): Boolean

decodeBooleanList

Read a list of booleans from the SSZ source.

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

decodeByteArrayList

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!): MutableList<ByteArray!>!

Read a list of byte arrays from the SSZ source.

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

decodeBytes

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!): Bytes!

Read a SSZ encoded bytes from a Bytes value.

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

decodeBytesList

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!): MutableList<Bytes!>!

Read a list of Bytes from the SSZ source.

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

decodeHash

Read a 32-byte hash from the SSZ source.

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

decodeHashList

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

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

decodeInt

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

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

decodeInt16

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

static fun decodeInt16(source: Bytes!): Int

decodeInt16List

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

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

decodeInt32

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

static fun decodeInt32(source: Bytes!): Int

decodeInt32List

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

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

decodeInt64

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

static fun decodeInt64(source: Bytes!): Long

decodeInt64List

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

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

decodeInt8

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

static fun decodeInt8(source: Bytes!): Int

decodeInt8List

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

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

decodeIntList

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

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

decodeLong

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

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

decodeLongIntList

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

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

decodeString

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!): String!

Read a SSZ encoded string from a Bytes value.

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

decodeStringList

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!): MutableList<String!>!

Read a list of strings from the SSZ source.

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

decodeUInt

Read a SSZ encoded unsigned integer from a Bytes value.

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

decodeUInt16

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

static fun decodeUInt16(source: Bytes!): Int

decodeUInt16List

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

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

decodeUInt256

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

static fun decodeUInt256(source: Bytes!): UInt256!

decodeUInt256List

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

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

decodeUInt32

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

static fun decodeUInt32(source: Bytes!): Long

decodeUInt32List

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

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

decodeUInt384

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

static fun decodeUInt384(source: Bytes!): UInt384!

decodeUInt384List

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

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

decodeUInt64

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

static fun decodeUInt64(source: Bytes!): Long

decodeUInt64List

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

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

decodeUInt8

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

static fun decodeUInt8(source: Bytes!): Int

decodeUInt8List

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

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

decodeUIntList

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

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

decodeULong

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

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

decodeULongIntList

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

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

decodeUnsignedBigInteger

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

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

decodeUnsignedBigIntegerList

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

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

encode

Encode values to a Bytes value.

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

encodeAddress

Encode a 20-byte address to a Bytes value.

static fun encodeAddress(address: Bytes!): Bytes!

encodeAddressList

Encode a list of addresses.

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

encodeBigInteger

Encode a big integer to a Bytes value.

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

encodeBigIntegerList

Encode a list of big integers.

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

encodeBigIntegerToByteArray

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

encodeBoolean

Encode a boolean to a Bytes value.

static fun encodeBoolean(value: Boolean): Bytes!

encodeBooleanList

Encode a list of booleans.

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

encodeByteArray

Encode a value to a Bytes value.

static fun encodeByteArray(value: ByteArray!): Bytes!

encodeBytes

Encode Bytes.

static fun encodeBytes(value: Bytes!): Bytes!

encodeBytesList

Encode a list of bytes.

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

encodeHash

Encode a hash to a Bytes value.

static fun encodeHash(hash: Bytes!): Bytes!

encodeHashList

Encode a list of hashes.

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

encodeInt

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

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

encodeInt16

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

static fun encodeInt16(value: Int): Bytes!

encodeInt16List

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

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

encodeInt32

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

static fun encodeInt32(value: Int): Bytes!

encodeInt32List

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

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

encodeInt64

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

static fun encodeInt64(value: Long): Bytes!

encodeInt64List

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

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

encodeInt8

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

static fun encodeInt8(value: Int): Bytes!

encodeInt8List

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

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

encodeIntList

Encode a list of two's compliment integers.

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

encodeLong

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

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

encodeLongIntList

Encode a list of two's compliment long integers.

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

encodeString

Encode a string to a Bytes value.

static fun encodeString(str: String!): Bytes!

encodeStringList

Encode a list of strings.

static fun encodeStringList(vararg elements: String!): Bytes!

Encode a list of strings

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

encodeTo

Encode values to a ByteBuffer.

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

encodeUBigInteger

Encode an unsigned big integer to a Bytes value.

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

encodeUBigIntegerToByteArray

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

encodeUInt

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

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

encodeUInt16

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

static fun encodeUInt16(value: Int): Bytes!

encodeUInt16List

Encode a list of 16-bit unsigned integers.

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

encodeUInt256

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

static fun encodeUInt256(value: UInt256!): Bytes!

encodeUInt256List

Encode a list of UInt256.

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

encodeUInt32

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

static fun encodeUInt32(value: Long): Bytes!

encodeUInt32List

Encode a list of 32-bit unsigned integers.

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

encodeUInt384

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

static fun encodeUInt384(value: UInt384!): Bytes!

encodeUInt384List

Encode a list of UInt384.

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

encodeUInt64

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.

static fun encodeUInt64(value: Long): Bytes!

encodeUInt64List

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

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

encodeUInt8

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

static fun encodeUInt8(value: Int): Bytes!

encodeUInt8List

Encode a list of 8-bit unsigned integers.

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

encodeUIntList

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

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

encodeULong

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.

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

encodeULongIntList

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

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

hashTreeRoot

Create the hash tree root of a set of values

static fun hashTreeRoot(vararg bytes: Bytes!): Bytes32!