PQCUARK is a set of hardware accelerators and toolchain support for post-quantum cryptography (PQC) on RISC-V. This repo aggregates RTL, scheme submodules, the binutils patch workflow, and a Sargantana simulation environment.
Related paper: https://eprint.iacr.org/2025/2178
- Overview
- Repository structure
- Prerequisites
- Initialize submodules
- Generate the PQCUARK toolchain
- Build scheme binaries
- Run binaries on Sargantana (Verilator)
- Cleanup
- Notes
Main flow:
- Generate and build the RISC-V toolchain with PQCUARK opcodes.
- Build ML-KEM or ML-DSA binaries.
- Run them on the Sargantana simulator (Verilator).
interface/RISC-V interfaces for BFU/Keccak.rtl/RTL for PQCUARK-NTT and PQCUARK-Keccak.includes/shared RTL utilities (submodulepqcuark-common).schemes/scheme submodules (ML-KEM and ML-DSA).toolchain/local clones ofriscv-gnu-toolchainand PQCUARK binutils.patches/generated patches (binutils and Sargantana).scripts/toolchain/Sargantana/run helpers.filelist.fRTL file list for simulation/lint.
- Git access to the remote repositories.
- Usual
riscv-gnu-toolchainbuild dependencies. - Verilator and dependencies for
core_tile(Sargantana).
The toolchain target clones riscv-gnu-toolchain, generates the opcode patch from the PQCUARK binutils fork, and builds the toolchain with a local prefix.
make toolchainThe toolchain is installed at:
toolchain/gcc-pqcuarkSet GCC_PQCUARK to build the schemes (use the helper script):
source schemes/ml-kem/set-env.sh
# or
source schemes/ml-dsa/set-env.shDefault binaries (PQCUARK):
make ml-kem-bin
make ml-dsa-binOutput binaries:
schemes/ml-kem/out/test_kyber512_pqcuarkschemes/ml-dsa/out/test_dilithium2_pqcuark
Override test and configuration via variables:
make ml-kem-bin ML_KEM_TEST=test_kyber768 ML_KEM_CONF=pqcuark
make ml-dsa-bin ML_DSA_TEST=test_dilithium3 ML_DSA_CONF=pqcuarkAll supported variations:
# ML-KEM tests (ML_KEM_TEST)
test_kyber512 | test_kyber768 | test_kyber1024
test_speed512 | test_speed768 | test_speed1024
# ML-KEM configurations (ML_KEM_CONF)
nist | pqrv_rv64im | pqrv_rv64imb | pqcuark
# ML-DSA tests (ML_DSA_TEST)
test_dilithium2 | test_dilithium3 | test_dilithium5
test_speed2 | test_speed3 | test_speed5
# ML-DSA configurations (ML_DSA_CONF)
nist | pqrv_rv64im | pqrv_rv64imb | pqcuarkFull flow initializes Sargantana, builds the simulator, and runs a default binary (kyber512_pqcuark, dilithium2_pqcuark):
make verilator-ml-kem
make verilator-ml-dsaTo run a specific binary, pass the same variables to the Verilator targets (they build and then execute the matching output binary name out/<test>_<conf>):
make verilator-ml-kem ML_KEM_TEST=test_kyber768 ML_KEM_CONF=pqcuark
make verilator-ml-dsa ML_DSA_TEST=test_dilithium3 ML_DSA_CONF=pqcuarkUseful RUN_VERILATOR_OPTS flags (forwarded to scripts/run_verilator.sh):
RUN_VERILATOR_OPTS="-w -d" make verilator-ml-kemFlags:
-wgenerate a VCD waveform underoutput/waves/.-ddump a signature file underoutput/signature/.-kgenerate a Konata trace underoutput/konata/.-srun Spike reference execution (requiresSPIKE_PATH).-crun cosimulation (DefaultConfig-sim-cosimbinary).-a "<args>"append extra arguments to the Verilator invocation.
If you only need to prepare Sargantana or the simulator:
make sargantana-init
make core-simmake cleanIndividual targets:
make clean-toolchain
make clean-sargantana
make schemes-clean- PQCUARK paper (important): https://eprint.iacr.org/2025/2178
- PQRV code is sourced from: https://github.com/Ji-Peng/PQRV
- NIST reference code is sourced from: https://github.com/pq-crystals/kyber and https://github.com/pq-crystals/dilithium
sargantana-initclonesexternal/core_tile, applies PQCUARK/CSR patches, and clones this repo into the Sargantana tree.scripts/run_verilator.shsupports extra options (-w,-d,-k,-c,-a).- The toolchain and Sargantana flows require network access to clone remote repositories.
Copyright 2026 Barcelona Supercomputing Center (BSC)
Licensed under the Solderpad Hardware License v 2.1 (the "License"); you may not use this file except in compliance with the License, or, at your option, the Apache License version 2.0. You may obtain a copy of the License at
https://solderpad.org/licenses/SHL-2.1/
Unless required by applicable law or agreed to in writing, any work distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.