← Blog

Rebuilding Faraday for auditability and agents

Faraday is an offline Bitcoin signer. Its first version grew fast: about 560,000 lines of Rust in seven weeks, wholly written by AI coding agents. A person started each session, told it what to do and checked what came back. Our review of the Faraday repo found that while the cryptography, key handling and file formats held up well, the app on top of them did not.

So we asked a plain question: should we fix that app where it stands, or start again on a blank, greenfield branch with an architecture chosen up front? We wanted the well-known patterns that keep large codebases easy to change:

The study of the code added four patterns that fit Faraday:

These patterns are preferred for the same reason. Each one gives every rule a single place to live, and a dependency that points the wrong way becomes something a tool can catch. That matters for people, and even more for agents. An agent works well when its task has a clear edge, and it does damage when it can reach anything.

It matters most for auditability. An auditor, or a user who wants to check our work, should be able to find where a key can live, what touches it, and what happens to it on a lock, without reading the whole app. In this design those answers each sit in one place, and a lint holds them there. Code that is easy to audit is also code that can be trusted to stay right as it grows, and for a signing device that is the work that matters.

What the audit found

Before choosing what to do next, we measured the code:

None of this was a security fault: the audit found no secret kept after its screen or a lock. But each feature cost more to add than the one before it. It was also the wrong shape for agents. An agent has to read far more than its task needs, and nothing stops it from reaching across the code.

A clean start, built to be filled in by agents

The answer was to start again. next is a new branch, started empty. The pure crates were copied over unchanged, with their tests. Everything else is being rebuilt on the patterns above, each one held by code:

How the work runs

The specification came first. Before any code was written, it set out every layer, crate, module, type and function signature, and the whole of it compiles as a skeleton where every function body is a todo!(). The number of stubs left is the measure of progress.

The agents work from it one small, well-defined task at a time, with the standard elements of any software project: tracked tasks, written instructions, review, and automated checks. The layer rules, the test headers and the handling of secrets are all lints, so work that drifts from the design fails a check instead of waiting for someone to notice. The full check runs on GitHub every time work lands.

Where it stands

We are working hard on fishing the migration. Just prior to this necessary work, Faraday had undergone a pretty big UX overhaul aimed at simplifying flows and making sure the app inter-operated with itself end to end. Designing Faraday really is designing an entire operating system, just one aimed at being for one specific purpose: offline signing on off the shelf hardware. I look forward to sharing about the UX updates!

The plan and the specification are public on the next branch.

Buy me a coffee

Donations to Faraday's development, in bitcoin.

QR code to come
Lightning
QR code to come
Bitcoin