Operators#

cuPQC-Hash operators are used to describe the hash operation to be performed and configure execution. They are combined via addition (+) to form a cuPQC-Hash descriptor.

Description Operators#

Algorithm#

template<algorithm Alg>
Algorithm()#

Sets the algorithm Alg to use. Valid values are:

enum algorithm#
enumerator SHA3#

SHA-3 hash functions (FIPS-202)

enumerator SHAKE#

SHAKE extendable output functions (FIPS-202)

enumerator SHA2_32#

SHA-2 32-bit word size hash functions (FIPS-180-4)

enumerator SHA2_64#

SHA-2 64-bit word size hash functions (FIPS-180-4)

enumerator POSEIDON2#

Poseidon2 hash functions

There is no default value.

SecurityCategory#

template<unsigned int Category>
SecurityCategory()#

Sets the NIST security category, which determines the parameter set of the algorithm to be used. The valid values of Category depend on the value of the Algorithm operator. Poseidon2 does not require a security category.

There is no default value.

Hash Family

Name

SecurityCategory

Algorithm

Alias

SHA-2

SHA2-224

1

algorithm::SHA2_32

SHA2_224()

SHA2-256

2

algorithm::SHA2_32

SHA2_256()

SHA2-384

4

algorithm::SHA2_64

SHA2_384()

SHA2-512

5

algorithm::SHA2_64

SHA2_512()

SHA2-512/224

1

algorithm::SHA2_64

SHA2_512_224()

SHA2-512/256

2

algorithm::SHA2_64

SHA2_512_256()

SHA-3

SHA3-224

1

algorithm::SHA3

SHA3_224()

SHA3-256

2

algorithm::SHA3

SHA3_256()

SHA3-384

4

algorithm::SHA3

SHA3_384()

SHA3-512

5

algorithm::SHA3

SHA3_512()

SHAKE

SHAKE-128

1

algorithm::SHAKE

SHAKE_128()

SHAKE-256

2

algorithm::SHAKE

SHAKE_256()

Description Operators - Poseidon2 Specific#

The Poseidon2 hash function operates over prime fields. Two fields are currently supported:

The constants pages provide the round constants and Maximum Distance Separable (MDS) matrix for each field.

Field#

template<field Field>
Field()#

Sets the prime field over which the Poseidon2 function operates.

Supported values: BabyBear, KoalaBear

Default: BabyBear

Width#

template<unsigned int Width>
Width()#

Sets the width (state size) of the Poseidon2 function.

Supported values: 16, 24

Default: 16

Capacity#

template<unsigned int Capacity>
Capacity()#

Sets the capacity of the Poseidon2 sponge construction.

Supported values: 8

Default: 8

Supported Configurations#

The following table shows all valid parameter combinations:

Name

Field

Width

Capacity

Full Rounds

Partial Rounds

Sbox

Alias

BabyBear-16

BabyBear

16

8

8

13

x7

POSEIDON2_BB_8_16()

BabyBear-24

BabyBear

24

8

8

21

x7

POSEIDON2_BB_8_24()

KoalaBear-16

KoalaBear

16

8

8

20

x3

POSEIDON2_KB_8_16()

KoalaBear-24

KoalaBear

24

8

8

23

x3

POSEIDON2_KB_8_24()

Prime moduli: BabyBear = 231 - 227 + 1, KoalaBear = 231 - 224 + 1

Execution Operators#

Thread execution#

Thread()#

Specifies that the operator will execute independently for each thread.

Warp execution#

Warp()#

Specifies that the operator will execute on each CUDA warp (group of 32 threads). The device methods should be called with the same arguments for all threads in the warp.

Only the algorithm::SHA3 and algorithm::SHAKE algorithms are supported for this execution mode.