Skip to content

p2p: add hybrid post-quantum key exchange (ML-KEM-1024) to BIP324 v2 transport #184

Open
8 of 9 issues completed

Description

@djh58

Tracking issue. This is the implementation plan for hybrid post-quantum key exchange in qbit's BIP324 v2 transport. The work is split into nine sub-issues, "parts", listed under Work plan. Parts 1–8 are one pull request each, and part 9 is the release gate. The Design section is the shared contract: sub-issues refer to it rather than repeat it, and a pull request that needs to change it updates this issue first. The original proposal, which used ML-KEM-768, is in this issue's edit history.

Epic · Size XL · Base branch 1.x.x (part 2's small scheduler PR targets main) · Code references are to 1.x.x at 45e9e72c2d · Sibling: part 1, the I2P post-quantum leasesets

Goal

Make every v2 connection between two upgraded qbit nodes confidential against "record now, decrypt later" by a future quantum computer. Stay fully compatible with v1.0.0 nodes, and change no consensus code.

When this epic is done:

  1. Two upgraded nodes derive their v2 session keys from both the existing ECDH secret and an ML-KEM-1024 shared secret, prove the switch with a key-confirmation packet, and show it: getpeerinfo transport_pq, and 2p in -netinfo.
  2. Connections to v1.0.0 nodes, other legacy v2 peers and v1 peers work exactly as they do today.
  3. Repeated failures with one endpoint fall back to plain v2 in a bounded way, load shedding bounds what an inbound flood can cost, and operators can see all of it in getpqtransportinfo.
  4. The release gate has passed: fuzz campaign, flood measurement, outside review, 14-day mainnet canary, 7-day testnet4 soak and green CI. Release N, the first release with this work, ships the feature on by default.

Why

  • v2 transport is on by default (DEFAULT_V2_TRANSPORT{true}, src/net.h:96). It derives every session key from a single secp256k1 ECDH secret (BIP324Cipher::Initialize, src/bip324.cpp:34-71).
  • A passive observer can record v2 traffic today. With a cryptographically relevant quantum computer, they could later recover the ECDH secret from the two 64-byte ElligatorSwift keys sent at the start of each connection, and decrypt the recorded session.
  • What would leak is relay metadata: inv, tx and getdata timing and ordering, and addr gossip. That helps attribute transactions to the nodes that first relayed them, and helps map the network.
  • The symmetric layer (ChaCha20-Poly1305 with FSChaCha20 rekeying every 224 messages) is not the weak point; the key exchange is. Spend authorization (P2MR with SLH-DSA) is unaffected.

Scope

In scope:

  • the hybrid key exchange in the BIP324 v2 transport;
  • its configuration, telemetry, fallback and load shedding;
  • the ML-KEM library integration;
  • tests, CI, tooling and docs;
  • the release gate.

The I2P post-quantum leaseset change (part 1) is tracked here as a sibling but ships on its own, outside the release gate.

Not in scope:

  • Peer authentication, or protection against an active man-in-the-middle. BIP324 stays unauthenticated.
  • Pre-shared or out-of-band keys, and a "require PQ" option for pinned peers, which would need them.
  • Removing ECDH.
  • Any consensus, wallet, mempool or photon change.
  • Wire compatibility with Bitcoin nodes, which use a different network magic.
  • Hiding traffic shape. Hybrid sessions are distinguishable from legacy v2 by packet sizes, and the operator guide points censorship-sensitive users to Tor and I2P.
  • Transaction-origin privacy against spy peers.
  • A timer on the initiator's hold. -peertimeout already bounds it, and no qbit responder waits for the initiator's version packet.
  • Persisting the fallback set or hybrid successes across restarts.

Design

Overview

  • Hybrid, and ECDH stays. Session keys come from HKDF over both the BIP324 ECDH secret and an ML-KEM-1024 shared secret (FIPS 203, NIST category 5), so they stay confidential unless both break. ML-KEM-1024 costs about 6 µs and 864 bytes more per connection than ML-KEM-768.
  • No extra round trip.
    • The responder puts its ML-KEM encapsulation key in its BIP324 version packet.
    • The initiator holds its own version packet until the responder's arrives (they travel in the same TCP flight as today), and puts the ciphertext in it.
    • Both sides switch keys right after the version packets. Each side's first packet under the new keys is a 20-byte key confirmation.
  • Cost per hybrid connection:
    • 3,184 extra bytes: two 1,572-byte records and two 20-byte confirmations. The largest single burst stays below TCP's 14.6 KB initial window.
    • ML-KEM-1024 compute with native code: keygen 8.8 µs, encaps 9.7 µs, decaps 12.2 µs. Portable C takes 26–27 µs per operation. For comparison, today's ECDH costs 43.8 µs per side. (AMD Ryzen 9 9955HX, clang 21 -O3, medians of 20,000 runs.)
    • Per-message encryption is unchanged, so block relay is unaffected in normal operation.
  • Library: mlkem-native v2.0.0, vendored unmodified (part 3). Its C code is CBMC-proved memory-safe, and its x86_64 and AArch64 assembly is HOL-Light-proved correct and constant-time where it handles secret data. qbit uses native code with runtime detection on x86_64 (AVX2) and on macOS arm64, and portable C elsewhere, including AArch64 Linux: upstream's AArch64 assembly carries no BTI landing pads, and linking it would strip BTI/PAC hardening from the binary (part 3).
  • Code layout: the record parser and per-connection KEM state live in src/bip324_pq.{h,cpp} (PQHandshake), so V2Transport and BIP324Cipher gain only calls and upstream merges stay small.

Message flow

Initiator                                           Responder
ellswift_I ‖ garbage_I              ──────────►
                                    ◄──────────     ellswift_R ‖ garbage_R
                                    ◄──────────     terminator_R ‖ version_R{F0 ‖ ek}    then holds
terminator_I                        ──────────►
holds its version until version_R arrives
version_I{F0 ‖ ct}, ECDH keys       ──────────►
switch to hybrid keys                               decapsulate; switch to hybrid keys
confirmation, hybrid keys           ──────────►
                                    ◄──────────     confirmation, hybrid keys
application packets                 ◄─────────►     application packets
  • Neither side waits for the other's confirmation before sending. The receiver delivers application messages only after the peer's confirmation verifies.
  • Between sending its offer and processing the initiator's version packet, the responder sends nothing, decoys included.
  • With the switch off on either side, or toward a legacy peer, version contents are empty and today's ECDH keys stay in use.

Wire format

  • Version-packet contents are zero or more records CompactSize(len) ‖ header (1 byte) ‖ payload, where len ≥ 1 counts the header plus the payload. The shape follows the bitcoin-dev Transport Feature Negotiation draft.
  • Header registry. 0x00 is reserved. 0xF0 (PQ_MLKEM1024) is used for both the offer and the accept; the sender's role says which one a record is. qbit assigns its own header values from 0xF0 upward, far from the low values a Transport Feature Negotiation table would assign first.
  • The responder's offer is a 0xF0 record whose payload is the 1,568-byte encapsulation key (ek). It is sent only when the responder's switch is on.
  • The initiator's accept is a 0xF0 record whose payload is the 1,568-byte ciphertext (ct). It is sent only after a valid offer, with the initiator's switch on; otherwise the initiator sends empty contents.
Object Layout Bytes
Offer contents fd 21 06 f0 ‖ ek 1,572
Accept contents fd 21 06 f0 ‖ ct 1,572
Record length CompactSize 1,569 (header plus payload) fd 21 06
Encrypted version packet encrypted length 3 ‖ encrypted payload (header 00 ‖ contents) 1,573 ‖ tag 16 1,592
Encrypted confirmation encrypted length 3 (plaintext 00 00 00) ‖ encrypted header 1 (plaintext 80) ‖ tag 16 20
  • AAD. Both version packets travel under the ECDH keys. A sender's first packet authenticates its garbage as AAD, so if a decoy already consumed it, the version packet uses empty AAD. Confirmations always use empty AAD.

Parse rules

PQHandshake::ParseContents is noexcept and makes one pass over a non-owning SpanReader, keeping only the position of the first own record. The 4,000,013-byte contents limit bounds its work.

  1. The whole contents must parse as records. Empty contents, or a parse failure anywhere (truncation, a zero, non-canonical or oversized length, trailing bytes), mean "no features": the connection keeps today's behavior and is never dropped for it. This deliberately differs from the Transport Feature Negotiation draft, which disconnects on unparseable contents: BIP324 receivers ignore version contents today, and v1.0.0 relies on that.
  2. The first 0xF0 record wins. Later 0xF0 records and unknown headers are ignored, but the transcript still covers them.
  3. Only after the whole grammar validates is the first own record checked: ek must be 1,568 bytes and pass the FIPS 203 §7.2 modulus check, and ct must be 1,568 bytes. A malformed first own record disconnects (malformed_record, with reason ek_length, ek_modulus or ct_length).
  4. A corrupted ct of the right length can't be detected (ML-KEM's implicit rejection). The two sides derive different keys, and the key confirmation fails at once.

Key schedule

  • Retained secret. The initiator and responder keep the raw 32-byte BIP324 ECDH secret (ss_ECDH, the output of ComputeBIP324ECDHSecret) past Initialize, until the switch decision. It is wiped on every path.
  • Transcript. BIP324Cipher keeps a running CSHA256, so contents are never stored:
    TH = SHA256( ellswift_I (64) ‖ ellswift_R (64)
               ‖ CompactSize(len(contents_R)) ‖ contents_R
               ‖ CompactSize(len(contents_I)) ‖ contents_I )
    
    The contents are the full version-packet contents each side sent, responder first, including unknown and duplicate records. Packet framing, garbage, terminators, tags and confirmations are not hashed. For the ordinary one-record exchange the TH input is 3,278 bytes.
  • Derivation (HKDF-SHA256, RFC 5869):
    salt = ASCII("qbit_v2_hybrid_mlkem1024") ‖ network_magic     24 + 4 = 28 bytes, no NUL
    IKM  = ss_ECDH (32) ‖ ss_MLKEM (32) ‖ TH (32)                   96 bytes
    PRK  = HMAC-SHA256(key = salt, msg = IKM)
    initiator_L, initiator_P, responder_L, responder_P, session_id
         = HMAC-SHA256(PRK, ASCII(label) ‖ 01)                       32 bytes each
    
    The network magic is in wire order: mainnet 44 4f 24 a8, regtest a6 6b 1f da.
  • Switch. SwitchToHybrid re-emplaces all four FSChaCha20 and FSChaCha20Poly1305 objects with counters at 0, and replaces the session id. Garbage terminators are not re-derived. Later rekeys derive from the hybrid keys.
  • Recipe changes. Any recipe change takes a new header with its own salt label. A label-only change under the same header would let two adjacent releases both accept the offer, derive different keys and disconnect at the first hybrid packet.
  • Vectors. src/test/data/pq_transport_vectors.json holds the inputs and every intermediate value. An independent Python reference generates it (part 4).

Key confirmation

Right after switching, each side's first packet under the hybrid keys is an empty decoy, 20 bytes on the wire, sent with Encrypt({}, {}, ignore=true). It consumes hybrid packet index 0 in each direction.

The receiver requires all of the following, and otherwise disconnects at once with first_packet_failed:

  • the decrypted length is 0, checked as soon as the 3 length bytes arrive (reason length);
  • the tag verifies (reason tag);
  • the ignore bit is set (reason not_decoy).

Without this check, a key mismatch decrypts to a random length, and about 24% of the time the receiver would wait for bytes that never arrive until the 60 s handshake timeout. transport_pq, the hybrid status and the hybrid session id are reported only after the peer's confirmation verifies; until then the status is pending.

Fallback after repeated failures (part 5)

  • Counted failures, outbound only, per endpoint:

    • malformed_record;
    • first_packet_failed;
    • closed_after_switch: after we switched and before the peer's confirmation verified, the peer closed the connection (eof, reset) or the handshake timed out (timeout).

    Our own disconnects (operator, shutdown, network off, eviction, feelers) and send errors never count. Legacy outcomes are neutral. Only a confirmed hybrid success clears a streak.

  • Entering fallback. An endpoint enters the fallback set after 3 consecutive counted failures, and never if it completed a hybrid handshake since startup. A single failure is telemetry only.

  • Windows escalate per endpoint: 1 h, then 4 h, then 24 h. At expiry the streak resets and the escalation level stays.

  • Policy. While an endpoint is in the set, outbound connections to it run plain v2 and neither parse nor validate the offer. An existing connection never renegotiates. Inbound connections never fall back.

  • Bounds. Memory only, cleared on restart. The failure history holds at most 1,000 endpoints, evicting the oldest. Endpoints with a confirmed success live in a separate set that is never evicted.

  • Endpoint key. A resolved destination is its CService (address and port). A name-proxy destination is its normalized hostname and port. Inbound uses the remote address and source port.

  • Visibility. Entering fallback logs one warning, v2 pq: fallback cause=<trigger> until=<UTC time>. If 8 or more distinct endpoints have counted failures and none has succeeded since startup, the node warns once that its own ML-KEM code may be at fault, naming -mlkemportable when native code is active.

Load shedding (part 5)

  • When more than threshold_per_s inbound offers were attempted in the last second, responders stop offering: they send empty contents, exactly today's v2. The peer's status is off, and the inbound shed counter increments.
  • Offering resumes after 10 consecutive seconds below half the threshold.
  • Outbound connections are never affected.
  • The threshold defaults to 1,000 offers per second, which caps the extra key-generation CPU at about 3% of one core even in portable C. The flood measurement in the release gate (part 9) sets the final value.
  • Starting and stopping each log one info line: v2 pq: load_shedding started threshold_per_s=<n> and v2 pq: load_shedding stopped.

Configuration (part 6)

Option Behavior
-v2pqtransport Default 0 until the default-on PR in part 9, then 1 from release N. No effect when -v2transport=0; an explicit -v2pqtransport=1 in that case raises an InitWarning naming the fix. Booleans must be numeric (true parses as 0), and a non-numeric value raises an InitWarning.
-mlkemportable Hidden, debug category, all chains. Forces portable C: the field escape hatch if native code misbehaves on some CPU family.
-test=pq_fail_first_packet Regtest only. Corrupts this node's ML-KEM shared secret on every hybrid handshake, so the peer's confirmation check fails.
-test=mlkem_portable Regtest only. Forces portable C.
WITH_MLKEM_NATIVE=AUTO|ON|OFF CMake. OFF builds portable only; ON makes missing native support a configure error.

The startup line always names the active backends:

v2 pq: enabled arith=<x86_64-avx2|aarch64-neon|portable> keccak=<x86_64-avx2|aarch64|portable>
v2 pq: disabled (-v2pqtransport=0) arith=… keccak=…
v2 pq: disabled (-v2transport=0) arith=… keccak=…

RPC (part 6)

  • getpeerinfo gains:

    • transport_pq: true once the peer's confirmation verified;
    • transport_pq_status: one of pending, hybrid, legacy_peer, fallback, off or v1.

    transport_protocol_type keeps its values. session_id is the hybrid session id when transport_pq is true.

  • getnetworkinfo gains connections_pq, counted over the same peers getpeerinfo lists.

  • New getpqtransportinfo. All fields are always present, and empty collections are []:

type Endpoint = { kind: "address" | "name_proxy";
                  network: "ipv4" | "ipv6" | "onion" | "i2p" | "cjdns" | "name_proxy";
                  address: string;            // canonical address or normalized hostname, no port
                  port: uint16 };
type DirectionCounts = { switched: uint64; legacy_peer: uint64; malformed_record: uint64;
                         first_packet_failed: uint64; abandoned: uint64; internal_error: uint64 };
type Failure = { sequence: uint64; time: int64; endpoint: Endpoint;
                 direction: "inbound" | "outbound";
                 connection_type: string;       // existing ConnectionTypeAsString tokens
                 peer_id: int64;
                 outcome: "legacy_peer" | "malformed_record" | "first_packet_failed" | "abandoned"
                        | "closed_after_switch" | "fallback" | "internal_error";
                 reason: string };              // fixed vocabulary below
type Ring = { last_sequence: uint64; dropped: uint64; entries: Failure[] };   // oldest first, max 256

type GetPQTransportInfo = {
  enabled: boolean;
  status: "enabled" | "disabled_v2pqtransport" | "disabled_v2transport";
  instance_id: string;                          // 64 lowercase hex, random per process start
  arith_backend: "x86_64-avx2" | "aarch64-neon" | "portable";
  keccak_backend: "x86_64-avx2" | "aarch64" | "portable";
  since: int64;                                 // startup time; counters count from here
  handshakes: {
    inbound: DirectionCounts & { shed: uint64 };
    outbound: DirectionCounts & { closed_after_switch: uint64; fallback: uint64 };
  };
  load_shedding: { active: boolean; threshold_per_s: uint64; since: int64 };   // since = 0 when inactive
  fallback_set: { endpoint: Endpoint;
                  cause: "malformed_record" | "first_packet_failed" | "closed_after_switch";
                  reason: string; streak: uint32; entered: int64; expires: int64;
                  window_seconds: 3600 | 14400 | 86400 }[];
  failure_streaks: { endpoint: Endpoint;
                     cause: "malformed_record" | "first_packet_failed" | "closed_after_switch";
                     reason: string; streak: uint32;  // 1 or 2
                     last_failure: int64; next_window_seconds: 3600 | 14400 | 86400 }[];
  recent_failures: { inbound: Ring; outbound: Ring };  // outbound includes manual connections
};

Reason vocabulary (fixed):

legacy_peer:          no_features | parse_error
malformed_record:     ek_length | ek_modulus | ct_length
first_packet_failed:  length | tag | not_decoy
closed_after_switch:  eof | reset | timeout
abandoned:            eof | reset | timeout | send_error | local | garbage_terminator | version_length | version_tag
fallback:             malformed_record | first_packet_failed | closed_after_switch
internal_error:       keygen | check_public_key | encaps | decaps | cipher_state

Counter semantics. Counters count events, not exclusive outcomes:

  • switched counts key installations, even if confirmation later fails;
  • fallback counts entries into the set, not plain-v2 connections;
  • abandoned counts offers whose initiator sent no authenticated version before the connection closed;
  • each ring has its own sequence, and reports how many entries it dropped.

-netinfo shows 2p for hybrid peers, and treats a server without transport_pq (v1.0.0) as not hybrid. The GUI peer details read "v2 (hybrid post-quantum)".

Logging

Each outcome logs one line. Every line has the prefix v2 pq:, and the outcome word is the counter key, so one search finds them all. Fields come from a fixed list and never contain bytes the peer controls: reason, cause, until, role, conn_type, peer, and peeraddr only with -logips. Failure lines also carry arith and keccak.

Line Level
switched, legacy_peer, every inbound outcome, abandoned net debug
Outbound malformed_record, first_packet_failed, closed_after_switch, internal_error info, each from its own call site
load_shedding started / stopped info
fallback, the local-fault warning warning

Inbound and outbound lines come from separate call sites, because the logger rate-limits per call site; inbound noise can't silence outbound evidence. Exact counts and per-endpoint attribution come from getpqtransportinfo, not from logs.

Failure handling and secrets

  • Internal ML-KEM errors not caused by peer input never assert:

    • a responder that can't generate a key sends no offer;
    • an initiator that can't check the key or encapsulate continues as if its switch were off for that connection;
    • a responder whose decapsulation fails internally closes the connection (internal_error/decaps), because the initiator has already committed to the hybrid keys.

    Each is counted as internal_error.

  • Entropy. Key generation draws two independent 32-byte GetStrongRandBytes values, and encapsulation draws one: ProcRand asserts at most 32 bytes per call.

  • Wiping. The decapsulation key, the retained ECDH secret, ML-KEM temporaries and derived keys are wiped with memory_cleanse on switch, legacy outcome, disconnect and timeout, and in destructors.

  • Memory. A pending inbound connection holds about 3.3 KB: the 3,168-byte expanded decapsulation key, the 32-byte ECDH secret and about 100 bytes of transcript state. That is about 420 KB at 125 connections, and only until the initiator's version packet or -peertimeout. Key generation is lazy: it happens only after the initiator's full 64-byte key arrives.

Compatibility

  • v1.0.0 and other legacy v2 nodes ignore version contents. v1.0.0 was verified to accept contents up to 4,000,013 bytes, with decoys first and after a 10 s delay, in both roles (part 2 pins this). Upgraded ↔ legacy connections keep ECDH-only keys, with no disconnect and no extra round trip.
  • v1 peers, and the v1 retry, are unchanged.
  • Switch off on either side is byte for byte today's behavior: no hold state, and empty version packets.
  • Mixed-version tooling. A new qbit-cli -netinfo against a v1.0.0 node shows 2 without errors.
  • The initiator's hold. A hybrid initiator sends its version packet only after the responder's arrives. That is the order BIP324's version-negotiation steps list; deployed BIP324 initiators instead use the option to send it right after their garbage terminator. BIP324's progress conditions still hold: the initiator still sends its terminator at once and enters version negotiation, and every responder, legacy or hybrid, sends its version packet without waiting for the initiator's. The spec makes that a MUST for responders. Only qbit initiators behave differently, never responders.

Testing and CI

Layer What Where
KEM primitive NIST ACVP and C2SP CCTV vectors, implicit rejection, backend equality, build policy parts 2, 3
Key recipe JSON vectors from an independent Python reference; transcript binding; rekey boundaries part 4
Parser grammar, first-wins, semantics, maximum contents; pq_records fuzz target part 4
State machine both roles, the legacy matrix, v1 detection, send hold, switch boundary, the three confirmation failures, corrupted ct, internal errors, rekeys part 4
Telemetry and fallback close causes, once-only counting, rings, endpoint identity, threshold, windows, success protection, eviction, local-fault warning, shedding part 5
Operator surface options, warnings, startup line, exact RPC dictionaries, -netinfo, rpc fuzz safe list part 6
End to end Python hybrid peer both ways; misbehaving peers; fallback; the whole functional suite with PQ on part 7
Adversarial mlkem, mlkem_backend_diff, pq_records, p2p_v2_pq_malicious_peer, the extended bip324_cipher_roundtrip and v2 transport targets parts 3, 4
Interop v1.0.0 in both roles; mixed-version CLI parts 2, 6
Performance per-backend benchmarks; handshake benchmark (also in a VM); flood lab parts 3, 8, 9
Docs quick-start test; doc string check part 8

CI jobs.

  • ci-pq.yml is one reusable workflow with a recorded source SHA and a jobs input (part 2). Its jobs:
    • aarch64-unit (part 2);
    • s390x-unit and macos-arm64-unit (part 3);
    • pq-functional, the whole suite with --v2pqtransport (part 7).
  • The aarch64 job is required for pull requests that touch the library or transport (part 3).
  • main runs separate nightly callers for [email protected] and [email protected], each with its own status (part 2, on main).
  • The v1.0.0 interop tests run in the existing previous-releases job.
  • MSan builds use portable C only, because MSan can't see writes made by assembly.

Work plan

Parts

Nine sub-issues. Parts 1–8 are one pull request each, and part 9 is the release gate. Inside a part, work items keep short IDs (for example E3) as section headings and commits; cross-references use them.

Part Sub-issue Work items Merges after Can start
1 #185 I2P post-quantum leasesets A1 — now; ships on its own
2 #186 Foundations B1, B2, B3, C1, C5, C4 — now
3 #190 ML-KEM library D1, D2, C2, D3, D5, C3, D4 part 2 now; stack on part 2 until it merges
4 #199 Handshake core E1, E2, E3, G4, H2 part 3 E1 and H2 now; E2 against part 3's API
5 #206 Telemetry and safety F1, F2, F3, F4 part 4 F1 now
6 #209 Operator surface F5, F6 part 5 F5 once part 4 merges
7 #212 End-to-end tests G1, G2, G3 part 6 the Python hybrid peer once part 4 merges
8 #215 Flood tool and operator docs H1, H3 part 6 v2flood once part 4 merges
9 #222 Release gate R0–R7 part 7, part 8 R0 once part 2 merges; R4 once parts 3 and 4 are up
flowchart LR
  P1["1 · I2P post-quantum leasesets"]:::p
  P2["2 · Foundations"]:::p
  P3["3 · ML-KEM library"]:::p
  P4["4 · Handshake core"]:::p
  P5["5 · Telemetry and safety"]:::p
  P6["6 · Operator surface"]:::p
  P7["7 · End-to-end tests"]:::p
  P8["8 · Flood tool and operator docs"]:::p
  P9["9 · Release gate"]:::g
  P2 --> P3
  P3 --> P4
  P4 --> P5
  P5 --> P6
  P6 --> P7
  P6 --> P8
  P7 --> P9
  P8 --> P9
  P2 -. "R0 baseline starts" .-> P9
  P4 -. "R4 review starts" .-> P9
  classDef p fill:#e0e7ff,stroke:#555,color:#111
  classDef g fill:#dcfce7,stroke:#555,color:#111
Loading

Solid arrows are merge order, and each is a GitHub "blocked by" link. Dotted arrows are release-gate items that start early. Part 1 has no arrows: it ships on its own.

Critical path and parallel work

  • Critical path: parts 2 → 3 → 4 → 5 → 6 → 7 → 9, where part 9 is the default-on PR, the 14-day canary and the release decision.
  • At the start, up to five lanes: part 1; part 2; part 3 (stacked on part 2's branch until it merges); F1 from part 5; and E1 and H2 from part 4.
  • During implementation: R0's 14-day baseline runs, and R4's outside review starts on the spec and the library.
  • After part 4 merges: F5, the Python hybrid peer and v2flood can be drafted alongside part 5.

Conventions for implementers

  • Branch from 1.x.x, and target 1.x.x. The exception is part 2's nightly-scheduler PR (C4), which targets main.
  • One pull request per part. Its body says Closes #<part> and Part of #184, and its commits follow the part's work items in the order listed there.
  • Each commit builds and passes the unit and functional tests (the per-commit CI check, .github/ci-test-each-commit-exec.py). New tests land in the same commit as the behavior they test.
  • The Design section above is the contract. A pull request that needs to change it updates this issue first, then the affected parts.
  • Node behavior doesn't change until part 6 adds the option (default off) and the default-on PR in part 9 turns it on, so every merge leaves 1.x.x releasable.
  • Code references are to 1.x.x at 45e9e72c2d. Line numbers drift, so search by symbol.
  • Option names, RPC fields and log strings are exact. Part 8's doc check enforces them.
  • The 29 earlier fine-grained sub-issues were consolidated into these nine and closed; each closed issue points to its part.

Release gate and rollout

Every step below is a checklist item in part 9 (#222).

  1. Release candidate. Parts 1–8 are merged, the default-on PR (R1) turns the feature on just before the cut, and a Guix-built release candidate follows. The release notes say exactly what it protects and how to switch it off.
  2. Before the canary:
    • the fuzz campaign (R2): seven targets × three sanitizer configurations × 24 CPU-hours;
    • the flood measurement (R3);
    • 14 days of baseline (R0);
    • a check that the census and crawler tools handle non-empty version contents (R0).
  3. Canary (R5). Two team mainnet nodes, an archive node and a pool node pinned to it, run the release candidate for 14 days. A third team archive node stays on v1.0.0 as the control. Clean means:
    • no crash;
    • the pinned link is manual and hybrid in at least 99% of 5-minute samples;
    • no malformed_record, first_packet_failed or fallback entry between known-good endpoints;
    • inbound connections hold within ±20% of the control.
  4. Alongside the canary: the scoped outside review (R4) and the 7-day testnet4 soak across x86_64 with AVX2, x86-64 without AVX2, Raspberry Pi 4, Apple Silicon and Windows (R6).
  5. Release cut (R7). If every gate item holds, release N ships on by default. If any is open or raised a concern, R1 is reverted, release N ships switched off, and a point release turns it on once the item is resolved. Every operator can switch it off with -v2pqtransport=0, which never disconnects anyone. v1.0.0 nodes keep working with ECDH-only keys indefinitely.

A wire, key-recipe or state-machine change after the canary starts restarts the canary, the soak and the flood measurement on the changed code.

After release N: a weekly probe from a default-config, non-listening mainnet node records the share of its outbound full-relay connections with transport_pq=true.

Convergence policy

  • Track bitcoin-dev, bitcoin/bips and upstream transport changes, such as bitcoin/bitcoin#36376 (rare BIP324 decoys). The rule against decoys before the initiator's version packet binds only qbit's offering responders, so upstream decoys from legacy peers stay compatible.
  • If a Bitcoin standard for PQ transport ships, qbit implements it as a new header. At most two PQ recipes are supported at once.
  • qbit's 0xF0 recipe stays for at least two major releases after that standard ships. The release before its removal announces it in its release notes, and warns at startup while 0xF0 connections are still in use.
  • While two recipes exist, getpeerinfo reports which one each hybrid peer uses.

Definition of done

  • Parts 1–8 are merged: into 1.1.0, done with Hybrid post-quantum v2 transport (#184) — integration #233 (db8dbe5); and part 2's scheduler PR (C4) into main, not yet opened.
  • The spec, operator guide and release note are published, and the spec is posted to bitcoin-dev (part 4).
  • Part 9's release decision (R7) is posted, and release N has shipped: on by default, or off with the point-release follow-up filed.

References

Sub-issues

Sub-issues

8 of 9 Issues completed
Loading 9 sub-issues

Activity

  1. added
    enhancement
    on Sep 30, 2026
  2. 135 remaining items

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

    enhancementpq-transport

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions