Skip to content

Prevent release builds from enabling PQC test backend controls #104

Closed

Description

@kiwidream

Summary

Production libbitcoinpqc builds correctly pin SHA-256 to the scalar backend, but that guarantee is conditional on SPX_PRODUCTION_BUILD=1. Setting SPX_ENABLE_TEST_BENCH_ENV_KNOBS=ON replaces the production define with runtime-selectable SHA backend controls, and the top-level qbit build does not reject that configuration for a release artifact.

No acceptance divergence has been demonstrated: the scalar, SHA-NI, ARM, and CommonCrypto backends are intended to implement the same SHA-2 function, and the repository has known-answer tests. This issue is release hardening so a packaging mistake cannot expand the consensus-critical runtime surface.

Verified on

origin/1.0.0 at 988756471aeecdf4463c04be49da2b7b89a98c21.

Source trace

Scope correction: WOTS+C counter

The audit also noted that verification permits counters through 0xffff while signing uses BITCOINPQC_WOTSC_MAX_COUNTER. This is not an active verification mismatch:

  • the configurable value is an operational signing cap used while signing statistics are active;
  • verification intentionally accepts the full 16-bit protocol range; and
  • compilation rejects a configured signer cap greater than 0xffff.

See src/libbitcoinpqc/sphincsplus/ref/wots.c#L104-L145 and src/libbitcoinpqc/sphincsplus/ref/sign_stats.h#L8-L26. A deliberately lower signer cap may prevent the local signer from producing some signatures, but it does not cause nodes to reject an otherwise valid protocol signature.

That behavior should be documented, but it does not need to be coupled to the release-backend guard.

Expected behavior

Official and package/release qbit builds should fail configuration if consensus-critical PQC test/benchmark runtime controls are enabled.

Recommended changes

  • Add a top-level release/package guard that rejects SPX_ENABLE_TEST_BENCH_ENV_KNOBS=ON unless an explicit developer-only build mode is selected.
  • Add CI checks for every release artifact that prove SPX_PRODUCTION_BUILD=1 and the runtime knob macro is absent.
  • Keep backend differential known-answer tests in CI on every supported architecture.
  • Consider a small startup known-answer test for the exact verification entry point used by qbit. If adopted, fail closed before networking or chainstate activation and keep the vector stable and inexpensive.
  • Document that BITCOINPQC_WOTSC_MAX_COUNTER is a signer resource cap, not the verifier's protocol maximum.

Acceptance criteria

  • A normal release/package configuration cannot enable PQC runtime backend environment knobs.
  • CI verifies the effective compile definitions of shipped libbitcoinpqc objects rather than relying only on option defaults.
  • Scalar and every supported accelerated backend continue to pass the same known-answer suite.
  • The distinct roles of the WOTS+C signer cap and 16-bit verification bound are documented.

Activity

  1. added
    enhancement
    on Jul 11, 2026
  2. kiwidream commented on Jul 12, 2026

    @kiwidream
    MemberAuthor

    Scope clarification for #104 and PR #107

    PR #107 completes the downstream qbit release-build guard: integrated builds reject SPX_ENABLE_TEST_BENCH_ENV_KNOBS=ON, enforce SPX_PRODUCTION_BUILD=1 on the effective bitcoinpqc target, cover direct option, stale-cache, and compiler-flag injection paths, pin the Guix configuration, and document the production policy and WOTS+C signing-cap distinction.

    The separate requirement to prove which accelerated SHA implementation actually executed is explicitly deferred to Qbit-Org/qbit-libbitcoinpqc#3. That upstream issue owns:

    • test-only introspection for the effective SHA-256 and SHA-512 implementations;
    • explicit failure or skip behavior when a requested accelerator falls back to scalar;
    • requested-versus-selected backend evidence in CI;
    • real x86 SHA-NI and macOS CommonCrypto coverage, without counting Windows scalar fallback as x86 coverage; and
    • ARM differential coverage only after ARM is enabled and exercised on a suitable runner.

    This deferral does not weaken qbit's production policy: official integrated builds remain pinned to the scalar production backend, while accelerator experiments and differential evidence stay in the standalone upstream library. With that scope split recorded here, merging PR #107 can close #104; the linked upstream issue remains the source of truth for the deferred accelerator-evidence work.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions