Device Functions#

Device functions can be accessed from instances of a descriptor PK.

execute#

PK::execute(...)#

A descriptor objects defines an execute method, the signature of which depends on the Function operator. Common arguments:

Parameters:
  • entropy – Source of cryptographic entropy of length PK::entropy_size, and 8-byte aligned. Should be created by get_entropy.

  • workspace – Global memory workspace of length PK::workspace_size, and 8-byte aligned.. Can be allocated by make_workspace.

  • smem_workspace

    Shared memory workspace of length PK::shared_memory_size, and 8-byte aligned. Typically allocated by :

    __shared__ uint8_t smem_workspace[PK::shared_memory_size];
    

Keygen#

__device__ void PK::execute(
uint8_t *public_key,
uint8_t *secret_key,
uint8_t *entropy,
uint8_t *workspace,
uint8_t *smem_workspace
);#

Generate public and secret key pair.

Parameters:
  • public_key – Buffer to which the public key will be written. Must be of length PK::public_key_size, and 8-byte aligned.

  • secret_key – Buffer to which the secret key will be written. Must be of length PK::secret_key_size, and 8-byte aligned.

Encaps#

__device__ void PK::execute(
uint8_t *ciphertext,
uint8_t *shared_secret,
const uint8_t *public_key,
uint8_t *entropy,
uint8_t *workspace,
uint8_t *smem_workspace
);#

Perform encapsulation: generate a shared secret and encrypt it as a ciphertext using the public key.

Parameters:
  • ciphertext – Buffer to which the ciphertext will be written. Must be of length PK::ciphertext_size, and 8-byte aligned.

  • shared_secret – Buffer to which the shared secret will be written. Must be of length PK::shared_secret_size, and 8-byte aligned.

  • public_key – Buffer containing the public key. Must be of length PK::public_key_size, and 8-byte aligned.

Decaps#

__device__ void PK::execute(
uint8_t *shared_secret,
const uint8_t *ciphertext,
const uint8_t *secret_key,
uint8_t *workspace,
uint8_t *smem_workspace
);#

Perform decapsulation: derive the shared secret from the ciphertext and secret key.

Parameters:
  • shared_secret – Buffer to which the shared secret will be written. Must be of length PK::shared_secret_size, and 8-byte aligned.

  • ciphertext – Buffer containing the ciphertext. Must be of length PK::ciphertext_size, and 8-byte aligned.

  • secret_key – Buffer containing the secret key. Must be of length PK::secret_key_size, and 8-byte aligned.

Sign#

__device__ void PK::execute(
uint8_t *signature,
const uint8_t *message,
const size_t message_length,
const uint8_t *secret_key,
uint8_t *entropy,
uint8_t *workspace,
uint8_t *smem_workspace
);#

Sign a message using the secret key.

Parameters:
  • signature – Buffer to which the signature will be written. Must be of length PK::signature_size, and 8-byte aligned.

  • message – Buffer containing the message.

  • message_length – Length of the message buffer.

  • secret_key – Buffer containing the secret key. Must be of length PK::secret_key_size, and 8-byte aligned.

Note

For algorithm::ML_DSA, PK::signature_size is not a multiple of 8. If performing batches of operations, padding may be required to ensure the signature argument is correctly aligned.

Verify#

__device__ bool PK::execute(
const uint8_t *message,
const size_t message_length,
const uint8_t *signature,
const uint8_t *public_key,
uint8_t *workspace,
uint8_t *smem_workspace
)#

Verify the signature of a message using the public key.

Parameters:
  • message – Buffer containing the message.

  • message_length – Length of the message buffer.

  • signature – Buffer containing the signature. Must be of length PK::signature_size, and 8-byte aligned.

  • public_key – Buffer containing the public key. Must be of length PK::public_key_size, and 8-byte aligned.

Returns:

true if the signature is valid for the given message and public key, false otherwise.

Note

For algorithm::ML_DSA, PK::signature_size is not a multiple of 8. If performing batches of operations, padding may be required to ensure the signature argument is correctly aligned.