This repository is a fork of the pqax repository, adding further examples from public-key cryptography (both classical and post-quantum). Along with pqmx and SLOTHY, it accompanies the paper Fast and Clean: Auditable high-performance assembly via constraint-solving by Abdulrahman, Becker, Kannwischer and Klein.
It contains implementations of SPHINCS+ described in Hybrid scalar/vector implementations of Keccak and SPHINCS+ on AArch64. See sphincsplus for more details.
The main components of the repository are the following:
asm
: Core primitives in optimized assembly, auto-generated or handwritten.tests
: C-based tests for core primitives using a minimal hardware abstraction layer (HAL).envs
: Test environments implementing the HAL.sphincsplus
: Supporting material for the paper "Hybrid scalar/vector implementations of Keccak on AArch64"nelight
: Submodule for the SLOTHY superoptimizer.
The following sections explain each component in greater detail.
The heart of the repository are optimized assembly routines for core components of the post quantum primitives under
consideration, such as the NTT or Keccak. All optimized assembly is contained in the asm
directory, which is structured
as follows:
asm/manual
contains assembly that has been written by hand.asm/scripts
contains code generation scripts for various algorithms around polynomial multiplication or the PQC schemes they're relevant for, as well as other tests and examples.asm/auto/
contains the assembly auto-generated by the examples inasm/scripts
. Its structure mirrors that ofasm/scripts
.
The core assembly routines are accompanied by C test programs contained in tests/
. For example, the
Keccak implementations from asm/manual/keccak_f1600
are tested in
tests/keccak_neon/
.
The test files platform-independent and only rely on a small hardware abstraction layer
tests/inc/hal.h
which declares stubs for debugging, measuring, and random sources.
As mentioned above, the tests from tests/
can be run in any environment defining the hardware abstraction layer
interface tests/inc/hal.h
.
The supported test environments are located in envs
. There are currently two test environments: native
for
builds on an Arm host, and cross
for cross-compilation. For the cross
test environment, you can specific the
environment variable CYCLES
as one of NO, PMU, PERF
to indicate the source of cycle counts, and PLATFORM
as one of
v8a
or v84a
to control the compilation target.
pqax is licensed under the MIT license. See LICENSE for details.
pqax contains some third party sources, some of which are licensed differently:
- sphincsplus/sphincsplusx2: CC0 1.0 Universal Public Domain Dedication
- asm/manual/keccak_f1600/third_party/keccakx2_cothan.c: Apache 2.0
- asm/manual/keccak_f1600/third_party/keccakx2_bas.s: MIT
- asm/manual/keccak_f1600/third_party/keccakx2_C.s: CC0 1.0 Universal Public Domain Dedication
- asm/manual/x25519/X25519-AArch64.s: CC0 1.0 Universal Public Domain
To build/run tests, use make build-{cross,native}-{testname}
, where test
is one of the tests in
tests. For example, to cross-compile the Keccak tests for simulation in QEMU, use CYCLES=NO make build-cross-keccak_neon
.