Embedded Cashu wallet
nucula
Tap-to-pay ecash on a $23 board.
ESP32-C3 · PN7160 NFC · open hardware.
Open source · CERN-OHL-S-2.0 hardware
What is it
A Cashu wallet
on a microcontroller.
Holds ecash from several mints. Receives over NFC. Mints and melts over Lightning. Keeps working offline and redeems later.
- MCU
- ESP32-C3 · RISC-V
- Radio
- NXP PN7160 NFC · Wi-Fi
- Display
- 2.4″ OLED · 128 × 64
- Input
- 3 × 4 keypad (detachable)
- Power
- USB-C · single-cell Li-ion
The idea
Digital cash that behaves like cash.
Cashu is an ecash protocol built on Bitcoin's Lightning Network. A mint issues tokens against Lightning payments using blind signatures, so it signs tokens it never sees. Whoever holds the tokens can spend them. There's no account and no balance on a server: the tokens are the money.
nucula keeps those tokens on a small circuit board. Paying someone works like handing over coins. The tokens move from one device to the other, and that is the whole transaction.
Pay a Lightning invoice
Any Lightning wallet can top up a nucula. The mint takes the payment…
The mint issues tokens
…and hands back blind-signed ecash. The mint can't tell who ends up holding it.
Tokens live on the device
Not in an account, not on a server. Whoever holds the device holds the money.
Tap to pass them on
Spending means handing tokens to someone else, over NFC or back out through Lightning.
Cashu over NFC
Tap, and the token moves.
- READ creqA…The phone reads a NUT-18 payment request from nucula.
- WRITE cashuB…The phone writes the token back to nucula.
- SWAP /v1/swapnucula swaps it at the mint, or verifies it offline and stashes it.
Numo made Cashu tap-to-pay real on Android point-of-sale devices. nucula speaks the same NDEF handshake, so a wallet that can pay Numo can pay nucula.
Why dedicated hardware
Why
nucula?
- CostAbout $23 in parts per board, at prototype quantities.
- FlexibilityOpen hardware, open firmware: change anything.
- IntegrationGoes inside machines that already exist.
- ExtensionAdds tap-to-pay to a point of sale that has no NFC.
- RobustnessA single-purpose device with no OS updates and no app store. It still receives offline.
Anything that takes (or used to take) coins.
Vending
Snacks, drinks, parts.
Ticketing
Transit, events, parking.
Laundromat
Washers, dryers.
Coin slots
Arcades, lockers, meters.
02 / 03
Hardware
Four layers, 128 parts, one I²C bus.
nucula-board · rev 2
One board.
Everything on the top side. The keypad section snaps off.
- Outline
- 60 × 110 mm
- Keypad section
- 60 × 35 mm · breakaway
- Layers
- 4 · FR-4 · 1.6 mm · ENIG
- Parts
- 128 · 55 unique · top side only
- License
- CERN-OHL-S-2.0
At the heart
ESP32-C3
A modern RISC-V microcontroller with Wi-Fi and Bluetooth LE on the die. Lean, and cheap.
- Core
- RV32IMC · single core · 160 MHz
- Memory
- 400 KB SRAM · 4 MB flash
- Radio
- Wi-Fi 4 · Bluetooth 5 LE
- Accelerators
- SHA · AES · RSA / MPI
- Module
- WROOM-02-N4 · $3.32
NFC
NXP PN7160
NFC controller with an integrated RF front end. It speaks NCI 2.0 over I²C and emulates a card.
- Interface
- I²C 0x28 · IRQ · VEN
- Mode
- Card emulation · ISO-DEP
- Antenna
- PCB coil · 40 × 40 mm · 4 turns
- Inductance
- ≈ 1.56 µH
- Matching
- → 20 Ω @ 13.56 MHz
Charging & power
Power path.
- Input
- USB-C · 5 V
- Charger
- TP4054 · 100 mA
- Battery
- Li-ion · ~400 mAh
- Select
- USB › battery
- Regulator
- SY8089 buck · 3.31 V
- Supervisor
- TLV803
Power stage adapted from Olimex ESP32-C3-DevKit-Lipo rev C · CERN-OHL-S
Input
Keypad,
detachable.
A PCF8574T 8-bit I/O expander scans a 3 × 4 matrix, so the keypad costs two pins on the MCU.
- Expander
- PCF8574T · I²C 0x20
- Breakaway
- 2 mouse-bite tabs · 28 × ⌀0.6 mm
- Bridge
- 3V3 · GND · SDA · SCL · INT
- Silkscreen
- “1 CUT BRIDGE / 2 SNAP”
Everything on one bus
Two wires.
Three chips.
- MCU
- ESP32-C3 · GPIO6/7
- NFC
- PN7160 · 0x28
- OLED
- SSD1309 · 0x3C
- Keypad
- PCF8574T · 0x20
100 kHz · each device probed at boot · all optional
Stackup
Four layers.
The NFC coil and signals are on top. The inner layers are ground. There is no copper under the coil.
Manufacturing cost
Keep it
standard.
- Standard 4-layer stackupNo impedance control ordered.
- Open 0.30 mm viasInstead of filled and capped vias. No via-in-pad.
- Single-sided assemblyAll parts on top: one stencil, one reflow.
- Basic parts where possible“Extended” library parts add setup fees.
Components only · excludes PCB, assembly, display, battery
03 / 03
Firmware
400 KB of RAM, one core and a lot of elliptic curves.
Build environment
C, C++ & ESP-IDF.
Component map
What runs where.
Features
What can it do?
Tap to receive
A payment request over NFC. The phone writes the token back.
Mint
Fund the wallet with a Lightning invoice.
Melt
Pay Lightning invoices from ecash.
3 mints
Up to 10 cached keysets each.
Offline receive
P2PK-locked, verified at tap time, stashed and redeemed when Wi-Fi returns.
DLEQ
Proofs are verified, not trusted.
Seed backup
BIP-39 from hardware entropy. Recover from twelve words.
Drain all
Every balance out as V4 tokens.
Speaks standard Cashu: any wallet that follows the NUTs can pay a nucula
One tap, step by step
Tap-to-pay flow.
- nuculaBuild a NUT-18 request (P2PK-locked if offline) and pre-warm TLS to the mint.
- READ BINARYThe phone reads creqA… from nucula.
- UPDATE BINARYThe phone writes cashuB… back.
- POST /v1/swapnucula swaps the proofs and verifies the mint's DLEQ.
- Received ✓The display confirms the payment.
Working around the hardware
Small, slow, and full.
mbedTLS dynamic buffers. One /v1/keys request instead of N. Bounded crypto scratch: a 10 KB stack frame became 3 KB.
One core at 160 MHz. The accelerators (SHA, RSA/MPI) are the only parallelism, so we use them.
The 4 MB flash holds a 1.52 MB image in a 1.81 MB slot. SoftAP and IPv6 were cut to save about 50 KB.
Crypto · secp256k1
Every µs counts.
Hardware compression hooked into libsecp256k1.
A 2 KB signing comb beat the 22 KB and 86 KB tables.
Joint scalar multiplication.
-Os beats -O3 because of icache.
Crypto · BLS12-381
BLS on a $3 chip.
Cashu v3 keysets use BLS signatures. A token checks out with one pairing:
e(C, G₂) = e(Y, K)
Fully offline. No DLEQ needed.
The trick: 384-bit Montgomery multiplication runs on the RSA accelerator. The CPU does Fp2 additions while the engine multiplies.
52 builds later
End to end.
| Operation | before | after | speed-up |
|---|---|---|---|
| 10-proof swap · crypto | 4,578 ms | 2,520 ms | 1.82× |
| BLS verify · 10 proofs / 10 keys | 1,886 ms | 960 ms | 1.97× |
| secp DLEQ verify · NUT-12 | 56.95 ms | 21.30 ms | 2.67× |
| Nutroot 8-of-15 threshold | 1,734 ms | 138 ms | 12.56× |
On-device, 160 MHz, crypto only. Rejected: whole-program LTO (2× slower), hardware inversion, hand-written asm.
Open hardware
Nothing
to buy.
Schematics, board layout, BOM and manufacturing files are all in the KiCad 10 project. The v2 board is a routed prototype for manual assembly; bring-up is still ahead.
- Design
- KiCad 10 · project-specific parts included
- Fabrication
- 4 layers · 1.6 mm · ENIG · Gerbers + drills
- Sourced separately
- OLED · keypad · battery
$ git clone https://github.com/zeugmaster/nucula-board.git
$ cd nucula-board
# check the schematic (needs kicad-cli)
$ python3 tools/check_schematic.py
$ kicad nucula-v2.kicad_proRemaining work
Not done yet.
- NFC tuningTune with a VNA toward 20 + j0 Ω, using the trim pads and removable TX links.
- Component sizeRF parts are 0805 / 1206 so they can be hand-tuned. Shrink them once the values are known.
- Bring-up & powerInrush current, charger heat, and battery runtime.
- EnclosureDisplay fit and ribbon routing.