Device Functions#
In the following function descriptions, MERKLE is used as a placeholder for the cuPQC-Hash Merkle Tree descriptor object that is instantiated with a specific Merkle Tree size and precision.
create_leaf#
generate_tree#
-
template<class HASH, typename Precision>
__device__ void MERKLE::generate_tree(
)# Generate a Merkle Tree. This API function is a block-level function, and will generate a full tree in a single call. Note that we cap BlockDim to 256 threads per block.
- Parameters:
hash – The hash function used to generate the Merkle Tree.
merkle_tree – The Merkle Tree object to generate.
generate_sub_tree#
-
template<class HASH, typename Precision>
__device__ void MERKLE::generate_sub_tree(
)# Generate a sub tree of the Merkle Tree. This API function is defined by the SubMerkle Tree object, but operates on the larger tree. This can be used to generate a larger tree distributed across multiple blocks. This function will compute a blocks worth of the tree in a single call. Note that we cap BlockDim to 256 threads per block.
- Parameters:
hash – The hash function used to generate the Merkle Tree.
merkle_tree – The Merkle Tree object to generate the sub tree of.
sub_tree_num – The number of the sub tree to generate.
generate_proof#
-
template<class HASH, typename Precision>
__device__ void MERKLE::generate_proof( - proof<N, HASH, Precision> &proof,
- const Precision *leaf,
- const uint32_t leaf_index,
- const tree<N, HASH, Precision> &merkle_tree
Generate a proof for a leaf in the Merkle Tree. This is a per-thread function.
- Parameters:
proof – The proof object to generate.
leaf – The leaf to generate a proof for.
leaf_index – The index of the leaf to generate a proof for.
verify_proof#
-
template<class HASH, typename Precision>
__device__ bool MERKLE::verify_proof( - const proof<N, HASH, Precision> &proof,
- const Precision *leaf,
- const uint32_t leaf_index,
- const Precision *root,
- HASH &hash
Verify a proof for a leaf in the Merkle Tree. This is a per-thread function.
- Parameters:
proof – The proof object to verify.
leaf – The leaf to verify a proof for.
leaf_index – The index of the leaf to verify a proof for.
root – The root of the Merkle Tree.
hash – The hash function used to generate the Merkle Tree.