cuPQC-Hash: Cryptographic Hash Functions#

The cuPQC-Hash library provides GPU-optimized implementations of cryptographic hash functions designed for direct integration into CUDA kernels. As a device-side library, cuPQC-Hash enables you to perform hashing operations within your kernels, eliminating data movement overhead and maximizing throughput.

Supported Hash Functions#

The cuPQC-Hash library supports a comprehensive range of cryptographic hash functions including SHA-2, SHA-3, SHAKE, and Poseidon2 variants.

Family

Algorithms

Output size

SHA-2

SHA2-224 SHA2-256 SHA2-384 SHA2-512

224 · 256 · 384 · 512 bits

SHA-2

truncated

SHA2-512/224 SHA2-512/256

224 · 256 bits

512-bit computation, digest truncated to the second number.

SHA-3

SHA3-224 SHA3-256 SHA3-384 SHA3-512

224 · 256 · 384 · 512 bits

SHAKE

SHAKE128 SHAKE256

Any length (XOF)

Requested per call, in bytes.

Poseidon2

BabyBear-16/24 KoalaBear-16/24

Any number of field elements

Each element is a uint32_t modulo a 31-bit prime.

Supported Merkle Tree Configurations#

The cuPQC-Hash library provides two distinct computation modes optimized for different use cases:

  • Single-Block Mode (High Throughput): One thread block computes one complete Merkle tree. This mode enables efficient batching where multiple trees can be calculated in parallel across different blocks, maximizing throughput for applications that need to compute many independent Merkle trees.

  • Multi-Block Mode (Low Latency): Multiple thread blocks collaborate to compute a single large Merkle tree by generating subtrees that are combined. This parallel approach reduces latency for computing individual large trees by leveraging more GPU resources simultaneously.

Both modes require power-of-two leaf counts. Single-block mode completes the Merkle reduction with Generate Tree (Generate Subtree is not used in this mode). Multi-block mode uses Generate Subtree to create subtrees, then Generate Tree over the subtree roots to finish the tree (two successive kernel calls that typically lower latency on large trees).

Notation for N and M

  • N, total tree size (power-of-two).

  • M, multi-block subtree leaf count (power-of-two).

For each mode, the table below gives the supported tree and subtree sizes together with the size parameter that each Merkle device function expects. A dash marks a column that does not apply to the mode.

Mode
(block)

Supported sizes (# of leaves)

Size parameter consumed by

Tree N

Subtree M

Generate Tree

Generate Subtree

Generate Proof

Verify Proof

Single

22221

N

N

N

Multi

216224

210212

N/M

M

N

N

Supported Merkle Tree Hash Functions#

The following hash algorithms are supported for Merkle Tree operations, with their respective I/O data types:

Family

Algorithms

Precision

SHA-2

SHA2-256 SHA2-512

uint8_t

Byte-oriented input.

SHA-3

SHA3-256 SHA3-512

SHAKE

SHAKE128 SHAKE256

Poseidon2

BabyBear-16/24 KoalaBear-16/24

uint32_t

Field elements.

Key Features#

  • High Performance: GPU-optimized implementations with batched operations for high throughput and GPU utilization.

  • Merkle Tree Support: High-performance Merkle Tree API for efficient proof generation and verification, compatible with supported hash functions.

  • Flexible Merkle Tree Modes: Choose between single-block mode for high-throughput batch processing of multiple trees, or multi-block mode for low-latency computation of individual large trees.

  • Algorithm Coverage: NIST-standardized SHA-2, SHA-3, and SHAKE for traditional cryptographic applications, alongside Poseidon2 for zero-knowledge proof systems.