Skip to content

Add HIP post-quantum cryptography examples - #469

Open
firedoil wants to merge 3 commits into
ROCm:amd-stagingfrom
firedoil:add-pqc-trustflow-rocm
Open

Add HIP post-quantum cryptography examples#469
firedoil wants to merge 3 commits into
ROCm:amd-stagingfrom
firedoil:add-pqc-trustflow-rocm

Conversation

@firedoil

@firedoil firedoil commented Jun 19, 2026

Copy link
Copy Markdown

Description

This PR adds post-quantum cryptography examples implemented with HIP for AMD GPUs.

The examples demonstrate batched key encapsulation and digital signature workflows using Kyber, Aigis-enc, ML-DSA, and Aigis-sig. The executables provide deterministic CTest self-tests and file-oriented commands for key generation, encapsulation, decapsulation, signing, and verification.

Changes

  • Standardized GPU entry points as .hip files and headers as .hpp files.
  • Removed the CUDA conversion compatibility layer and made the examples explicitly target the AMD HIP backend.
  • Integrated the examples with the existing Applications/CMakeLists.txt and Applications/Makefile.
  • Added standalone CMake and Makefile support for the PQC example directory.
  • Added CTest self-tests for every supported parameter set.
  • Added file-oriented KEM and signature command interfaces.
  • Converted comments, documentation, command descriptions, and user-facing messages to English.
  • Removed the research and optimization section, profiling artifacts, benchmark results, performance comparisons, Jupyter frontend, and shell build scripts.
  • Retained concise implementation notes in the README without benchmark or performance claims.
  • Split resource-intensive signature verification preprocessing into smaller HIP kernels so that the largest ML-DSA parameter set runs on gfx1100.

Supported Parameter Sets

The following 13 targets are supported:

  • applications_pqc_kyber512
  • applications_pqc_kyber768
  • applications_pqc_kyber1024
  • applications_pqc_aigis_enc1
  • applications_pqc_aigis_enc2
  • applications_pqc_aigis_enc3
  • applications_pqc_aigis_enc4
  • applications_pqc_mldsa44
  • applications_pqc_mldsa65
  • applications_pqc_mldsa87
  • applications_pqc_aigis_sig1
  • applications_pqc_aigis_sig2
  • applications_pqc_aigis_sig3

Four representative targets are built by default. Set ROCM_EXAMPLES_PQC_BUILD_ALL_VARIANTS=ON to build and test all 13 parameter sets.

Build and Test

The examples were built and tested with:

  • AMD Radeon Graphics
  • GPU architecture: gfx1100
  • HIP version: 7.12.60610
  • AMD Clang version: 22.0.0git

All supported parameter sets were enabled and tested with:

cmake -S Applications/pqc_trustflow_rocm \
  -B build-pqc-all \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_HIP_ARCHITECTURES=gfx1100 \
  -DROCM_EXAMPLES_PQC_BUILD_ALL_VARIANTS=ON

cmake --build build-pqc-all --parallel 2
ctest --test-dir build-pqc-all --output-on-failure

Result:

100% tests passed, 0 tests failed out of 13

The self-tests cover KEM shared-secret agreement, signature generation and verification, and rejection of modified signature data.

Notes

This contribution intentionally targets the AMD HIP backend. CUDA backend compatibility is not included in this revision.

The implementation is provided as an educational HIP example and is not intended to be used as a production cryptographic library.

@firedoil
firedoil requested review from a team as code owners June 19, 2026 18:49
@zichguan-amd

Copy link
Copy Markdown
Collaborator

Hi @firedoil, thanks for contributing to rocm-examples! PQC is an interesting topic that we haven't covered yet in the repo, and your PR is a welcomed addition. To align with rocm-examples existing code base and future maintainability, there are some points that need to be addressed for this PR to land:

  • The comments and documentations are not in English.
  • The build system does not integrate with existing CMake and Makefile structures, this is very important for CI testing, please add at least CMake support instead of a bash build script.
  • 2nd part doesn't really fit into this repo. It's meant to showcase HIP applications and API usage, which is what the first part does. I'd distill the research and optimizations into a section of readme and remove the second part all together. Please also remove any performance comparison or benchmark claims.
  • The kem_api source files are .cu files with a rocm_compat.h conversion header, but sign_api seems to be purely ROCm. Please standardize the sources to HIP files that runs on amd backend. Compatibility with cuda backend is a plus.

@firedoil firedoil changed the title Add ROCm PQC TrustFlow KEM and signature example Add HIP post-quantum cryptography examples Jul 27, 2026
@firedoil

Copy link
Copy Markdown
Author

Hi, thank you for the detailed review. I have updated the PR to address the requested changes:

  1. All comments, documentation, command descriptions, and user-facing messages in the PQC examples are now in English.

  2. The examples are now integrated into the existing Applications/CMakeLists.txt and Applications/Makefile. The PQC directory also provides standalone CMake and Makefile support, and the supported targets are registered with CTest.

  3. The research and optimization section, profiling artifacts, benchmark results, performance comparisons, Jupyter frontend, and shell build scripts have been removed. The README now contains only concise implementation notes without benchmark or performance claims.

  4. The source files have been standardized as HIP sources using .hip entry points and .hpp headers. The conversion compatibility header has been removed. This revision intentionally supports the AMD HIP backend only; CUDA compatibility is not included.

I built and tested all 13 supported parameter-set targets on an AMD gfx1100 GPU with HIP 7.12.60610. All 13 CTest self-tests passed.

Thank you again for the review.

@zichguan-amd

Copy link
Copy Markdown
Collaborator

Hi @firedoil, thanks for the follow up. Since this PR covers encryption/cryptography, it requires internal review and approval. I've sent out a request and will let you know if the content can be merged as per ROCm's OSS policies before I review again. Thanks for the understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants