Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-exfil.mdandbip-exfil/vectors.json. TheBIP-EXFIL/hostandBIP-EXFIL/noncedomains are provisional; assigning a BIP number requires coordinated vector regeneration across implementations.crypto: use libngu with interactive Schnorr anti-exfilincrement pins this implementation, then its PSBT increment supplies the device transport.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, orNGU_INCL_MUSIG=1which 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.
ngu_tests.runsuite passed, including key/tweak, Schnorr, MuSig, random, codecs, hashes, HD-node and BIP32/BIP39 tests.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.