Favilla notes · test report · 27 October 2026
A nonce the signer cannot choose
The chip that holds your keys could, in theory, leak them through the signatures it makes, and nothing on the board could see it. As of today it cannot. This is what we built, why, and how we proved it by building a deliberately dishonest signer and watching it get caught.
A Schnorr or ECDSA signature is public. Its nonce is secret, and the nonce and the private key are tied together by the signature equation. Anyone who controls the nonce and can read the signature can recover the key. On the KEY the nonce was chosen by the STM32G0, the isolated signer that holds the plaintext key. Its firmware is ours and open, but if the silicon itself were trojaned, or our code were wrong in a way that biased the nonce, every signature the device ever published would carry a few bits of the key out to the world, and the ESP32 beside it could not tell a good nonce from a chosen one. It was the one place in the design where a single chip was enough.
The fix is the Blockstream and Coldcard anti-exfil scheme, adapted to the G0's fixed-length command set. The application processor contributes to every nonce and checks that its contribution was used.
The protocol in four lines
ESP32 draws t (32 random bytes), sends h = H(t) with the message G0 derives its nonce k0 as before, answers R0 = k0 · G commits before it knows t ESP32 reveals t G0 checks H(t) == h, signs with k = k0 + H(R0 ‖ t) ESP32 checks x(R0 + H(R0 ‖ t) · G) == r, then verifies the signature
The G0 commits to its nonce point before it learns t, so it cannot make k0 depend on t. The ESP32 commits to h before it sees R0, so it cannot grind the result either. Every bit of the final nonce depends on a value the G0 did not pick, so any pattern it tried to put in k0 is destroyed by the hash. The ESP32 learns nothing it could not already see: R0 and the signature are both safe to publish. And t only tweaks a nonce still derived inside the chip, so the ESP32 cannot choose the nonce either. The nonce channel now needs both chips to be dishonest at once.
A signing chip that chose its own final nonce cannot pass the check, because it committed to R0 before it knew t.
What changed on the G0
- The one-shot signing commands are gone. SIGN, BTCSIGN and MSGSIGN are retired, not accepted, their ids never reused. There is no way left to ask the chip for an uncommitted nonce.
- Each is replaced by an INIT that answers R0 and a FINISH that takes t and answers the signature. One operation may be pending at a time; a second INIT is refused and does not disturb the first; a FINISH with the wrong t, no t, or after a ten second window is refused; a reset or sleep forgets the pending state.
- The deterministic derivation stays: RFC 6979 for ECDSA with h as extra data, BIP-340 for Schnorr with h folded into the auxiliary randomness. A lost or replayed t can never repeat a nonce on a different message.
- Hash tags follow libsecp256k1-zkp for ECDSA (s2c/ecdsa/data, s2c/ecdsa/point) and the upstream Schnorr proposal (s2c/schnorr/data, s2c/schnorr/point), so standard tooling can check a KEY signature the same way.
- The boot self-test gained four fixed-input vectors through the new path. Same inputs must give the same R0 and the same signature as the host that generated them.
- Cost: 4.3 KB of flash, one extra I2C round trip per signature. The nonce point was already computed inside signing; it is now split out, not added.
What changed on the ESP32
Checking the code before writing this turned up something the design note had assumed wrongly: the ESP32 did not verify the G0's signatures at all. It had sign, ECDH and point multiplication but no Schnorr verify and no ECDSA verify; on the bitcoin path it compared the public key and the sighash with its own and trusted the signature. Both verifiers are new, alongside the commitment check. Any mismatch is an ANTI-EXFIL FAULT: the signature is wiped, never used, signing is latched off until the next power cycle, and the screen says SIGNER FAULT. No retry, because a retry would mask the alarm. The event or transaction is not signed.
How it was tested
The acceptance test for this change is not an honest signer passing. It is a dishonest one being caught.
| Test | Where | Result |
|---|---|---|
| Derivation: the G0's k0 is byte-identical to the nonce BIP-340 itself would produce; the tweaked signature verifies; the host relation holds; the untweaked (previous) signature fails it; a wrong t fails it | Host, libsecp256k1, all 15 BIP-340 signing vectors plus ECDSA and recoverable cases | 136 / 136 |
| Command layer: the real G0 handlers, extracted from the firmware source and driven as the ESP32 drives them. Honest Nostr, P2WPKH, P2WSH and BIP-137 flows; the bitcoin latch burned exactly once per signature and never at FINISH; every pending-state rule above; the door gate | Host | 78 / 78 |
| Fault hardening from 19 October (glitched signature caught, glitched key caught), re-run through the split | Host | 10 / 10 |
| Bitcoin derivation, sighash and reference signatures against embit | Host | 206 / 206 |
| Fuzzing of the INIT / FINISH state machine with six invariants: FINISH always clears; INIT while pending changes nothing and never fetches; a released signature always satisfies the relation for the committed R0 and t; nothing after timeout or reset; key bytes never appear in any output; a bitcoin INIT burns the latch at most once | Host, libFuzzer with address and undefined-behaviour sanitisers | 355,838 runs, 0 findings |
| ESP32 verifiers: BIP-340 verify against all 19 BIP-340 vectors including the negatives; ECDSA and recoverable verify; relation checks agree with the G0 side; off-curve and malformed R0 rejected | Host, against libsecp256k1 | 161 / 161 |
| Honest G0 on hardware: self-test 24/24, Nostr event signed from the phone app, DM sent and received, two-input multisig PSBT signed | KEY, bench unit | pass |
| Dishonest G0 on hardware: a bench build that ignores t and puts eight key bits in the final nonce | KEY, bench unit | caught |
The dishonest signer
We built the G0 firmware with a bench flag that makes it do exactly what the protocol exists to stop: ignore the ESP32's t and set the low byte of the final nonce from the key. Its signatures are valid signatures; a client, a relay or an unchecking host accepts them, and eight bits of the key ride out with each one. On the host, eight of eight such signatures verified and eight of eight failed the relation check.
On hardware the first attempt did not get that far. The dishonest build failed its own boot self-test: 20 of 24, because the four new vectors no longer matched, and the G0 went to its error state and refused every command. That is correct fail-closed behaviour, and it is a second, independent layer the design note had not claimed: a G0 whose nonce path has been altered never signs at all. It is also useless as a bench test, so the bench flag now also skips those four vectors, and the clean firmware was confirmed byte-identical before and after that change.
With the self-test out of the way the dishonest G0 booted normally, unlocked, and the phone app asked it to sign an event. The ESP32's log:
[G0] self-test v8: 20/20 passed, flags=0x00 [G0] anti-exfil: present - every signature is host-nonce committed (self-test v8) ... [sign] using PWA pre-computed id: 8d7176d023792b17... [G0] ANTI-EXFIL FAULT: Nostr: x(R0 + H(R0||t)G) != R - signature discarded, signing latched off until reboot [G0] ANTI-EXFIL FAULT: holding fault screen (fail-closed, no retry)
The event never left the device. The screen read SIGNER FAULT. The same test on the bitcoin path gives the same result with a different label.
What it does not claim
- It does not protect against a compromised ESP32. A hostile host can skip the check. Secure boot and an open, reproducible ESP32 build are what make the host trustworthy; this assumes they hold.
- It does not cover the Nostr encryption key exchange. The G0's ECDH is static, so there is no nonce to commit to; the residual there is different and smaller, and the fix for it (a discrete-log equality proof) is a separate item for the audit.
- It does not stop a dishonest G0 from refusing to sign, signing slowly, or leaking through timing on the bus. Those need physical access and are not remote key leakage.
- The latency numbers in the design note were estimates. The verify step on the ESP32 is heavier than estimated; measured figures will be added here. The G0 self-test timings are unchanged by the change (sign 812 ms per 4 vectors, verify 3,327 ms per 19, ECDH 619 ms per 1).
- The hash-tag byte layout was written from memory of the libsecp256k1-zkp source and pinned by test vectors; it will be diffed against that source. A mismatch would only cost interoperability with other tools, not security.