设备方法#

方法可以从描述符 PQC 的实例访问。

execute#

PQC::execute(...)#

描述符对象定义了一个 execute 方法,其签名取决于 Function 运算符。 常用参数

参数:

密钥生成#

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

生成公钥和私钥对。

参数:
  • public_key – 将写入公钥的缓冲区。 长度必须为 PQC::public_key_size 且 8 字节对齐。

  • secret_key – 将写入私钥的缓冲区。 长度必须为 PQC::secret_key_size 且 8 字节对齐。

封装#

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

执行封装:生成共享密钥,并使用公钥将其加密为密文。

参数:
  • ciphertext – 将写入密文的缓冲区。 长度必须为 PQC::ciphertext_size 且 8 字节对齐。

  • shared_secret – 将写入共享密钥的缓冲区。 长度必须为 PQC::shared_secret_size 且 8 字节对齐。

  • public_key – 包含公钥的缓冲区。 长度必须为 PQC::public_key_size 且 8 字节对齐。

解封#

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

执行解封:从密文和私钥中导出共享密钥。

参数:
  • shared_secret – 将写入共享密钥的缓冲区。 长度必须为 PQC::shared_secret_size 且 8 字节对齐。

  • ciphertext – 包含密文的缓冲区。 长度必须为 PQC::ciphertext_size 且 8 字节对齐。

  • secret_key – 包含私钥的缓冲区。 长度必须为 PQC::secret_key_size 且 8 字节对齐。

签名#

__device__ void PQC::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,
);#

使用私钥对消息进行签名。

参数:
  • signature – 将写入签名的缓冲区。 长度必须为 PQC::signature_size 且 8 字节对齐。

  • message – 包含消息的缓冲区。

  • message_lengthmessage 缓冲区的长度。

  • secret_key – 包含私钥的缓冲区。 长度必须为 PQC::secret_key_size 且 8 字节对齐。

注意

对于 algorithm::ML_DSAPQC::signature_size *不是* 8 的倍数。 如果执行批量操作,则可能需要填充以确保 signature 参数正确对齐。

验证#

__device__ bool PQC::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,
)#

使用公钥验证消息的签名。

参数:
  • message – 包含消息的缓冲区。

  • message_lengthmessage 缓冲区的长度。

  • signature – 包含签名的缓冲区。 长度必须为 PQC::signature_size 且 8 字节对齐。

  • public_key – 包含公钥的缓冲区。 长度必须为 PQC::public_key_size 且 8 字节对齐。

返回值:

如果签名对于给定的消息和公钥有效,则返回 true,否则返回 false

注意

对于 algorithm::ML_DSAPQC::signature_size *不是* 8 的倍数。 如果执行批量操作,则可能需要填充以确保 signature 参数正确对齐。