Repository navigation
Description
Part 3 of 9 · #184 · Size L · Base 1.x.x · Needs part 2 (#186) · Unblocks part 4 (#199), part 9 (#222)
Consolidates work items D1 (#190), D2 (#191), C2 (#194), D3 (#197), D5 (#201), C3 (#195) and D4 (#198), each formerly its own sub-issue. Their full text is below as sections; the closed issues point here.
Goal
Bring in mlkem-native unmodified and build ML-KEM-1024 into bitcoin_node: native code where it is proved, supported and keeps the binary's hardening (x86_64 with AVX2, AArch64 on macOS) and portable C elsewhere, including AArch64 Linux, behind a small C++ wrapper. Also its tests, fuzz targets and benchmarks, the s390x and macOS arm64 CI jobs, the aarch64 merge gate, and the Guix and hardening check. Nothing in qbitd calls the library yet.
Work items
In suggested commit order. Each item is a section below.
- D1 · crypto: vendor mlkem-native v2.0.0 unmodified, with a pin, update script and tree-id lint
- D2 · crypto: add a cached, standalone usable-AVX2 check
- C2 · ci: add s390x big-endian and macOS arm64 unit jobs to the PQ workflow
- D3 · crypto: build ML-KEM-1024 with runtime backend selection and a C++ wrapper
- D5 · fuzz, bench: exercise ML-KEM-1024 per backend
- C3 · ci: require the aarch64 PQ job for ML-KEM and transport changes
- D4 · build: verify reproducible Guix builds and ELF hardening notes with native ML-KEM
Starting early
- Every item can start now. C2 and C3 extend the workflow C1 (test, ci: foundations: qbit release tooling, Python ML-KEM-1024, v1.0.0 interop, PQ CI workflow, canary tools (#184 part 2) #186) creates, and D3's evidence needs C1's jobs, so this part merges after part 2. Stack its branch on part 2's if part 2 hasn't merged.
- D4 is evidence posted on this part's pull request, not a separate commit, unless the hardening fallback is needed.
D1 · crypto: vendor mlkem-native v2.0.0 unmodified, with a pin, update script and tree-id lint
Needs nothing within #184.
Goal
Bring the upstream ML-KEM library into the tree byte for byte, with tooling that proves it stays unmodified. Nothing compiles it yet; D3 does.
Context
- Library: mlkem-native v2.0.0 (PQ Code Package), commit
d1b2fe782888bdb761a50336012923180be7f502. Upstream git ids at that commit: tree ofmlkem/=d9d581290ea1e6fa37462bfbc61b9b4266a2e9e5, blob ofLICENSE=79c71b1fdcc53cc17b1df99a0f4d4d48121ac174. - Why this library: its C code is CBMC-proved memory-safe, and its x86_64 and AArch64 assembly is HOL-Light-proved correct and constant-time wherever it handles secret data. It has AVX2 and NEON backends with a portable C fallback. Editing it would void those proofs, so it is never edited.
- The libbitcoinpqc subtree already has the tooling to mirror:
test/lint/libbitcoinpqc-subtree-check.sh,doc/subtrees/libbitcoinpqc.md,ci/checks/test_libbitcoinpqc_build_policy.py, and lint ignores intest/lint/lint_ignore_dirs.pyandtest/lint/test_runner/src/main.rs. The markdown lint ignores only git subtrees and one Doxygen readme (main.rs:696-699), and upstream's READMEs link to files outsidemlkem/.
Scope
src/mlkem-native/: the whole upstreammlkem/directory (C sources,fips202/and everynative/backend, about 1.7 MB) plusLICENSE, at the pinned commit, byte-identical. Copying the whole directory keeps the identity check simple and keeps every file upstream's single-compilation-unit build includes.contrib/devtools/mlkem-native.pin: the full commit, the tagv2.0.0, the tree id ofmlkem/and theLICENSEblob id.contrib/devtools/update-mlkem-native.sh [<commit>]: defaults to the pinned tag; honorsREMOTE_REFandREMOTE_URL; copiesmlkem/andLICENSE; computes the ids from the fetched upstream and rewrites the pin; then prints what to re-run, because qbit's backend headers include upstream paths (D3).test/lint/mlkem-native-check.sh, run by the lint runner likelibbitcoinpqc-subtree-check.sh:git rev-parse HEAD:src/mlkem-native/mlkemmust equal the pinned tree id, and theLICENSEblob must match. The check is exact and needs no network. It printsGOODorFAIL, and failures give signature, cause and fix.- Lint ignores:
test/lint/lint_ignore_dirs.pyandtest/lint/test_runner/src/main.rs, includinglint_markdown's ignore paths, plus any other lint that scanssrc/(spelling, includes, whitespace and so on). The vendored tree is never reformatted. doc/subtrees/mlkem-native.md, modeled ondoc/subtrees/libbitcoinpqc.md, with:- Current Pin;
- the update procedure;
- a PR checklist (D4 adds the Guix and ELF-property steps; D3 adds a diff of upstream's
fips202/native/aarch64/x1_scalar.hagainst qbit's mirror); - Common Failures, each as signature, cause and fix;
- the review cadence: check upstream releases and security advisories at least quarterly.
Acceptance criteria
-
test/lint/mlkem-native-check.shprintsGOODoffline, and editing any vendored byte makes it printFAIL. - All lints pass with the vendored tree.
- Running the update script at the pinned tag reproduces the tree with no diff.
Suggested commit: crypto: vendor pinned mlkem-native without source changes.
D2 · crypto: add a cached, standalone usable-AVX2 check
Needs nothing within #184.
Goal
A correct and cheap answer to "can this CPU and OS run the x86_64 ML-KEM assembly?", detected once at startup, for the ML-KEM capability hook in D3. That assembly needs AVX2 and also BMI2, POPCNT and SSE4.1 (decided 2026-10-05 after review: a VM that exposes AVX2 but hides BMI2 or POPCNT would otherwise crash with SIGILL on the first key generation; real AVX2 silicon has all four).
Context
- mlkem-native asks for the AVX2 capability 82 to 98 times per operation. With CPUID on every call, a KVM guest measured 248 to 301 µs per operation instead of 9 to 13 µs, so the answer must be cached.
src/crypto/sha256.cpp:574has a private XGETBV check (AVXEnabled).SHA256AutoDetectskips CPUID leaf 7 when SSE4 is missing, and clears AVX2 whenever SHA-NI is present (:613-630). That is right for SHA256 and wrong for ML-KEM, so share only the primitives, not that decision logic.
Scope
- Move only the XGETBV primitive into
src/compat/cpuid.h, under the existing supported-x86 guards:uint64_t XGetBV(uint32_t index) noexcept;. SHA256's selection behavior stays exactly as it is. - New
src/compat/cpu_features.h(and.cppif needed):namespace cpu_features { struct X86Features { uint32_t max_basic_leaf{0}; uint32_t leaf1_ecx{0}; uint32_t leaf7_ebx{0}; uint64_t xcr0{0}; }; X86Features DetectX86Features() noexcept; constexpr bool HasUsableAVX2(const X86Features& f) noexcept; bool HasUsableAVX2() noexcept; // detected once, then cached }
HasUsableAVX2requires all of:The exact list is every extension the vendored x86_64 assembly uses, confirmed by an instruction audit of the assembled objects; re-run the audit on every library update. Name the check for what it tests.max_basic_leaf >= 7 leaf1_ecx & (1 << 27) // OSXSAVE leaf1_ecx & (1 << 28) // AVX (xcr0 & 0x6) == 0x6 // XMM and YMM state enabled by the OS leaf7_ebx & (1 << 5) // AVX2 leaf7_ebx & (1 << 8) // BMI2 (pext) leaf1_ecx & (1 << 23) // POPCNT leaf1_ecx & (1 << 19) // SSE4.1 (pinsrq, pblendw)
Query the supported leaves first, and run XGETBV only after the leaf-1 checks pass. On non-x86 targets and unsupported compilers it returns false.
Tests
usable_avx2_matrix: synthetic features that clear each requirement in turn (leaf availability, OSXSAVE, AVX, XMM state, YMM state, AVX2) give false, and no XGETBV runs when OSXSAVE is clear.usable_avx2_host: on GCC and Clang x86 hosts the result equals__builtin_cpu_supports("avx2"), whether or not the CPU has SHA-NI.- Existing SHA256 tests unchanged.
Acceptance criteria
- Tests pass on x86_64, and the check compiles to false elsewhere.
- SHA256 implementation selection is unchanged (same
SHA256AutoDetectstring on the CI hosts).
Suggested commit: crypto: share x86 feature primitives and detect usable AVX2.
C2 · ci: add s390x big-endian and macOS arm64 unit jobs to the PQ workflow
Needs C1 (#186).
Goal
Run the PQ-relevant unit suites on a big-endian target and on Apple Silicon, so byte-order bugs and AArch64 assembly problems show up in CI.
Context
ci/test/00_setup_env_s390x.shbuilds and tests the whole tree inside an emulatedlinux/s390xcontainer, but no workflow runs it. qbit still ships a big-endianpowerpc64release.- The x64 runners already emulate
linux/arm64for the 32-bit ARM jobs, which need two 180-minute unit-test shards, so emulation works but is slow. ci.yml:220defines a native macOS arm64 job that is disabled by default.
Scope
s390x-unit. A newci/test/00_setup_env_s390x_unit.shcross-compiles on the x64 runner with Ubuntu'sg++-s390x-linux-gnuand the depends tree fors390x-linux-gnu, building onlytest_bitcoin. The suites run through ctest withCMAKE_CROSSCOMPILING_EMULATOR='qemu-s390x;-L;/usr/s390x-linux-gnu'passed as a CMake cache argument. Don't calltest_qbitdirectly: that would bypass the emulator. Only the tests run emulated. The timeout is 180 minutes until the first runs are measured, then twice the measured time.macos-arm64-unit. A GitHub-hostedmacos-14job with native host setup (no Docker). It assertsuname -misarm64and runs the same suites.- Both report suite evidence the same way as
aarch64-unit(C1). s390x-unitstays out of the merge gate (C3) because emulation is slow.
Acceptance criteria
- A named dispatch of each job runs only that job and passes on a clean hosted runner.
- Each summary shows
bip324_testsandnet_testsexecuted and passed. D3 addsmlkem_tests. - The measured
s390x-unittime is recorded, and its timeout set to twice that.
Suggested commit: ci: add s390x and macOS arm64 PQ unit jobs.
D3 · crypto: build ML-KEM-1024 with runtime backend selection and a C++ wrapper
Needs D1, D2, C1 (#186), C2, D4.
Goal
Compile mlkem-native into bitcoin_node as ML-KEM-1024. Use native code where it is proved and supported and keeps the binary's hardening (x86_64 with AVX2, and AArch64 on macOS) and portable C everywhere else, including AArch64 Linux (see D4), behind a small C++ wrapper with fixed-size types and secret wiping. Nothing in qbitd calls it yet.
Context
- Release builds target baseline x86-64. Upstream's default selection compiles the x86_64 backend only when the compiler itself targets AVX2 (
mlkem/src/sys.h:68-69,mlkem/src/native/meta.h,mlkem/src/fips202/native/auto.h). With default settings every release binary would silently run portable C. - Measured on an AMD Ryzen 9 9955HX (clang 21 -O3, medians of 20,000 runs):
- ML-KEM-1024 native: keygen 8.8 µs, encaps 9.7 µs, decaps 12.2 µs;
- portable C: 26.1, 26.9 and 25.8 µs;
- for comparison, today's ECDH costs 43.8 µs per side.
support/cleanse.his C++ (it includes<cstdlib>and declares a C++-linkage function), so C code can't include it.- MSan can't see writes made by assembly, so it would report false positives on native code.
- Hardening flags live on
core_interface(CMakeLists.txt:531-545:-fcf-protection=full, and-mbranch-protectionon aarch64). The configure summary starts atCMakeLists.txt:651.
Scope
Configuration. src/crypto/mlkem_config.h, selected through MLK_CONFIG_FILE and kept outside the vendored directory:
MLK_CONFIG_PARAMETER_SET=1024and a qbit namespace prefix;MLK_CONFIG_NO_RANDOMIZED_API, so only the deterministic_derandAPIs exist and callers supply entropy;MLK_CONFIG_CUSTOM_ZEROIZEmapped toqbit_mlkem_zeroize;MLK_CONFIG_CUSTOM_CAPABILITY_FUNCfor the capability hook below.
Backend selection without AVX2 compiler flags.
- Define
MLK_CONFIG_USE_NATIVE_BACKEND_ARITHandMLK_CONFIG_USE_NATIVE_BACKEND_FIPS202only on x86_64 withMLK_SYSV_ABI_SUPPORTED, and on AArch64 Mach-O (macOS). AArch64 ELF builds (Linux) stay portable: upstream's AArch64 assembly has no BTI landing pads or GNU property note, so linking it drops BTI/PAC/GCS marking from the whole binary (D4's finding; hardening wins).mlkem_config.hrefuses a native request for AArch64 ELF. Elsewhere (riscv64, powerpc64, 32-bit ARM, s390x, MSVC) leave them undefined; never define an enable macro to 0. With them set,mlkem_native.c:87-90would pull in the riscv64 backend. - Point
MLK_CONFIG_ARITH_BACKEND_FILEandMLK_CONFIG_FIPS202_BACKEND_FILEat qbit-ownedsrc/crypto/mlkem_arith_backend.handsrc/crypto/mlkem_fips202_backend.h:- x86_64: include
mlkem/src/native/x86_64/meta.handmlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.hunconditionally; - AArch64: arithmetic from
native/aarch64/meta.h; Keccak is the non-SHA3 variant upstream picks without the SHA3 extension, used on Apple too, so every AArch64 build runs the Keccak the Linux aarch64 job tests.x4_v8a_scalar.his included unchanged. The single-lane entry is a qbit-owned mirror of upstream'sx1_scalar.hdispatch glue that calls the same upstream assembly but first checks the NEON capability: upstream'sx1_scalar.hcalls its assembly with no capability check, so the portable override would otherwise be incomplete and the backend names untruthful. - Each header defines its backend's name.
- x86_64: include
- No C file is compiled with
-mavx2, and there is no global AVX2 flag. The x86_64 backend is assembly plus constant tables that check the CPU at run time, so the portable fallback runs on every x86-64 CPU.
Capability hook and portable override.
MLK_SYS_CAP_X86_64_AVX2maps to D2's cached check of every ISA extension the x86_64 assembly uses (AVX2, BMI2, POPCNT, SSE4.1),MLK_SYS_CAP_AARCH64_NEONto true (NEON is mandatory on AArch64), and every other capability,MLK_SYS_CAP_AARCH64_SHA3included, to 0.- The hook reads cached booleans plus one
std::atomic_boolportable override. No CPUID or XGETBV runs inside an ML-KEM operation. - The override forces every capability check to 0, so every native routine falls back to portable C. It changes only before networking starts, or between operations in single-threaded test code: the x86_64 backend uses its own NTT coefficient order, so one operation must never mix backends.
- C ABI shim
src/crypto/mlkem_shim.h, with the C declarations hidden from__ASSEMBLER__:void qbit_mlkem_zeroize(void* ptr, size_t len); // C++ implementation forwards to memory_cleanse int qbit_mlkem_has_avx2(void); int qbit_mlkem_has_neon(void);
Wrapper. src/crypto/mlkem.{h,cpp}:
namespace mlkem {
inline constexpr size_t PUBLIC_KEY_BYTES = 1568;
inline constexpr size_t SECRET_KEY_BYTES = 3168;
inline constexpr size_t CIPHERTEXT_BYTES = 1568;
inline constexpr size_t SHARED_SECRET_BYTES = 32;
inline constexpr size_t KEYGEN_SEED_BYTES = 64;
inline constexpr size_t ENCAPS_COINS_BYTES = 32;
template <size_t N>
class Secret { // memory_cleanse on destruction, Clear() and move-from
std::array<uint8_t, N> m_bytes{};
public:
Secret() noexcept = default;
~Secret();
Secret(const Secret&) = delete;
Secret& operator=(const Secret&) = delete;
Secret(Secret&& other) noexcept;
Secret& operator=(Secret&& other) noexcept;
std::span<uint8_t, N> Bytes() noexcept;
std::span<const uint8_t, N> Bytes() const noexcept;
void Clear() noexcept;
};
using PublicKey = std::array<uint8_t, PUBLIC_KEY_BYTES>;
using Ciphertext = std::array<uint8_t, CIPHERTEXT_BYTES>;
using DecapsulationKey = Secret<SECRET_KEY_BYTES>;
using SharedSecret = Secret<SHARED_SECRET_BYTES>;
enum class Error : uint8_t { NONE = 0, INVALID_PUBLIC_KEY = 1, INVALID_SECRET_KEY = 2, INTERNAL = 3 };
[[nodiscard]] Error KeyGen(std::span<const uint8_t, 64> seed64, PublicKey& ek, DecapsulationKey& dk) noexcept;
[[nodiscard]] Error CheckPublicKey(std::span<const uint8_t, 1568> ek) noexcept;
[[nodiscard]] Error Encaps(std::span<const uint8_t, 1568> ek, std::span<const uint8_t, 32> coins32,
Ciphertext& ct, SharedSecret& ss) noexcept;
[[nodiscard]] Error Decaps(const DecapsulationKey& dk, std::span<const uint8_t, 1568> ct,
SharedSecret& ss) noexcept;
struct BackendNames { std::string_view arith; std::string_view keccak; };
void InitializeRuntime(bool force_portable) noexcept;
BackendNames GetBackendNames() noexcept; // the ACTIVE implementation
class ForcePortableForTesting { // RAII; restores the previous value
bool m_previous;
public:
ForcePortableForTesting() noexcept;
~ForcePortableForTesting();
ForcePortableForTesting(const ForcePortableForTesting&) = delete;
ForcePortableForTesting& operator=(const ForcePortableForTesting&) = delete;
};
} // namespace mlkem- Every return value is checked, and every failed call clears its secret outputs.
- Upstream's invalid-public-key result maps to
INVALID_PUBLIC_KEY, separately from internal failures. - A ciphertext of the right length that was corrupted still yields a secret (implicit rejection); it is not an error.
- Fixed-size spans prevent wrong-sized calls. Callers check network lengths before constructing them.
- Backend names: arith
x86_64-avx2,aarch64-neonorportable; keccakx86_64-avx2,aarch64orportable. - Entropy is the caller's job (E2): key generation takes two independent 32-byte draws, and encapsulation one.
Build.
cmake/mlkem-native.cmakebuilds upstream's single compilation unitmlkem_native.cplusmlkem_native_asm.Sas a private dependency ofbitcoin_nodeonly. It never goes intobitcoin_crypto,bitcoin_commonorbitcoin_consensus; tests, fuzz and bench reach it through their node linkage.- The
core_interfacehardening flags apply to the C and assembly sources. - MSVC, and any toolchain without GNU-as support, build portable only (
MLK_CONFIG_NO_ASM). - When
SANITIZERScontainsmemory, both native options stay unset. WITH_MLKEM_NATIVE=AUTO|ON|OFF, defaultAUTO:AUTObuilds native code where supported;ONis a configure error where native code isn't supported (including AArch64 ELF) or the sanitizer settings forbid it;OFFbuilds portable only.
- The configure summary prints the ML-KEM backend and why it was chosen.
CI. Add mlkem_tests to the PQ unit jobs: CTEST_REGEX becomes ^(mlkem_tests|bip324_tests|net_tests)$, and the expected-suite checks include it.
Tests
| Test | Setup | Expect |
|---|---|---|
mlkem_tests/acvp_keygen_1024 |
Fixed d ‖ z, native then portable |
Exact EK and DK; identical outputs |
mlkem_tests/acvp_encap_decap_1024 |
Fixed EK and coins; fixed DK and CT | Exact CT and SS; decapsulation succeeds |
mlkem_tests/public_key_modulus |
C2SP CCTV valid and invalid coefficients, including the 3328/3329 boundary | Correct result; no assertion reachable from peer input |
mlkem_tests/implicit_rejection |
Flip ciphertext bits, same size | A secret is returned; it differs from the original and matches the reference rejection vector |
mlkem_tests/wrapper_lifetimes_and_errors |
Invalid DK; injected internal failures; move and clear | Errors distinguished; secret outputs cleared; moved-from objects cleared |
mlkem_tests/backend_selection |
AUTO on a native-capable build, OFF build, MSan build, the portable guard | Native code is compiled in where expected; on a host where __builtin_cpu_supports("avx2") is true the active backend is native, so a build that silently fell back to portable fails; names match; the guard restores state |
ci/checks/test_mlkem_build_policy.py |
AUTO/ON/OFF across the architecture, compiler and sanitizer matrix | Correct configure success or failure; native options only on x86_64 SysV and AArch64; no global AVX2 flag |
Lint and backend-test failures print signature, cause and fix.
Acceptance criteria
- Unit and build-policy tests pass in required CI.
- Named dispatches of
s390x-unit,aarch64-unitandmacos-arm64-uniton the PR branch pass, withmlkem_testsexecuted. - CMake configure tests cover
AUTO,ONandOFF. - D4's Guix reproducibility and ELF-property evidence is posted on this PR.
- No ML-KEM symbol is in
bitcoin_crypto,bitcoin_commonorbitcoin_consensus, andqbitdbehavior is unchanged.
Suggested commit: crypto: add ML-KEM-1024 wrapper and runtime backend dispatch.
D5 · fuzz, bench: exercise ML-KEM-1024 per backend
Needs D3.
Goal
Fuzz the wrapper on both backends, prove the backends agree, and benchmark each one.
Scope
src/test/fuzz/mlkem.cpp:- target
mlkem: arbitrary EK and CT plus deterministic seeds. An invalid EK is rejected safely. Decapsulating a valid-length CT is never treated as proof the ciphertext was valid. Honest round trips agree. - target
mlkem_backend_diff: the same seeds, EK and CT under the detected backend and under forced portable C must give equal status and outputs. The override is restored before returning. - Both honor
MLKEM_FORCE_PORTABLE=1.
- target
- Required corpus: add both targets to
QBIT_REQUIRED_CORPUS_TARGETS(test/fuzz/test_runner.py:22), to the target list intest/fuzz/qbit_corpora/overlay.pyand toMANIFEST.json. Add seeds throughgenerate_seeds.pywithin its limits: 16 seeds per target, 8 KiB per seed, 64 KiB per target, 384 KiB in total. src/bench/mlkem.cpp: keygen, encaps and decaps, with one benchmark per backend named after it, restoring auto-detection afterwards (the SHA256 precedent is insrc/bench/crypto_hash.cpp).
Acceptance criteria
- Seed replay, deterministic replay and forced-portable replay pass in the fuzz CI job.
- On an AVX2 host,
bench_qbit -filter='MLKEM.*'lists both backends.
Suggested commits: fuzz: exercise ML-KEM validation and backend equivalence; bench: measure ML-KEM operations by active backend.
C3 · ci: require the aarch64 PQ job for ML-KEM and transport changes
Needs C1 (#186).
Goal
Pull requests that touch the ML-KEM library, the transport, or their build and CI wiring must pass aarch64-unit before they merge. Other pull requests skip it.
Context
- The required gate on
1.x.xisfull-validation-gate(ci.yml:1071); itscheck_result(:1110) fails anything other thansuccess. ci/checks/classify_merge_profile.py(called atci.yml:130) decides each pull request's validation profile.
Scope
- A new classifier output, true when a change touches any of:
src/mlkem-native/**,src/crypto/mlkem*,cmake/mlkem-native.cmake;src/bip324*(includingsrc/bip324_pq.*),src/net.h,src/net.cpp;src/compat/cpuid.h,src/compat/cpu_features.*;.github/workflows/ci-pq.ymland the PQ CI env files;src/test/mlkem_tests.cpp,src/test/bip324_tests.cpp,src/test/net_tests.cpp,src/test/data/pq_transport_vectors.json.
ci.ymlcallsci-pq.ymlwithjobs: aarch64-unitwhen the output is true. The source is the pull request's merge commit.full-validation-gateacceptsskippedfor this job only when the classifier says it isn't required. A required job that was skipped, failed or cancelled, or a missing classifier output, fails the gate.- Contract tests: a matching pull request (for example, one touching
src/bip324.cpp) requires and runs the job; a non-matching one skips it and passes the gate.
Acceptance criteria
- Contract tests for both cases pass in required CI.
- A test pull request touching
src/bip324.cppshows the aarch64 check, and one touching only docs does not.
Suggested commit: ci: gate ML-KEM and transport changes on the aarch64 PQ job.
D4 · build: verify reproducible Guix builds and ELF hardening notes with native ML-KEM
Needs nothing within #184.
Goal
Show that linking the native ML-KEM code keeps release builds reproducible and doesn't silently drop control-flow hardening from release binaries. This part merges only with this evidence.
Context
- Guix release builds also build and install
test_qbit:contrib/guix/libexec/build.shdoesn't turn tests off, andsrc/test/CMakeLists.txt:250installs the binary. So D3 already puts the library into a release artifact. - Release builds compile with
-fcf-protection=fullon x86_64 and-mbranch-protectionon aarch64 (CMakeLists.txt:531-545). The linker keeps a GNU property in the output (IBT and SHSTK on x86_64, BTI and PAC on aarch64) only if every input object carries it. mlkem-native's AArch64 assembly emits nobti cand no property note, so linking it can drop BTI/PAC marking from a whole aarch64 binary. contrib/guix/security-check.pychecks only the first instruction ofmain(endbr64orbti), so it would not catch that.
Scope
- Guix-build every release host on this part's branch with the assembly enabled. Reproduce the build (two independent builds give identical hashes), and record the hashes on this part's pull request.
- Compare the
readelf -nGNU property notes of every Guix-built ELF binary (includingqbitd,qbit-cli,qbit-qtandtest_qbit) before (base1.x.x) and after (D3): BTI and PAC on aarch64, IBT and SHSTK on x86_64. Post the table on this part's pull request. - Make the comparison repeatable: add the commands, or a short script, to the PR checklist in
doc/subtrees/mlkem-native.md(D1). Every library update repeats it, and so does E3 (net: hybrid v2 handshake: key recipe, record parser, negotiation with key confirmation, and spec (#184 part 4) #199), the first PR whereqbitditself links the code. - Finding, 2026-10-05: cross-built with
-mbranch-protection=standard, every C and C++ object carries BTI, PAC and GCS, but upstream'smlkem_native_asm.Sobject has no GNU property note, so a binary that links the native AArch64 backend loses all three (ld -z force-btinames the object). x86_64 keeps IBT and SHSTK. AArch64 ELF builds are therefore portable-only (D3) until an upstream release's AArch64 assembly carries landing pads and the property note; re-run this comparison then. - If a marking that was present is lost, hardening wins. Build AArch64 Linux without the native backend (portable C) until upstream ships landing pads, make the backend-selection tests expect portable in that configuration, and record the reason in the runbook. Apply the same rule to x86_64 if IBT or SHSTK is lost. Never restore a marking by force-marking objects that lack landing pads.
Acceptance criteria
- Guix hashes for all release hosts are recorded and reproduced.
- The before/after property table is on this part's pull request, and either no marking is lost or the fallback above is applied in D3.
- The runbook's PR checklist includes the comparison.
One pull request against 1.x.x closes this issue. The shared contract is the Design section of #184; change it there first if needed.
Activity
[-]crypto: vendor mlkem-native v2.0.0 unmodified, with a pin, update script and tree-id lint (#184 D1)[/-][+]crypto: vendor mlkem-native and build ML-KEM-1024 with runtime backend selection, tests and cross-platform CI (#184 part 3)[/+]crypto: vendor pinned mlkem-native without source changes
4 remaining items
bench: measure ML-KEM operations by active backend
ci: add s390x and macOS arm64 PQ unit jobs
ci: gate ML-KEM and transport changes on the aarch64 PQ job
crypto: share x86 feature primitives and detect usable AVX2
crypto: require SSSE3 for the SSE4 and SHA-NI SHA256 paths
crypto: add ML-KEM-1024 wrapper and runtime backend dispatch
fuzz: exercise ML-KEM validation and backend equivalence
bench: measure ML-KEM operations by active backend
ci: add s390x and macOS arm64 PQ unit jobs
ci: gate ML-KEM and transport changes on the aarch64 PQ job
doc: record the local x86_64 GNU property evidence for mlkem-native
crypto: vendor mlkem-native and build ML-KEM-1024 with runtime backen…
djh58 commentedon Oct 23, 2026
Done in #225, merged into
feature/pq-transportas 6fcdb4a. It reaches1.1.0with #233 and ships in 1.1.0.D4 (reproducible Guix builds and ELF hardening notes with native ML-KEM) moved to the release gate, #222: the 1.1.0 release candidate's Guix builds are checked there.
Hybrid post-quantum v2 transport (#184) — integration (#233)