← Notes

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.

Record
Change
Host-contributed nonce (anti-exfil) on every signature: Nostr BIP-340, bitcoin BIP-143 inputs, BIP-137 messages
Date
Built and tested 27 October 2026
G0 firmware
Self-test v8, 24 checks. Replaces the frozen v7 tree c0b94d1b7a9e350d; frozen 27 October 2026 on the build that passed the tests below
G0 firmware.bin SHA-256
d640e2f651f3c613ea41cc8bf44f70d393f91ae5b55eef1069ad966da15d60b8
ESP32 firmware
Two new verifiers (full BIP-340 and ECDSA), the commitment check, and a fault latch
Status
Honest signer passes on hardware; dishonest signer caught on hardware. Ahead of the independent audit, not instead of it

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

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.

TestWhereResult
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 itHost, libsecp256k1, all 15 BIP-340 signing vectors plus ECDSA and recoverable cases136 / 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 gateHost78 / 78
Fault hardening from 19 October (glitched signature caught, glitched key caught), re-run through the splitHost10 / 10
Bitcoin derivation, sighash and reference signatures against embitHost206 / 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 onceHost, libFuzzer with address and undefined-behaviour sanitisers355,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 rejectedHost, against libsecp256k1161 / 161
Honest G0 on hardware: self-test 24/24, Nostr event signed from the phone app, DM sent and received, two-input multisig PSBT signedKEY, bench unitpass
Dishonest G0 on hardware: a bench build that ignores t and puts eight key bits in the final nonceKEY, bench unitcaught

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

What this isn't: an audit. It is our own test record of our own change, with the harnesses in the firmware tree so anyone can re-run them. The independent audit of the signing path is what comes next, and the dishonest build is part of the package handed to the auditor so the property can be confirmed by someone who did not write it.