Keystone
Keystone's published firmware, checked against its published source with cverif. No device has a verification target yet: below are our research notes on the release channel, image format and build.
About Keystone's firmware
Repository: https://github.com/KeystoneHQ/keystone3-firmware. Facts below were checked against master at commit bd06fe2e (2026-11-26), tag 4.0.2 (commit 5db5cf2e), and the published 4.0.2 Bitcoin-only file. Research date: 2026-12-04.
Verdict: possible, low priority. The application image can be extracted from the release file and matches the vendor's published build hash (checked here), and the build is reproduced by WalletScrutiny. But the MCU is a Chinese security MCU with closed parts, the bootloader is closed and travels inside the release file, most of the wallet logic is Rust, and the build is heavy and only loosely pinned. cverif would cover the C side: FreeRTOS, drivers, UI, secure-element drivers, the BIP-39/SLIP-39 code and the firmware-update code.
1. Device, MCU, published images
| item | value | source |
|---|---|---|
| device | Keystone 3 Pro (firmware "G3"); three editions: Multi-coin ("web3"), Bitcoin-only, Cypherpunk | build.py (-t btc_only, -t cypherpunk), release notes |
| MCU | MegaHunt MH1903, built as Cortex-M4 with FPv4-SP, hard-float ABI | README.md; firmware.cmake (-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16) |
| application address | 0x01081000 (external QSPI flash, executed in place) | mh1903b.ld (FLASH ORIGIN = 0x01081000); src/boot_update.c (APP_ADDR) |
| bootloader | at 0x01001000, not open source | src/boot_update.c (BOOT_ADDR) |
| secure elements | Microchip ATECC608A, Maxim DS28C50, Maxim MAX32520 | README.md |
Whether the MH1903 core is an Arm Cortex-M4 or a licensed Arm core sold under another name (SecurCore) was not established here; the compiler is told cortex-m4 with an FPU, which is what cverif will use.
Published images: only the application update file keystone3.bin, one per edition. It contains the application and, appended, a signed bootloader update (boot.sig) that is not in the public repository (section 3). Secure-element firmware is the chip vendors' and is not published.
2. Release channel
- Download: https://keyst.one/firmware (a script-driven page) links to
https://keyst.one/contents/KeystoneFirmwareG3/v<version>/<edition>/keystone3.binwith<edition>inweb3,btc_only,cypherpunk(for 4.0.2; 3.9.9 also haslegacy_ota, purpose not checked). During this research the CDN (CloudFront) answered HTTP 403 to requests with curl's default User-Agent and served the files to a browser-like one. - GitHub releases (https://github.com/KeystoneHQ/keystone3-firmware/releases) have no assets: the body gives, per edition, the sha256 of the signed
keystone3.binand a "Source Code SHA-256 Checksum", which is the sha256 of the build outputmh1903.bin(checked below). The device can display the same value (guide.keyst.one/docs/verify-checksum; computation insrc/ui/gui_model/gui_model.c). - Tags: plain version numbers (
4.0.2,3.2.2, …), lightweight (not annotated, not signed). Release branchesrelease/vX.Y.Zexist for some versions. No release names a commit; the tag is the only link. 3.9.9, 4.0.0 and 4.0.2 were all published on 2026-11-24. - No detached signature or PGP; the vendor signature is inside the file.
Checked on 4.0.2 Bitcoin-only: the downloaded file (3667811 bytes) has sha256 155ac40a…dd147c2, as in the GitHub release body.
3. Image format
From tools/code/firmware-maker/src/main.rs (the open-source "OTA maker"), tools/code/firmware-checker/src/main.rs, tools/padding_bin_file/padding_bin_file.py, build.py, and the published file:
keystone3.bin = u32 LE header length (348)
‖ header
‖ 0x00
‖ QuickLZ level-3 stream, one block per 16 KiB of mh1903_full.bin
header = "~fwdata!"
‖ u32 BE compressed size ‖ u32 BE original size
‖ sha256(compressed stream) ‖ sha256(mh1903_full.bin)
‖ u32 BE encode = 1 ‖ u32 BE unit = 16384 ‖ u32 BE encrypt = 0
‖ signature, 256 ASCII hex characters (empty in an unsigned file)
mh1903_full.bin = mh1903.bin (the application, at 0x01081000)
‖ "mh1903bootupdate" ‖ u32 BE len(boot.sig) ‖ sha256(boot.sig)
‖ boot.sig[0:0x134] ‖ 0xFF to a 4 KiB boundary
‖ boot.sig[0x134:] ‖ 0xFF to a 4 KiB boundary- The signature's algorithm and what it covers are decided by the closed bootloader; not determined here. The unsigned file the vendor tool makes differs from the release in the header length and the signature only.
boot.sig(the bootloader update, 404188 bytes in 4.0.2) is copied in bybuild.pyfromtools/boot.sigif present; it is not in the public tree, so a local build givesmh1903_full.bin=mh1903.binand the release's appended part cannot be reproduced. The running application installs it (src/boot_update.c, which looks for themh1903bootupdatemarker in flash at 4 KiB steps).- To compare with a local build: decompress, check both header hashes, cut at the 4 KiB-aligned
mh1903bootupdaterecord (the first match in the data is a string inside the application, at an unaligned offset), compare the part before it withmh1903.bin.
Checked on 4.0.2 Bitcoin-only, with a small QuickLZ decompressor written for this: both header hashes match; the decompressed image is 5812224 bytes; the boot-update record starts at 0x526000; the 5398528 bytes before it have sha256 e340360f…6fdc465, the release's "Source Code SHA-256 Checksum" for Bitcoin-only. The vector table gives initial SP 0x20005e10 and reset handler 0x0112ded5, inside the application range.
4. Build
- Documented procedure (
docs/verify.md): clone,git -c submodule.keystone3-firmware-release.update=none submodule update --init --recursive(that submodule is private),docker pull keystonehq/keystone3_baker:1.0.2(or build theDockerfile),git checkout tags/<tag>, thendocker run -v $(pwd):/keystone3-firmware keystonehq/keystone3_baker:1.0.2 python3 build.py -e production [-t btc_only | -t cypherpunk]; comparesha256sum build/mh1903.binwith the release's source checksum. A machine with 16 GB RAM (32 GB recommended) is required. - Environment (
Dockerfile):ubuntu:22.04with unpinned apt packages, Rust installed with rustup and the toolchain fromrust-toolchain(nightly-2026-05-22atmaster),cbindgenandbindgen-cliinstalled without version pins, GNU Arm9-2019-q4-majordownloaded by URL (no hash check). The image is referenced by tag (1.0.2), not digest. On Docker Hub that tag was last pushed on 2024-04-28 (digestsha256:9d54ee99…), whilerust-toolchainhas changed since (2025-03, 2025-07, 2026-04, 2026-07): the image's rustup presumably installs the newer nightly named in the repository at build time (network access during the build); not checked. - Build system:
build.py→ CMake (-DLIB_RUST_C=ON -DBUILD_PRODUCTION=true -DRU_SUPPORT=true, plus-DBTC_ONLY/-DCYPHERPUNK) →make -j; Cargo buildslibrust_c.a(rust/rust_c), linked with the C objects and the prebuiltexternal/mh1903_lib/MHSCPU_Driver/lib/MH1903_QRDecodeLib.a. C flags:-Os(fromMCU_FLAGS),-ffunction-sections-style section flags,--gc-sections, newlib nano. - Reproducibility: claimed by the vendor (
docs/verify.md). WalletScrutiny (https://old.walletscrutiny.com/hardware/keystone3.pro) reports 1.6.0 (2024-08), 1.7.12 (2024-12-10) and 2.0.0 (2025-02-21) as reproducible; the current page (https://walletscrutiny.com/hardware/keystone3.pro/, dated 2026-10-30) says its reviewers built 3.2.0 Multi and Bitcoin-only and that the payloads matched (as read from the page; not reproduced here).
5. Language split
Rough line counts at master: about 130k lines of first-party C and headers in src/ (plus about 127k lines of generated image/font tables in src/ui/gui_assets), about 140k lines of Rust in rust/, and about 730k lines of vendored C in external/ (LVGL, SQLite, FreeRTOS, cryptoauthlib, cJSON, ctaes, FatFs, safec, the MH1903 drivers and USB stack).
- Rust (out of scope): per
README.md, "most of the blockchain-related functionality … including transaction signing, address generation, and cryptographic operations" (rust/apps/*,rust/keystore,rust/rust_c). Its dependency tree includessecp256k1-sys(libsecp256k1 in C, compiled by thecccrate), so some C ends up inside the Rust static library. - C (in scope): FreeRTOS and tasks, drivers (
src/driver, including the secure-element drivers such asdrv_atecc608b.c), key storage and settings (src/managers/keystore.c), BIP-39 and SLIP-39 (src/crypto/bips,src/crypto/slip39), firmware and bootloader update (src/boot_update.c), USB/WebUSB protocol, the LVGL UI and its assets. - Closed: the bootloader,
MH1903_QRDecodeLib.a, the MCU's ROM, the SE firmware.
Best cverif targets: src/managers/keystore.c, the SE drivers, SLIP-39/BIP-39, and the update path (boot_update.c), which decides what gets written to the bootloader area.
6. Plan for targets/keystone/keystone3-btc.sh (and -multi, -cypherpunk)
| step | what to do |
|---|---|
t_releases | GitHub releases API (tags), keeping those whose body has the checksum sections |
t_fetch | download keyst.one/contents/KeystoneFirmwareG3/v<ver>/<edition>/keystone3.bin; record its sha256 and the two hashes from the GitHub release body for that edition; check the file hash |
t_source | clone tag <ver> with public submodules (skip keystone3-firmware-release); the tag is lightweight and no commit is published, so record the resolved commit only |
t_build | python3 build.py -e production -t <edition> in keystonehq/keystone3_baker:1.0.2, compare mh1903.bin with the release's source checksum; instrumented rebuild with wrappers for arm-none-eabi-gcc/ar (CMake and Cargo's cc crate) |
t_extract | new fwimage.py keystone3 parser: header, QuickLZ decompression (level 3, 16 KiB blocks; about 60 lines of Python), both header hashes, split at the aligned boot-update record; code.bin at 0x01081000; the boot-update record reported as unverified (closed bootloader); cpu = cortex-m4 with FPv4, hard-float |
t_verify, t_report | as usual; report Rust and closed bytes separately |
Expected difficulties:
- The bootloader is closed and the release file carries a new one each time; nothing in this pipeline can say anything about it, and the signature check that protects the device is in it.
- Most of the wallet logic is Rust; as for BitBox02, C objects from
ccinside the Rust static library need special handling in the bundle exporter. - Build environment: unpinned tools, a mutable image tag, a nightly Rust, network access during the build, and a large memory footprint. Old releases may not rebuild identically; the fallback is
--discoverwith the bundle. - The MH1903 is not an ST or Microchip part: no public reference manual was checked here for its memory map, and peripheral accesses through vendor driver code (
external/mh1903_lib) are verified as written in C only. - Three editions per release, each a separate build and target.
Priority: low. After KeepKey, BitBox02 and the Coldcard bootloader.