Skip to content

Review finding: v1.0.1 notes describe SHA-NI and CommonCrypto paths that qbit never uses #311

Closed

Description

@kiwidream

Summary

The performance figures and a known-limitation bullet describe SHA-NI and CommonCrypto backends that qbit never uses.

Severity: medium. Found in the 2026-11-04 review of the v1.0.1 change set (all 1.x.x merges since v1.0.0 plus the open PRs that target it), against 1.x.x 21fee6ee8e; area: #268, #181.

Observed

Confidence: confirmed (proven from code and the CI policy; the backend is corroborated by timing). The size of the scalar verify delta on aarch64 is not measured here.

  • Location: doc/release-notes-1.0.1.md:333-339 and :516-520 at review/pr-181 261d1b71eb (the subtree: import libbitcoinpqc v0.3.2 signer stack scrub #268 entry and the "depth of the libbitcoinpqc stack wipe" limitation). The mechanism is src/libbitcoinpqc/sphincsplus/ref/opt_flags.h:108-109 at 21fee6ee8e (#if defined(SPX_PRODUCTION_BUILD) return SPX_SHA_BACKEND_SCALAR;), plus sha2.c spx_sha256_select_hashblocks_impl/spx_sha512_select_hashblocks_impl, which return the _ref scalar functions when the mode is SCALAR. qbit forces SPX_PRODUCTION_BUILD=1 (cmake/libbitcoinpqc.cmake:58,64-65), and CI enforces it (.github/workflows/core-checks.yml:172-180). The upstream doc agrees: src/libbitcoinpqc/docs/runtime-crypto-env.md:15-18 says "Production mode pins SHA hashblock backend selection to the scalar implementation… cannot switch production builds to … x86 SHA-NI, or CommonCrypto".

  • Scenario: an operator or packager reads the notes and concludes three things, all wrong for qbit:

    1. Nodes on SHA-NI x86 see no verification change, while ARM and older x86 see about 6.5%.
    2. Apple-silicon performance is unmeasured "because it hashes through CommonCrypto".
    3. macOS stack scrubbing is weaker because "the library hashes through CommonCrypto, whose SHA context it does not wipe".

    In fact every qbit build, on every platform, verifies, signs and generates keys with the library's scalar SHA-256/512. The SHA-NI figure describes a code path qbit never runs. The CommonCrypto limitation and the PR release: prepare v1.0.1 #181 checklist item built on it ("macOS's CommonCrypto SHA context relies on the 16 KiB burn alone") are moot. On macOS the same scalar code and wipes run as on Linux; what is still unverified there is only the burn depth.

  • Evidence:

    • Code traced as above.

    • Timing measured on this host: 5 interleaved rounds pinned to one core on a shared, loaded machine (load average about 19–31). Medians:

      Build verify keygen sign
      qbit's own build/lib/libbitcoinpqc.a 2,504 µs 17.1 ms 229 ms
      standalone v0.3.2, production 2,501 µs 16.9 ms 224 ms
      standalone v0.3.0, production 2,548 µs 15.0 ms 202 ms
      v0.3.2 with test knobs, SPX_SHA_BACKEND=x86 (SHA-NI) 1,050 µs — —
    • qbit's library therefore runs at scalar speed: about 2.4× slower than SHA-NI. That pin predates v1.0.1 (it is already in v0.3.0) and is not a regression.

    • On this x86-64 host, scalar verification shows no measurable v0.3.0 → v0.3.2 change (within ±3% noise), so I could not reproduce the notes' "6.5% slower on scalar" figure either.

    • Keygen came out about 13–15% slower and signing about 11–14% slower, consistent with the notes.

Impact

Operator guidance on the cost of consensus verification is wrong, and so is the scope of a known limitation Mainnet has defaultAssumeValid = uint256{} (src/kernel/chainparams.cpp:183), so every IBD verifies every PQC signature. Any verify regression therefore applies to every node, not only to "non-SHA-NI" ones.

Suggested fix

  • Rewrite the subtree: import libbitcoinpqc v0.3.2 signer stack scrub #268 entry: "qbit's integrated build always uses the library's scalar SHA-256 (production mode), on every platform; verification is unchanged within measurement noise on x86-64 [and N% on aarch64, if measured with bench_qbit on an aarch64 Guix binary]; key generation is about 11–15% slower and signing about 11–18% slower."
  • Delete the CommonCrypto sentences and the CommonCrypto clause of the macOS limitation. Keep "burn depth unverified on macOS, Windows and ARM".
  • Optionally add a note that -assumevalid has no default on mainnet, so IBD verifies every signature.

Related: #181 (corrects text in its notes at 261d1b71eb).

Activity

  1. added
    documentation
    on Nov 4, 2026
  2. kiwidream commented on Nov 12, 2026

    @kiwidream
    MemberAuthor

    Fixed on 1.x.x by the v1.0.1 release notes in #181 (29c0ec9b6c):

    • The libbitcoinpqc v0.3.2 entry now says that qbit builds the library in production mode on every platform, so its x86 SHA-NI, ARMv8 SHA and Apple CommonCrypto backends are never used. Its figures are for production-mode builds: key generation about 11 to 15% slower, signing about 11 to 18%, and verification about 7 to 8% in a micro-benchmark.
    • The CommonCrypto clause is gone from the stack-wipe limitation, which keeps "depth unverified on macOS, Windows, and Linux on ARM, riscv64, and ppc64".

    The optional -assumevalid note was not added.

    Closing by hand, because a merge into 1.x.x does not close issues automatically.

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

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions