RailBao

Rust and in-browser Railgun wallet for private Ethereum transactions, signed on a Xous dabao device

RailBao

Created At

ETHGlobal Mumbai

Winner of

Ethereum Foundation

Ethereum Foundation - Best CROPS Upgrade to an Existing Project

Project Description

RailBao is a Railgun privacy wallet written in Rust. It runs either as a local daemon with a web interface or as a static website, where the wallet engine is compiled to WebAssembly and runs entirely in the browser. For this hackathon we added a hardware signer: a dabao board running the Xous microkernel. It holds the Railgun spending and viewing keys and signs private transfers with Poseidon-EdDSA. It also signs the Ethereum transactions of the public account. The browser talks to it over WebHID with a small CBOR protocol.

How it's Made

Device side. The signer is a Rust app for Xous, the microkernel that runs on Baochip's dabao board. It reuses an earlier dabao Ethereum burner wallet developed for Devcon 8 workshops. That brings the seed (created from the chip's random number generator on first boot and kept in on-chip ReRAM), the USB HID transport, and a CBOR protocol that wraps ERC-4527 Ethereum signing requests. We added Railgun commands to it:

  • Key derivation: SLIP-10 at the same derivation paths the Railgun engine uses.
  • Spending key: BabyJubJub, signing with Poseidon-EdDSA (from ZKNox's kohaku-crypto).
  • Viewing key: ed25519, which the wallet can export.
  • Address: the device builds the full 0zk Railgun address.

Host side. rsgun-wallet is a Rust wallet on the kohaku Railgun SDK. We added a railgun-dabao crate with:

  • the protocol client;
  • three transports: native HID, TCP to the Xous emulator, and a WebHID bridge;
  • a signer type that plugs in exactly where the existing Ledger signer does;
  • an alloy transaction signer for the public Ethereum account.

The wallet runs either as a local daemon or as a static site, with the engine compiled to WebAssembly and running in a Web Worker. The browser build uses Waku to talk to Railgun broadcasters.

How the partner tech helped. Because kohaku's signer interface is generic, the dabao became a drop-in alternative to a Ledger. Railgun's engine fixed the derivation paths, and its proof of innocence and broadcaster networks worked unchanged.

Hacky bits:

  • Firmware too big: the dabao's app region is 873 KiB, and the Poseidon hash library's constant tables pushed the firmware to 1,041 KiB. We copied the library into the repo and kept only the 2- to 6-input variants Railgun uses, bringing the firmware down to 805 KiB.
  • WebHID from a Web Worker: browsers don't let a worker use WebHID. The page owns the device, and the worker exchanges raw 64-byte reports with it through message passing.
  • Ethereum signature recovery: the Ethereum signature's recovery bit is found by trying both values against the device's address.
  • Every reply is checked: the host recomputes the 0zk address from the exported keys and verifies every Railgun signature.

Everything was tested end to end on Sepolia (shield, private transfer, unshield).

background image mobile

Join the mailing list

Get the latest news and updates

RailBao | ETHGlobal