Skip to content

secp256k1: experimental interactive Schnorr anti-exfil - #1

Open
Sjors wants to merge 1 commit into
masterfrom
2026/10/taproot-anti-exfil
Open

Sjors wants to merge 1 commit into
masterfrom
2026/10/taproot-anti-exfil

Conversation

@Sjors

@Sjors Sjors commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

This adds the signer half of the draft BIP-EXFIL protocol to ngu's native secp256k1 module. A host commits to a random scalar, obtains the device's original public nonce, and reveals the scalar in a second invocation. The resulting signature is an ordinary BIP340 signature whose nonce contribution the host can verify.

Base and dependencies

Based on upstream switck/libngu:master. The implementation is one increment, secp256k1: add interactive single-signer Schnorr anti-exfil, including the API, shared vectors, embedded tests and documentation.

  • BIP draft: protocol and eight shared vectors in bip-exfil.md and bip-exfil/vectors.json. The BIP-EXFIL/host and BIP-EXFIL/nonce domains are provisional; assigning a BIP number requires coordinated vector regeneration across implementations.
  • Coldcard firmware: its crypto: use libngu with interactive Schnorr anti-exfil increment pins this implementation, then its PSBT increment supplies the device transport.
  • HWI: host validation, Coldcard driver support and real simulator tests. The build dependency is libngu → Coldcard firmware → HWI.
  • Bitcoin Core: an integration consumer through HWI, with no build dependency on this native module.

There is no compile-time dependency on the standalone libsecp256k1 anti-exfil API. This implementation uses the public APIs already provided by upstream libngu's nested secp256k1, including the custom Schnorr nonce callback and secret-key tweak addition.

Interface and implementation

  • anti_exfil_commit(keypair, message32, commitment32) returns the original compressed 33-byte nonce point, retaining its parity, without signing.
  • anti_exfil_sign(keypair, message32, commitment32, nonce33, entropy32) checks the opening and original nonce, adds the host scalar, and verifies the resulting BIP340 signature before returning its 64 bytes.

Enable NGU_INCL_SCHNORR=1, or NGU_INCL_MUSIG=1 which also enables Schnorr. Both anti-exfil entry points are omitted when Schnorr is disabled. The vector test only skips when ordinary Schnorr is also absent; no MuSig dependency is introduced.

The caller supplies the actual signing keypair. Coldcard applies the Taproot tweak before calling these functions. The original nonce is deterministic in the normalized signing key, message, host commitment and dedicated protocol domain, so no persistent secret nonce state is needed between invocations.

Secret arithmetic stays in native code. SHA256 output is reduced with one branchless subtraction of the curve order; public libsecp operations handle key normalization and scalar addition. A separate nonce domain avoids related nonces with ordinary BIP340 signing. Temporary private-key and nonce buffers are cleared, and final signature verification provides the specified fault check.

Host verification, immutable request state and safe retries remain necessary. These signer functions cannot provide those host guarantees. The experimental construction and implementation need cryptographic review before deployment.

Validation

Built into the native Coldcard Edge MicroPython simulator with GCC 13.

  • All eight independent BIP vectors passed, covering both key and nonce parities and host-scalar boundaries. Changed message, host commitment and nonce, plus zero and out-of-range reveals, were rejected.
  • The complete embedded ngu_tests.run suite passed, including key/tweak, Schnorr, MuSig, random, codecs, hashes, HD-node and BIP32/BIP39 tests.
  • The embedded suite also passed with Schnorr/MuSig disabled, checking that both anti-exfil entry points are absent. A Schnorr-only build passed ordinary Schnorr and anti-exfil vectors while MuSig remained disabled.
  • Upstream Hash_DRBG SHA256 known-answer tests and RNG backend integration gates passed.
  • The new test is included in the Unix Makefile and embedded test manifest/runner.
  • Dependent Coldcard firmware passed real HWI signing over library, CLI and stdin interfaces, including broadcast and confirmation, and the complete ordinary Edge suite.

Updating the dependency

Publish the libngu revision before updating Coldcard's submodule gitlink. If signing or rebasing changes that revision, update the gitlink before publishing Coldcard, then run HWI against the matching firmware. Once accepted upstream, restore Coldcard's upstream libngu URL and select the accepted revision.

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