[ Open source · On-device vision model ]

Scan a handwritten seed backup
without it leaving the device.

bitcoin-vision is a Rust library with a few small vision models. Give it a photo of a BIP39 recovery phrase or a Penlock share, and it tells you what it read, how sure it is about each word, and what else each word might be.

BIP39 models
24.7 MB
Penlock model
1.6 MB
Network
None
Reads
BIP39 words · Penlock shares
Library
Rust
License
MIT / Apache-2.0

01 · Playground

Run it on a practice backup.

Press Run sample to read a photo of a practice backup, or use your own practice photo. Either way the real models run right here in your browser, and the photo stays on your device unless you choose to share it.

  1. Find
  2. Read
  3. Match
  4. Check

INPUT · sample-recovery-page.jpg

The sample practice photo

Practice words only. Never photograph a real backup on a connected device.

Nothing read yet.

Read this practice page with the real models, in this tab.

Or use your own practice photo.

02 · Models

The models and what they do

These are small models trained for this task, not a general-purpose AI, and they run on the device. Reading a BIP39 phrase uses the first three. Reading a Penlock share only needs the last one.

Model fileUsed forWhat it doesWhat it returnsSize
word-detector.onnxBIP39Finds where each word is written on the pageA box around each word4.7 MB
text-recogniser.onnxBIP39Reads the letters as written, even when they don’t spell a seed wordThe text it saw, e.g. “absert”7.7 MB
word-reference.onnxBIP39Compares each word with all 2048 seed wordsEach seed word’s chance of being the right one12.3 MB
cell-reference.onnxPenlockReads each of the 72 handwritten symbols on a shareEach of the 29 symbols’ chance of being the right one1.6 MB
24.7 MB

of models to read a BIP39 phrase

1.6 MB

of models to read a Penlock share

0

network requests while scanning

2048

seed words each handwritten word is compared with

03 · How it reads

From photo to words

PIPELINE A · BIP39

Recovery phrase

  1. 01Find the words. The page is straightened and each word gets a box drawn around it.
  2. 02Read the letters. The recogniser reads what was actually written, spelling mistakes included.
  3. 03Match against the wordlist. Each word is compared with all 2048 BIP39 words.
  4. 04Check the checksum. The last word of a phrase carries a checksum, which catches most misreads.
  5. 05Ask the user. Words the scanner isn’t sure about are shown to the user with the closest alternatives.

PIPELINE B · PENLOCK

Penlock share

  1. 01Find the share. The share is located in the photo and split into its 72 boxes.
  2. 02Read the symbols. Each box is compared with the 29 symbols Penlock uses.
  3. 03Check each row. Every row has its own error check, so most misreads are caught here.
  4. 04Combine shares. Any 2 of the 3 shares are enough to rebuild the 12 words.
  5. 05Ask the user. If a symbol is smudged, the user can correct it by hand.

04 · Integrate

Using the library

Create a Scanner once and call scan for each photo. For every word you get where it is in the photo, a cropped image of it, the text that was read and the ranked seed words it could be. You also get whether the checksum passed.

use bitcoin_vision::words::{ScanOptions, Scanner};

// feature "bundled-models" embeds the ~24.7 MB of models
let scanner = Scanner::bundled()?; // load once, reuse

let photo = std::fs::read("practice-page.jpg")?;
let document = scanner.scan(&photo, ScanOptions::default())?.document();

for &i in &document.ordered_observations {
    let word = &document.observations[i];
    // word.selected, word.quad, word.candidates
}
  • Hardware wallets

    The models ship with the firmware and the scan happens on the device. A Penlock app has run it on the Passport Prime simulator.

  • Mobile wallets

    The user takes one photo and checks the result instead of typing 12 words. There’s an Android example to start from.

  • Penlock tools

    Read a paper share back without typing 72 symbols by hand, then combine any 2 of the 3 shares.

  • Read the integration guide →

05 · In a hardware wallet

Tested on the Passport Prime simulator

A Penlock app for Passport Prime, built at a hackathon, uses bitcoin-vision to read shares. It has only run on the Passport Prime simulator so far, not on a real device. Reading Penlock shares needs just the 1.6 MB model, and the library never touches the network, so it fits well on a signing device.

STORAGE

1.6 MB for Penlock, 24.7 MB for BIP39

NETWORK

Not used

UPDATES

Shipped in signed firmware

UX

User checks the result before revealing it

06 · Limits

It’s still a prototype

WHAT IT CAN’T DO YET

  • It only reads English seed words
  • Faint writing, low-contrast photos and unusual page layouts lead to misreads
  • About 1 in 16 wrong 12-word phrases still passes the checksum
  • It isn’t published on crates.io yet

WHAT INTEGRATORS MUST DO

  • Ask the user to confirm every word the scanner isn’t sure about
  • Keep photos and results in memory, never on disk
  • Keep the words hidden until the user taps Reveal, and wipe them on Forget
  • Remind Penlock users to keep their shares in separate places