← Socratic Seminar #52 ← → or space to navigate

Draft BIPs · Avila Labs · protocol v0.16.0 · PSBT v0.17.0

Anti-exfil signing: stop your hardware wallet leaking its seed

A signing device picks the nonce in every signature, so a malicious one can hide your seed in perfectly valid signatures. These drafts make the host add randomness to each nonce, then check the device used it.

Author: Connor Avila · Draft, no BIP number · github.com/AvilaLabs/anti-exfil · handbook

The threat

Dark Skippy: a whole seed in two signatures

Malicious firmware uses 8 bytes of the seed as the nonce for each of two signatures. The signatures are valid and published on chain. The attacker solves the low-entropy nonces with Pollard's kangaroo and rebuilds the 16-byte seed. Malicious firmware 12-word seed = 16 bytes bytes 0–7 bytes 8–15 nonce k₁ = bytes 0–7 nonce k₂ = bytes 8–15 Published tx sig₁ = (R₁, s₁) sig₂ = (R₂, s₂) both valid ✓ Attacker scans the mempool R = k·G with k < 2⁶⁴ Pollard's kangaroo solves k₁ and k₂ k₁ ‖ k₂ = seed The owner and every verifier see normal signatures. A real attacker blinds it with their own key so only they can extract it.

Dark Skippy disclosure, 2024: "A single use of a malicious hardware wallet is enough to lose everything." Not seen in the wild.

Why it's hard

Deterministic nonces don't fix it. Only the host can.

  • The device chooses the nonce. RFC 6979 or BIP340's derivation only helps if you can check the device followed it, which needs the secret key.
  • Grinding always works without help: Wuille noted that 2^b grinding steps per signature leak b bits per signature.
  • One round isn't enough: if the device sees the host's randomness before it commits, it can still grind. The draft uses two rounds "to remove it, leaving only the choice to refuse."
  • Prior art: Wuille's 2020 "Scheme 6" with a sign-to-contract tweak, already shipped in Blockstream Jade (secp256k1-zkp); the spec notes devices "already deploy versions of it". Library support is proposed in bitcoin-core/secp256k1 #1140, open since 2022.
  • The gap: "There is no agreed specification." Each vendor picks its own bytes, failure rules and host checks.

The protocol (BIP340 version)

Commit, commit, reveal, sign, verify

Two-round anti-exfil exchange. The host commits to random rho; the device commits to its base nonce point R0; the host reveals rho; after user approval the device signs with nonce k0 plus a tweak derived from R0 and rho; the host checks the signature's nonce equals R0 plus tweak times G. Host (wallet software) Device (holds the key) ① draw secret ρ m, hc = H("s2c/schnorr/data", ρ) ② k₀ = H(sk-mask ‖ pk ‖ m ‖ hc) R₀ = k₀·G (no signature yet) ③ store R₀, only then reveal ρ, m ④ user approves on device, then t = H("s2c/schnorr/point", R₀ ‖ ρ) sign with nonce k′ = k₀ + t sig = (r, s) ⑤ W = R₀ + t·G; x(W) = r ? and BIP340 Verify(pk, m, sig) ?

The device can't see ρ when it fixes R₀, and can't change R₀ after it sees ρ. ECDSA follows the same five steps with its own tags and a low-s check.

Design choices

Every rule closes a specific leak

k₀ depends on hc

Otherwise a malicious host could get two signatures on one base nonce with two tweaks, and solve for the key.

ρ stays secret

Anyone with ρ and a backdoored k₀ computes the key from one signature. ρ is never logged, shared or written to disk.

Fresh ρ every attempt

A ρ the device has seen must never be reused, or the device can grind against it.

Low-s for ECDSA

Accepting both (r, s) and (r, n − s) gives the device one free bit per signature.

Device recomputes

It never trusts a stored or host-supplied k₀ or R₀, so it can stay stateless and can't be tricked into reusing a nonce.

Refusals are counted

The one channel left: refusing selectively, at most ~1.44 bits per failed attempt. The host durably counts failures and warns the user.

PSBT integration

Three per-input fields, two passes

PSBT_IN_AE_HOST_COMMITMENT   0x21   <key id>  →  hc        32 bytes   (pass 1, host → device)
PSBT_IN_AE_NONCE_COMMITMENT  0x22   <key id>  →  R0_bytes  33 bytes   (pass 1, device → host)
PSBT_IN_AE_HOST_RANDOMNESS   0x23   <key id>  →  rho       32 bytes   (pass 2, host → device)
  • Key types are proposed, not assigned. Works with PSBT v0 and v2.
  • Required: P2PKH, P2WPKH, P2SH-P2WPKH, Taproot key path, and P2WSH single-key or bare multisig. Optional: Taproot script path. Not covered: MuSig2, FROST.
  • The fields are private to one host and one signer: the host keeps its own clean PSBT and builds a separate request each pass, because ρ must never reach anyone else.
  • Transports: USB works. QR looks possible on paper but needs its own profile (4 displays per tx). SD card and file don't work, since ρ would hit durable storage.

Status

Heavily tested, not yet reviewed

Draft

No BIP number, no cryptographer review, no outside audit. The Python reference is variable-time and "MUST NOT be used with real funds."

Tested

768 vector checks, a C module for libsecp256k1, a Jade port passing 378 tests with 36 regtest txs mined. Nothing has run on real hardware.

Proof

A reduction against a malicious host, with parts machine-checked. The malicious-device argument is "shorter and less reviewed."

Compatible

Same message layout as secp256k1 #1140 and Jade's secp256k1-zkp, whose signatures pass these host checks. The nonce derivation differs on purpose.

Competing drafts: Sjors Provoost's two-round Taproot key-path draft (Oct 2026, proprietary PSBT fields) doesn't interoperate. FractalEncrypt runs ECDSA anti-exfil over animated QR on SeedSigner and Kern.

Discussion

Questions for the room

  • Should Bitcoin Core's wallet or HWI require anti-exfil from signing devices, and refuse plain signatures?
  • Air-gapped users distrust their host, but the guarantee needs an honest host. Is QR anti-exfil still worth four displays per transaction?
  • Is a durable failure counter enough against a device that leaks through refusals, or will users just click past warnings?
  • Three incompatible approaches exist (this one, Sjors', FractalEncrypt's). How do we converge on one standard?
  • Part of the testing used implementations an AI model wrote from the text alone. How much should that count before human review?