Files
BackOne/docs/two-host-pq-manual-test.md
T
proitlab 2e2b0910a8
build.yml / build_ubuntu (push) Canceled after 0s
build.yml / build_macos (push) Canceled after 0s
build.yml / build_windows (push) Canceled after 0s
Lint / clang-format (push) Canceled after 0s
validate.yml / build_ubuntu (push) Canceled after 0s
pqconly: enforce PQ peers, including on the config-serve path
`pqconly` selected a type-1 identity and then behaved exactly like
`hybrid` at runtime: every handshake gate tested only
`pqcMode() != CLASSIC`, so nothing distinguished the two modes and no
non-capable peer was ever refused. Measured on the two-host lab, a
`pqconly` node carried traffic with a fully classical peer at 0% loss.

Add `Peer::pqconlyPeerRejected()` - true when this node is exactly
`pqconly`, the peer did not advertise the HELLO capability bit, and its
role is not PLANET/MOON (all four Earth roots are `pqcCapable:false` and
enforcing against them would cut the node off the root topology).

Three verbs are gated, and the third is load-bearing. The first
implementation gated only `VERB_NETWORK_CONFIG` and
`VERB_NETWORK_CREDENTIALS` and still let the classical peer join at 0%
loss, because membership is granted by the *serve* direction: a classic
peer asks the pqconly node's controller for its config, and the node
enforcing the policy was the one handing it over. Gating
`VERB_NETWORK_CONFIG_REQUEST` before the controller is consulted closes
it. The rejection counter had been incrementing in the unrelated
direction throughout, which is what made the false assurance possible.

`hybrid` keeps its silent classical fallback - that is its contract - but
now logs a downgrade WARNING once per peer, re-armed on recovery, so a
downgraded link is no longer invisible.

The gate keys on `_hybridCapable`, not `hybridSessionKeyInstalled()`:
the encapsulating peer stages its hybrid key until the confirm tag
arrives, so gating on the installed key would reject a healthy PQ peer
for the entire staging window.

Measured 2026-10-08, two-host lab, clean rebuild, selftest exit 0:
- `pqconly` vs classical: network now sits at REQUESTING_CONFIGURATION
  with assignedAddresses [] and 100% loss, down from OK at 0% loss.
- `pqconly` vs `pqconly`: 0% loss both directions, no false rejection.
2026-10-08 10:33:12 +00:00

19 KiB
Raw Blame History

Two-Host Post-Quantum Test — Manual Runbook

Human-redo of the two-machine BackOne PQ test. For this host + 192.168.122.85 over real NICs, real TUN/TAP, and systemd. The hermetic netns lab lives in pqc-test-scenario.md §4–§5 (tools/pqc-lab.sh) and is not repeated here — it proves the handshake on synthetic interfaces; this doc proves it end to end on real machines, and adds the membership half that the netns lab never exercised.

Verified live 2026-10-07 on BackOne 2.0.2. Every command below was run as written.


0. Roles and the one rule that makes this work

Host Address Role local.conf settings
HOST1 this machine (192.168.122.x) controller — owns the network {"settings":{"pqcMode":"hybrid"}}
HOST2 192.168.122.85 member — joins HOST1's network {"settings":{"pqcMode":"hybrid","disableController":true}}

The rule: exactly one host runs a controller. Setting disableController: true on HOST2 is not optional. Without it, both nodes answer their own NETWORK_CONFIG_REQUESTs and self-sign a local config, so they never contact each other and you get ACCESS_DENIED with an empty peer list — a symptom indistinguishable from the B6 bug. See §7.

disableController defaults to false, so a fresh install still runs a controller. That default is why this step is easy to miss.


1. Prerequisites

Both hosts need:

  • BackOne built at 2.0.2 or later (the three fixes in §7 are required).
  • curl, python3 (for the JSON checks), ping.
  • ROOT: tshark for dissection, tcpdump for capture.
  • Network: HOST1 and HOST2 must reach each other on UDP 9993 directly. Verify first — if UDP is blocked, you will be debugging a relay path instead of PQ:
# run on HOST1, HOST2's IP substituted
nc -zu -w2 192.168.122.85 9993    # or: ping -c2 192.168.122.85

Confirm the UDP path exists before starting. §4's absolute gate requires a DIRECT path.


2. Step 0 — confirm which binary each host runs

Do this before anything else. A repo build and a root-installed /usr/sbin/backone are different binaries, and "the fix didn't work" is almost always this mismatch.

# on each host
/usr/sbin/backone -v          # installed package build
./backone -v                  # repo build, if run from a source tree
sudo -n ls -la /var/lib/backone/backone   # symlink → which binary the service uses
systemctl status backone --no-pager | head -20

Record for each host: version string, and whether the service runs the package binary or a repo build. The live test used a repo build deployed over the system install.

If you change the binary, systemctl restart backone. A stale running process keeps the old code in memory regardless of what is on disk.


3. Reset state (destructive, per run)

This wipes identity and network membership on both hosts:

# on EACH host
sudo systemctl stop backone
sudo rm -f  /var/lib/backone/identity.secret \
           /var/lib/backone/identity.public \
           /var/lib/backone/identity.public.bak \
           /var/lib/backone/identity.secret.bak
sudo rm -rf /var/lib/backone/networks.d
sudo systemctl start backone

controller.db is deliberately kept. It holds the network definition and the member roster; wiping it would throw away the network you are about to test.

But kept ≠ untouched. After an identity wipe, every member row still carries the old address. The controller compares the new identity against that stale row and denies access — the B6 failure mode. §5 re-enrolls every member, which is what clears the stale field. Skipping re-enrollment is the single most common reason a redo fails.

BackOne regenerates a fresh identity on next start. Its address (and identity size) depends on pqcMode — see §4.


4. Configure the mode and verify the identity

local.conf lives at /var/lib/backone/local.conf. Write it before starting the daemon — the mode is read at startup.

HOST1 (controller):

{
  "settings": {
    "pqcMode": "hybrid"
  }
}

HOST2 (member):

{
  "settings": {
    "pqcMode": "hybrid",
    "disableController": true
  }
}

Restart and verify the identity type — this is the first and cheapest check:

sudo systemctl restart backone
stat -c '%s' /var/lib/backone/identity.public
pqcMode identity size first byte
absent / off 141 B 0 (classic)
hybrid 6415 B 1 (type 1, PQ)
pqconly 6415 B 1 — enforces PQ on network membership, see below

hybrid vs pqconly. Both write the same PQ material and both reach pqcHybridActive: true against a PQ peer. They differ only in what happens to a peer that cannot do PQ: hybrid falls back to classical and logs a one-time WARNING; pqconly refuses that peer's network config and credentials, so the network never comes up over an unprotected link (PLANET/MOON roots are exempt — they are pqcCapable:false and always will be). pqconly was previously indistinguishable from hybrid and enforced nothing; see pqconly-mode-test.md for the measurement and the reproduction steps.

identity.public is a colon-delimited text file (address:type:flags:...), so od on it reads ASCII, not the type byte. Field 2 is the type:

cut -d: -f2 /var/lib/backone/identity.public    # expect 1 under hybrid
/usr/sbin/backone-idtool validate /var/lib/backone/identity.public

If a classic 141 B identity is present while pqcMode: hybrid is configured, the daemon refuses to start by design (classic↔PQ mismatch). Wipe per §3 and restart.


5. Create the network and enroll HOST2 (on HOST1)

HOST1 is the controller, so all controller API calls happen here.

A=$(sudo -n cat /var/lib/backone/authtoken.secret)

5a. Create the network

curl -s -X POST -H "X-ZT1-Auth: $A" -H 'Content-Type: application/json' \
  -d '{"name":"pq-manual","private":true,"ipAssignmentPools":[{"ipRangeStart":"10.97.0.1","ipRangeEnd":"10.97.0.254"}]}' \
  http://127.0.0.1:9993/controller/network | python3 -m json.tool

Write down the id (the nwid). It is used in every call below.

5b. Authorize HOST2's identity

Read HOST2's address over SSH — it changed when you wiped the identity in §3. identity.public is a colon-delimited text file, field 1 being the address (address:revision:flags:privkey:pubkey...), not a binary blob. Extract with cut, never with a byte offset:

HOST2_ADDR=$(ssh 192.168.122.85 "cut -d: -f1 /var/lib/backone/identity.public")
echo "$HOST2_ADDR"    # 10 hex chars

Cross-check against the authoritative source, which derives the address from the private key rather than reading the cached public file:

ssh 192.168.122.85 "sudo -n /usr/sbin/backone-idtool getpublic /var/lib/backone/identity.secret | cut -d: -f1"

Then authorize it. authorized: true is the field the API reads (EmbeddedNetworkController.cpp:1175):

NWID=<paste-nwid-here>
curl -s -X POST -H "X-ZT1-Auth: $A" -H 'Content-Type: application/json' \
  -d '{"authorized":true}' \
  http://127.0.0.1:9993/controller/network/$NWID/member/$HOST2_ADDR

Repeat §5b for every member you wiped in §3 — including HOST2 in the classical run below.

5c. Have HOST2 join

ssh 192.168.122.85 "/usr/sbin/backone-cli -p9993 -D/var/lib/backone join $NWID"

Expected: 200 join OK (again — the leading number is an HTTP status, not a count).


6. Assertions

Two layers, both required. §6.1 is the pass/fail gate; §6.2 is what actually proves PQ.

6.1 Absolute gate — does the network work at all?

A=$(sudo -n cat /var/lib/backone/authtoken.secret)
curl -s -m 8 -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/network/$NWID \
  | python3 -c "import json,sys; d=json.load(sys.stdin); print('status:',d.get('status'),'peers:',len(d.get('peers',[])))"
Observable Required
status OK — not ACCESS_DENIED
peers non-empty
peer role / path LEAF / DIRECT, address 192.168.122.85/9993
/usr/sbin/backone-cli -p9993 -D/var/lib/backone peers

The first line reads 200 peers. That is the HTTP status code, not a peer count — a very common misreading. The real table is printed beneath it.

Data plane, both directions. Read each host's assigned address first — the IPs below are from the verified 2.0.2 run, and a re-created network assigns new ones:

# on HOST1 (assigned 10.97.0.13) → ping HOST2 (assigned 10.97.0.52)
ping -c 5 -W 3 10.97.0.52

# on HOST2 → ping HOST1
ssh 192.168.122.85 'ping -c 5 -W 3 10.97.0.13'

Both must report 0% packet loss. Do not assume the addresses — query them:

A=$(sudo -n cat /var/lib/backone/authtoken.secret)
curl -s -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/network/$NWID \
  | python3 -c "import json,sys; d=json.load(sys.stdin); print(d['id'], d['status'], d.get('assignedAddresses'))"

6.2 Comparative gate — is PQ genuinely active?

Run the same checks in both modes and compare. An absolute check alone proves nothing about PQ: status: OK and 0% loss pass identically on a build with all PQ code deleted.

# per peer, on each host
curl -s -m 8 -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/peer | python3 -c "
import json,sys
for p in json.load(sys.stdin):
    if p.get('role') != 'PLANET':
        print(p['address'], 'capable=', p.get('pqcCapable'), 'hybrid=', p.get('pqcHybridActive'))"
Observable classical (off) hybrid — must differ
identity.public size 141 B 6415 B
identity type byte 0 1
pqcCapable false true
pqcHybridActive false true
zt.hello.cap 0 1
zt.hello.idtype in HELLO 0 0 — see note
VERB_PQ_KEYS frames on wire absent present
HELLO size / fragments 185 B / 1 185 B / 1 — unchanged

HELLO does not grow in PQ mode, and that is correct. HELLO carries only the classic projection of the identity (Peer.cpp:527 calls Identity::serializeClassic), deliberately: a type-1 identity is 6415 B and would blow the fragment budget, which is also why the controller must compare classic material (the B6 fix). The capability bit in the HELLO revision field and the PQ keys in VERB_PQ_KEYS are what signal hybrid. Do not expect a large or fragmented HELLO — if you see one, something else is wrong.

The identity file is 6415 B because it holds the full type-1 record (ML-KEM-768 + ML-DSA-65 public keys); the HELLO packet is not.

6.3 Data-channel gate — proving the data key is PQ-derived

§6.2 proves the handshake advertises and exchanges PQ material. It does not prove the session key protecting your frames came from it. Those are different claims, and the gap matters: pqcHybridActive is the closest thing to a direct answer, but read what it actually reports.

A=$(sudo -n cat /var/lib/backone/authtoken.secret)
curl -s -m 8 -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/peer | python3 -c "
import json,sys
for p in json.load(sys.stdin):
    if p.get('role') != 'PLANET':
        print(p['address'], 'capable=', p.get('pqcCapable'), 'hybrid=', p.get('pqcHybridActive'))"
Field What it actually means
pqcCapable Peer set the capability bit. Advertised support only.
pqcHybridActive Peer::hybridSessionKeyInstalled() — the derived key is installed into _key, the buffer every data frame is armored with.

pqcHybridActive: true is a genuine assertion about the data channel, and it is deliberately stricter than "eligible": the code comment at node/Peer.hpp:710 says eligibility "is true a full round trip before the key exists, so reporting it as 'hybrid active' claims protection that is not in use."

Why tcpdump/tshark cannot answer this directly. Data frames are armored with the session key (Peer.cpp:645), so the payload — and the verb byte — is ciphertext. No filter can distinguish a PQ-derived key from a classical one, because that property is not visible in the output of a cipher. Any "the data frames look post-quantum" check is vacuous.

The one wire artifact that does bear on it. Peer::pqConfirmTag (node/Peer.hpp:67) is HMAC-SHA384(installed session key, min(addr) ‖ max(addr)) truncated to ZT_PQ_KEYS_CONFIRM_LEN = 4 bytes, appended last in VERB_PQ_KEYS so its position is unambiguous. Recomputing it offline under a candidate key and comparing proves which key both peers derived — but it is a verifier requiring the session key, not a passive observation, so it must be run on one of the hosts. Treat it as a lab tool for the key-confirmation path (IncomingPacket.cpp:1613), not as a routine capture check.


7. Capture and dissection

Capture on HOST1, udp port 9993:

sudo tcpdump -i any -s 0 -w /tmp/pq.pcap 'udp port 9993' &
CAP=$!

Reproduce the handshake (restart HOST2's service to force a fresh HELLO), then:

kill $CAP

Dissect with the repo dissector (tools/zt-dissector.lua):

tshark -X lua_script:tools/zt-dissector.lua -r /tmp/pq.pcap \
  -Y 'zt.verb == 1'                 # VERB_HELLO (Packet.hpp:617)
Filter Shows
zt any BackOne frame
zt.verb only on unencrypted frames — absent on encrypted ones
zt.verb == 1 HELLO only (Packet.hpp:617)
zt.hello.cap capability bit — 0 classical, 1 hybrid
zt.hello.idtype identity type in HELLO — 0 even in hybrid (classic projection only)
zt.hello.idsize serialized classic identity size (39 B)
zt.flags cipher suite in bits 3-5; 0x80 is the pre-1.0.3 legacy bit
zt.frag / zt.fragno / zt.fragtot fragment header — only for large frames

Verified live 2026-10-07 on a hybrid↔hybrid link:

ZT HELLO type=0 DBFA939D58 cap=1   185 B   # unencrypted, cap bit set
ZT ... Len=1480  flags=0x58         # PQ_KEYS fragments, cipher 3 (AES-GCM)

VERB_PQ_KEYS is encrypted and its verb is NOT visible. It is armored with the classical key and encryptPayload=true (Peer.cpp:628), so byte 27 is ciphertext like any other data packet — that is what lets the peer read it before it has switched to the hybrid session key. A 4257 B PQ_KEYS arrives as ~13 fragments at 1480 B each; identify it by size and fragmentation, not by zt.verb. The capture above shows 13 such frames.

The capability bit proves only that the peer advertises support. That the PQ exchange actually happened is a state question, answered in §6.3 — not something a dissector can show.

Run tshark as your normal user, not root. As superuser, Wireshark silently skips user Lua scripts and the dissector appears to be broken. If the pcap lives under a path the profile cannot read, copy it somewhere readable.


8. Troubleshooting — the three failure modes

All three are control-plane defects, none are crypto failures. In every case the tell is status: ACCESS_DENIED, peers: [], and 100% multicast loss on a healthy direct path.

8.1 B6 — controller compares identities the wire never carries

status: ACCESS_DENIED, no peer ever appears. Cause: the controller compared a stored type-1 identity against the classic projection HELLO actually transports, so they never matched. Fixed in 2.0.2 (sameClassicIdentity()).

Check: does HOST1's controller.db hold a member row whose address differs from the address HOST2 presents today? Re-run §5b.

sudo -n python3 -m json.tool /var/lib/backone/controller.db | grep -A3 members

8.2 B7 — peer's PQ identity never completed

Status stays deferred; credentials never arrive. Cause: received PQ keys were cached for crypto only and never written into the peer's Identity, so a type-2 membership double-signature could never verify. Fixed in 2.0.2.

Check: pqcCapable: true but pqcHybridActive: false and no peer. Confirm you are on ≥ 2.0.2 (backone -v).

8.3 B8 — both nodes ran their own controller

status: ACCESS_DENIED and each host has its own /var/lib/backone/networks.d/<nwid>.conf containing id=<its own address>.

Cause: no opt-out existed, so the member answered its own config requests and signed its own config, never contacting the controller that owned the network.

Fix: set disableController: true on HOST2 (§0) and restart. Delete HOST2's self-signed networks.d/<nwid>.conf, re-join, re-run §5b.

This is why §0 pins the roles. If both hosts have a networks.d/<nwid>.conf, you are here regardless of what status says.


9. Running the classical baseline

Same procedure, mode flipped — needed to populate the right-hand column of §6.2.

  1. §3 wipe both hosts.
  2. HOST1 local.conf: {"settings":{"pqcMode":"off"}} (or omit pqcMode entirely — absent means classic).
  3. HOST2 local.conf: {"settings":{"pqcMode":"off","disableController":true}}.
  4. Restart both; confirm identity.public is 141 B and type byte 0.
  5. §5 create a new network, authorize HOST2, join.
  6. §6.1 absolute gate — must still pass (classic is a supported mode).
  7. §6.2 — record pqcCapable/pqcHybridActive as false, HELLO 1 fragment, zt.hello.cap == 0.

Re-running §3 for the hybrid pass gives you a fresh type-1 identity and a new network, which is exactly what the comparative table needs.


10. Quick reference

# HOST1 controller, HOST2 = 192.168.122.85
A=$(sudo -n cat /var/lib/backone/authtoken.secret)
N=<nwid>

# health
curl -s -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/network/$N        # status/peers
curl -s -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/peer             # pqc flags
sudo /usr/sbin/backone-cli -p9993 -D/var/lib/backone peers          # path table

# membership (HOST1)
curl -s -X POST -H "X-ZT1-Auth: $A" -H 'Content-Type: application/json' \
  -d '{"authorized":true}' http://127.0.0.1:9993/controller/network/$N/member/$ADDR

# capture + dissect (HOST1)
sudo tcpdump -i any -s 0 -w /tmp/pq.pcap 'udp port 9993'
tshark -X lua_script:tools/zt-dissector.lua -r /tmp/pq.pcap -Y 'zt.hello.cap'

Cleanup when done: sudo systemctl stop backone on both hosts. Test networks and the shared lab subnet are left as you found them.


Appendix — where each claim comes from

Claim Source
disableController semantics and default service/README.md:46, service/OneService.cpp:1454-1459
member authorize route + authorized field controller/EmbeddedNetworkController.cpp:879, :1175
network create fields controller/EmbeddedNetworkController.cpp:620-766
VERB_HELLO = 0x01, VERB_PQ_KEYS = 0x17 node/Packet.hpp:617, :1103
MLKEM768_CT_LEN = 1088 node/PQHybrid.hpp:29
B6/B7/B8 root causes and fixes docs/pqc-test-scenario.md §9
netns lab, M1–M5 matrix, classification rule docs/pqc-test-scenario.md §4–§7
dissector fields (zt.hello.cap, zt.frag, …) tools/zt-dissector.lua