Skip to content

Interactive Taproot anti-exfil host verification and hardware-wallet support - #2

Open
Sjors wants to merge 28 commits into
masterfrom
2026/10/taproot-anti-exfil
Open

Sjors wants to merge 28 commits into
masterfrom
2026/10/taproot-anti-exfil

Conversation

@Sjors

@Sjors Sjors commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

A valid signature can leak a device's secrets through its nonce. Add a two-round
single-signer Taproot flow: the host commits to randomness, records the device's
full original nonce, reveals its contribution, and checks both BIP340 validity
and the nonce relation before accepting a signature. Six Taproot-capable device
variants implement the protocol; the four remaining HWI variants reject explicit
requests before signing.

The additive construction follows Snigirev's nonce-blinding/PSBT proposal and
Scheme 6 in Wuille's anti-covert-channel overview. The companion BIP defines the
exact domains, parity, failure rules, PSBT transport, and independent vectors.
This is an experimental implementation, with no claim of a new security proof.

Dependencies and companion PRs

This branch starts from HWI master and has no MuSig2-branch dependency.

Companion PR Relationship to this PR
BIP draft Protocol, provisional PSBT fields and shared test vectors.
libsecp256k1 API proposal Companion API and vector implementation; no compile dependency from HWI, Core or the firmware PRs.
Bitcoin Core host Application-level host through the HWI subprocess interface; CI builds its source from the fork branch for Core-managed integration tests.
Ledger Bitcoin app Firmware nonce commitment/reveal support and nonce-yield receipts used by the Ledger adapter.
Trezor firmware Protobuf transport and signing engines for Trezor One and T.
Jade firmware Native PSBT commitment/reveal signing and explicit capability.
BitBox02 firmware Streaming protocol rounds, transcript fields and explicit capability.
libngu Native Schnorr primitives required by the Coldcard firmware PR.
Coldcard Edge firmware PSBT commitment/reveal signing; depends on the libngu PR above.

Each firmware uses its own bundled SDK/secp primitives. Core's host PR builds on
the external-signer hardening work described in that PR. Coldcard's dependency
increment changes its libngu URL and gitlink, so publish libngu first and refresh
the firmware gitlink if its dependency is rewritten. The other temporary CI
references follow the published fork branch names.

Reviewable increments

The shared host increment, Verify interactive Taproot anti-exfil transcripts at
the HWI boundary
, implements independent transcript verification. Reject
anti-exfil requests before invoking unsupported signers
adds capability
preflight so an explicit request cannot silently fall back to ordinary signing.

Device increments add Ledger nonce-yield transport; Trezor protobuf receipts and
the One/T bridges; Jade native PSBT transport; BitBox02 streaming rounds and raw
SDK guards; and Coldcard Edge PSBT transport. Separate test increments register
the ordinary and protected suites, exercise mixed or untargeted inputs, reject
swapped Trezor receipts, and check refusal on released firmware.

Keep anti-exfil device logs and exceptions private to the signing context
and Protect anti-exfil CLI diagnostics across reconnect and close protect the
whole SDK/CLI lifetime described below.

Return only verified anti-exfil results in the host PSBT closes the metadata
channel in native device PSBT replies. After raw-response verification,
commands.signtx and the CLI reconstruct the response from the pristine caller
request and copy only validated nonce receipts or verified target signatures.

Small compatibility and test-harness increments:

  • test: keep registered wallet accounts distinct across cases uses accounts
    1 and 2 in the multi-policy test, avoiding a policy already registered by the
    preceding case under another name.

  • bitbox02: move draft anti-exfil capability to unused DeviceInfo field moves
    the decoder to field 10, preserving upstream's field-8 password-stretching
    string and field-9 bootloader version. Its regression checks actual string
    wire encoding and the previous draft's bool at field 8; neither advertises
    field 10.

  • test: disable unused P2P in the device node disables the unused P2P listener.
    The harness uses RPC for local wallet funding and mining; an unrelated socket
    can otherwise claim the chosen P2P port before node startup.
    This is the P2P-listening part of bitcoin-core/HWI#864.
    That upstream PR also increases the initial mining RPC timeout; the timeout
    change is not included here.

Each HWI increment was installed from its own exported tree and ran the
non-device tests available at that revision. Firmware PRs separate crypto/vector
support from wire or PSBT integration; Trezor separates its two signing engines.

Scope and application obligations

Single-signer Taproot key path, no annex, DEFAULT or explicit ALL. Several device
adapters retain their BIP86-only restriction. Script paths, MuSig2, FROST and a
general sign-to-contract API are outside this work. Existing ECDSA anti-klepto
interfaces retain their behavior.

PSBTv0/v2 carry proprietary input keys
fc 02 61 65 <subtype> <actual output key32>. Subtypes 0/1/2 contain commitment32,
original nonce33 and entropy32. First-round replies contain no signature and
report signed=false. The second round returns the usual Taproot key signature.
The provisional hash tags are BIP-EXFIL/host and BIP-EXFIL/nonce; BIP assignment
requires coordinated vector regeneration in every implementation.

The commands.signtx/CLI bridge checks the original transaction including
sequences, UTXOs, requested key, sighash, transcript and per-input signatures.
Missing proofs, changed protected fields, early signatures and new untargeted
signatures fail. It validates the raw device response, then returns the original
caller PSBT with only the validated nonce receipts or verified target signatures
copied in. Caller metadata and the private transcript are retained unchanged;
unrelated device-added, changed or removed metadata is not forwarded.

This boundary handles device-controlled bytes from native PSBT transports such
as Jade and Coldcard within an honest HWI. The application and HWI are trusted
parts of the same host. Core already copies only verified signatures into its
original PSBT; this change also closes the arbitrary-device-metadata channel
for standalone HWI consumers. Successful protected replies remain private
protocol messages. The trusted host collectively retains original state and
verifies device contributions; an application may delegate these checks to HWI's
checked boundary. Core adds its own verification and remains in the same trust
boundary as HWI. The final host strips transcripts before exporting a completed
PSBT. Direct
HardwareWalletClient.sign_tx/SDK callers must apply the same checks and original
PSBT reconstruction themselves. Interrupted-session recovery requires the exact
original tuple; there is no transparent restart with fresh entropy.

The common host verifier rejects new untargeted signatures in a protected
invocation. Device support for subset targeting varies: Jade and BitBox02 require
all owned inputs to participate. Core targets all its owned unsigned inputs.

Device coverage and implementation differences

All ten full library-mode suites passed locally, with expected skips. These are
locally built simulators, not physical-device flashes. Full suites ran serially
because generic enumeration probes other simulators; private endpoints were used
only with explicit paths and no discovery.

Device variant Protected-signing coverage or limitation
Ledger Bitcoin app Protected signing and Core-managed host integration.
Trezor One and T Two-input flows, wrong openings/nonces and swapped receipts.
Jade Two-input PSBTv0/v2 DEFAULT/ALL flows and five direct firmware faults.
BitBox02 Two-input PSBTv0/v2 DEFAULT/ALL flows and seven wire-level faults.
Coldcard Edge PSBTv0/v2, DEFAULT/ALL, library/CLI/stdin interfaces.
BitBox01 No ordinary Taproot; explicit protection request rejected.
Coldcard classic No ordinary Taproot; explicit protection request rejected.
Ledger legacy app No ordinary Taproot; explicit protection request rejected.
KeepKey Firmware explicitly rejects SPENDTAPROOT; protection rejected.

Jade needed the narrowest bridge change because its native PSBT command already
carries the transcript. Edge also has a suitable PSBT transport, but needs a
separate libngu dependency. Ledger needs custom nonce handling through its SDK
and a new nonce-yield receipt. Trezor requires protobuf transport and two signing
engines; tests caught optional-field defaults on ordinary requests and the extra
ALL witness byte in fee-weight estimates. BitBox02 needs explicit invocation
rounds, two-pass guards and protobuf/SDK changes, making it one of the more
involved adaptations. The unsupported variants need ordinary Taproot support
first.

Privacy and error handling

Raw public nonce points can themselves carry secret information. Actual Jade
CBOR log packets and SDK exceptions reproduced a path into default logging and
debug tracebacks. A context-local filter protects the SDK operation and the
CLI's discovery/initialization, reconnect, signing and close. It preserves
unrelated threads' logging, restores handlers on success/failure, and suppresses
chained raw exceptions using fixed error categories. Cleanup failure returns no
otherwise-complete transcript. Ordinary requests retain their diagnostic text.

Library callers constructing and closing clients themselves can use
anti_exfil.private_operation() around that lifetime. Successful PSBT replies
are host-local protocol messages, not diagnostic output to publish.

Local validation

  • The complete non-device suite passes, including shared vectors, multi-input
    and subset targeting, malformed responses, actual Jade SDK logging, CLI
    lifecycle and traceback privacy, restoration, unrelated-thread logging and
    the BitBox02 capability wire regression.
    The protected-response regressions simulate device metadata additions,
    mutations and removals across every map, in-place decoding, existing signatures
    and transcript preservation. Actual Jade and Coldcard driver decoders also
    process adversarial raw device-response bytes, rejecting invalid proofs before
    reconstruction. Their native PSBT simulator matrices check exact caller-PSBT
    preservation in both rounds for DEFAULT/ALL and v0/v2.
  • An occupied-port regression runs the actual fixture against released and
    companion Core. Consecutive funding/mining nodes start while the P2P port is
    deliberately held throughout, using RPC.
  • All ten full device suites pass. Protected suites check reconnect determinism,
    actual firmware rejection after bypassing host preflight, DEFAULT/ALL and
    PSBTv0/v2, independent host proofs, mempool acceptance, broadcast and mining.
  • Released Jade and BitBox02 simulators refuse AE before signing; their ordinary
    Taproot paths were checked too. All four unsupported variants reject an
    explicit request with the expected error and no returned PSBT.
  • The Core C++ host -> HWI subprocess -> Ledger firmware integration passes,
    including walletprocesspsbt, transcript removal, send, mempool and confirmation.
  • Configured flake8 passes. Scoped locked-mypy checks pass for the changed host,
    lifecycle and non-BitBox driver modules. Full optional typing remains limited
    by third-party stubs/SDK imports and existing BitBox generated-protobuf and
    PubkeyProvider errors; no complete typing pass is claimed.
  • Companion validation covers the eight shared vectors, complete libsecp CTest
    coverage and small-order zero-nonce checks, Ledger native crypto tests,
    BitBox02's actual ARM firmware build and full Rust unit suite, and libngu's
    embedded tests with Schnorr enabled and disabled and without MuSig.

Install HWI, build the matching firmware with test/setup_environment.sh, and
run from test/:

python run_tests.py --DEVICE --device-only --interface=library \
  --DEVICE-path=/absolute/path/to/simulator --bitcoind=/absolute/path/to/bitcoind
python run_tests.py --DEVICE --anti-exfil --interface=library \
  --DEVICE-path=/absolute/path/to/simulator --bitcoind=/absolute/path/to/bitcoind

Use --ledger-path for both Ledger variants. --ledger-anti-exfil-core selects
the Ledger protected suite plus the Core-managed test and needs the companion
Core build with -signerantiexfil. The ordinary suite runs separately. The cli
and stdin interfaces are supported too; Edge was tested through all three.

TEMPORARY fork CI commit

The last commit, TEMPORARY: CI build anti-exfil firmware and Core from Sjors
forks
, is integration scaffolding to remove or repoint as the companion work
lands upstream. It builds Core and the supported-device firmware from the public
2026/10/taproot-anti-exfil branches in Sjors/bitcoin,
Sjors/ledger-bitcoin-app, Sjors/trezor-firmware, Sjors/Jade,
Sjors/bitbox02-firmware and Sjors/firmware. Coldcard fetches its libngu
submodule from Sjors/libngu. The Ledger clone explicitly uses the app-bitcoin
destination expected by its builder.

The firmware PRs follow upstream's development lines: Ledger develop, Trezor
main, Jade and BitBox02 master, Coldcard new_edge, and libngu master.
The setup derives Jade's ESP-IDF and BitBox02's SDK image from the firmware
sources. Fresh fork clones need upstream release tags for version metadata:
Blockstream/Jade tags give ESP-IDF a SemVer firmware version, and signed
BitBoxSwiss/bitbox02-firmware tags drive its version-header generator. It
supplies the tested Trezor SDL3/Rust runtime layout and Coldcard compiler-patch
fallback while retaining release ancestry for version scripts.

The temporary CI wiring runs protected suites in the existing Python,
interface and wheel/sdist/bindist matrices; Ledger also exercises the actual
Core host. YAML, embedded shell syntax and the Trezor relocated runtime bundle
were checked locally. Current GitHub CI results are recorded by this PR's checks.

Sjors added 25 commits October 25, 2026 02:48
The preceding registration test persists account 0 on the simulator.
Registering the same descriptor again as HWI_testing_0 can be refused
as a duplicate by current firmware, leaving a prompt active.

Use accounts 1 and 2 for the multi-policy test. It still signs inputs
from both registered policies and an inferred wallet, without relying
on duplicate-policy registration being allowed.
Current firmware master uses DeviceInfo field 8 for its password-
stretching string. Move the experimental capability to field 10 to
match the rebased firmware, preserving its new upstream allocation.

Check actual string wire bytes and the earlier draft's bool allocation
so neither can advertise support without the dedicated capability.
A valid protected signature does not authenticate arbitrary device metadata.
Validate the complete raw response first, then reconstruct the signtx reply
from the pristine host request. Copy only target nonce receipts in round one
or verified target signatures in round two. Preserve caller metadata and the
private transcript for the trusted host's verification. HWI and its
calling application remain trusted parts of the same host.

Cover device-response additions, mutations and removals across PSBT maps,
in-place request mutation, existing untargeted signatures, invalid proofs,
and ordinary metadata passthrough. Exercise the actual Jade and Coldcard
decoders with adversarial raw device bytes, and check exact host-PSBT
preservation in their native DEFAULT/ALL and v0/v2 simulator matrices.
@Sjors
Sjors force-pushed the 2026/10/taproot-anti-exfil branch from 7a8ddb2 to b75558c Compare October 25, 2026 15:00
Sjors added 2 commits October 25, 2026 16:52
The device harness only uses RPC to create wallets, fund transactions and
mine blocks. Selecting a random P2P port releases it before bitcoind can
bind, so an unrelated socket can claim it and abort startup.

Disable P2P listening instead of selecting an unnecessary P2P port.
Use 2026/10/taproot-anti-exfil in Sjors/bitcoin, ledger-bitcoin-app,
trezor-firmware, Jade, bitbox02-firmware, and firmware. Coldcard's
firmware gitlink also requires the matching Sjors/libngu branch.
Branch refs follow signing-only commit SHA changes before publication.

Retain Ubuntu 24.04 and GCC 12/13 for the tested simulator toolchains.
Keep release ancestry available to version scripts. Advertise Ledger's
current 2.5.1 app version in Speculos. Build minimal, pinned SDL3 and
SDL3_image libraries for Trezor and bundle them beside each emulator with
relative runtime paths. Select the current Rust nightly and T2T1 model,
and stage the new xtask output at the path expected by the HWI harness.
Keep a Coldcard compiler-patch fallback for current new_edge.

Run protected signing in the existing interface and distribution matrices,
and include the Core-managed Ledger integration test.

Remove or repoint this temporary integration commit as the companion work
lands upstream. The firmware forks and branches must exist before GitHub
can execute this workflow.
@Sjors
Sjors force-pushed the 2026/10/taproot-anti-exfil branch from b75558c to fa10417 Compare October 26, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant