How ekaragoz77/kyber-arm64 works
Project type and purpose
• This is a highly optimized C/ARM-assembly implementation of the Kyber post-quantum key-encapsulation mechanism (KEM), targeting 64-bit ARMv8 (AArch64) CPUs.
• It is a standalone cryptographic library plus test/benchmark harness, not a web app or full-stack system.
• Purpose: provide compact, high-performance Kyber primitives for ARM Cortex-A processors and measure their performance.
File structure
• Top-level files:
• AUTHORS, LICENSE, README.md – metadata
• armv8/ – all source code (C and ARM64 assembly), headers, tests, and Makefile
• howtobuild.md – build instructions
• Under armv8/:
• Assembly modules (*.S, *.inc) for core operations (NTT, reduction, multiplication)
• C modules for fallback or glue logic (e.g., fips202.c, randombytes.c, kem.c, kex.c)
• Headers (*.h) define the API, parameters, and internal interfaces
• Test programs (test_kex.c, test_kyber.c, test_speed.c, test_vectors.c)
• Makefile orchestrates cross-compilation and linking
README for additional insights
• Confirms this is an ARM64-optimized variant of an existing reference Kyber implementation.
• Benchmarking on real devices (Pixel 3, iPad) and comparing clock cycles.
Main components
a. Source modules (grouped by function):
• Parameter definitions & API layer (params.h, api.h, kem.h, kex.h)
• Core arithmetic & NTT pipeline
– Assembly files: ntt-arm.S, inv-ntt-arm.S, basemul-arm.S, reduce-arm.S, add-arm.S, poly_macros-arm.S, cbd-arm.S
– C fallbacks: ntt.c, poly.c, polyvec.c, cbd.c, reduce.h, poly.h, polyvec.h
• Symmetric primitives
– SHA-2 (sha256.c/sha512.c, fips202.c), AES-CTR (aes256ctr.c)
– DRBG / randombytes (rng.c, randombytes.c)
• KEM operations (kem.c, kex.c, indcpa.c, verify.c)
• Utilities & benchmarks (cpucycles.c, speed_print.c)
b. Build system
• armv8/Makefile invokes cross‐compiler, assembles .S files, links object files into executables and static library
• howtobuild.md details environment setup
c. Test/benchmark harness
• test_kex, test_kyber: correctness of key‐gen, encaps, decaps
• test_speed: measure cycle counts via cpucycles
• test_vectors: verify against known vectors
Relationships and interactions
• The Makefile takes all source modules → compiles C and assembles ARM64 code → produces:
• Static library libkyber-arm64.a
• Test executables
• At runtime, test programs call into the library’s API (keypair, encaps, decaps)
• Inside library, high-level API calls into symmetric primitives and core NTT/arithmetic modules
• Benchmark harness invokes cpucycles around individual primitive calls
Architectural patterns and design principles
• Modular layering:
• API layer (uniform interface)
• Primitive abstraction (symmetric vs arithmetic)
• Architecture‐specific hand-tuned assembly modules
• Separation of concerns:
• Correctness (reference C code) vs performance (ASM)
• Testing harness separated from library code
• Cross‐platform build: unified Makefile controls architecture‐specific flags
Technologies, frameworks, libraries
• Language: C99 + GNU assembler (ARM64 syntax)
• Build: GNU Make, gcc-aarch64 (cross-compiler)
• No external dependencies beyond standard C library and assembler