Operators#

Description Operators#

Merkle Tree operators are used to configure the tree structure and execution. They are combined via addition (+) to form a Merkle Tree descriptor.

Size#

template<unsigned int N>
Size()#

Sets the Merkle tree leaf count N.

See Supported Merkle tree configurations for supported tree sizes, modes, and precision limits.

Default: Size<2048>.

Precision#

template<typename T>
Precision()#

Sets the Merkle tree leaf node element type T. The type parameter T must be one of the following (<cstdint>):

type std::uint8_t#

Fixed-width unsigned 8-bit integer element type. Typical with SHA-2, SHA-3, and SHAKE when building Merkle trees.

type std::uint32_t#

Fixed-width unsigned 32-bit integer element type. Typical with Poseidon2 when building Merkle trees.

Default: std::uint8_t.

Merkle Tree Aliases#

For convenience, we provide aliases for Merkle Trees with the supported sizes and precisions. They are in the following format: MERKLE_<PRECISION>_<SIZE> where <PRECISION> takes the values BYTE or FIELD representing uint8_t or uint32_t respectively, and <SIZE> is the size as a raw number, not the power of 2 exponent. For example, MERKLE_BYTE_2048 is an alias for decltype(Algorithm<algorithm::MERKLE>() + Size<2048>() + Precision<uint8_t>() + Function<function::Merkle>() + Block()). Recall that the precision is tied to the respective hash algorithm that will be used in tandem with the Merkle Tree, in the case of our example, this Merkle Tree will be used with SHA2, SHA3, or SHAKE.

Execution Operators#

Block execution#

Block()#

Specifies that the operator will execute on each CUDA block. Merkle Tree generation utilizes a thread-based hash function to generate the tree using a full block.

BlockDim#

template<unsigned int X, unsigned int Y = 1, unsigned int Z = 1>
BlockDim(
)#

Sets the number of threads per block. The default value is BlockDim<128, 1, 1>. This is used to specify the number of threads per block for the Merkle Tree generation functions. Currently, the maximum supported value is BlockDim<256, 1, 1>.