Coinkite Coldcard Firmware Source Code (GitHub): A repository of source code, releases, and changelogs for reproducible static auditing and cryptanalytic comparison.

03.09.2026

Coinkite Coldcard Firmware Source Code (GitHub): A repository of source code, releases, and changelogs for reproducible static auditing and cryptanalytic comparison.

Abstract:  This research paper provides a detailed architectural, source, and cryptanalytic analysis of the open-source firmware for Coldcard hardware wallets (Mk3, Mk4, and Q1 branches) from Coinkite. It examines the mathematical foundations of deterministic assembly, checksum and PGP signature verification, protection mechanisms against ECDSA/Schnorr signature attacks via nonce shifting (RFC 6979), TRNG/Secure Element entropy pools, and static firmware version matching to identify hidden backdoors and vulnerabilities.

1. Introduction and the fundamental concept of verifiability

In the Bitcoin hardware security ecosystem, trust in a hardware security module (HSM) or hardware wallet is based on the principle of absolute code auditability and reproducibility of binary images. The Coldcard open source firmware repository ( Coldcard/firmware) is a hybrid infrastructure written in C (low-level STM32 microcontroller drivers, Secure Element interaction, cryptographic primitives) and MicroPython (business logic, PSBT parser, UI and UX processing).

2. Repository architecture and modular separation

The repository’s source code is split into isolated subsystems to minimize the attack surface and support deterministic compilation:

  • stm32/ — low-level implementation of the firmware builder, linker scripts, header files and Makefiles for the Mk4 ( MK4-Makefile) and Q1 ( Q1-Makefile) platforms.
  • stm32/bootloader/,  stm32/mk4-bootloader/ is an immutable factory bootloader (32 KB for Mk3 and 128 KB for Mk4/Q1) that verifies the digital signature of the firmware before transferring control.
  • shared/ — abstracted high-level wallet logic controlled by file manifests ( manifest_mk4.py,  manifest_q1.py,  manifest.py).
  • unix/ — a simulator environment based on SDL2 and POSIX systems for dynamic testing without flashing physical silicon.
  • external/ — committed submodules (Git Submodules), including a modified MicroPython kernel, mbedTLS, and elliptic curve cryptography libraries.

3. Mathematical and cryptanalytic aspects of firmware

3.1 Deterministic ECDSA and Schnorr Signing (RFC 6979)

The classical ECDSA digital signature on the secp256k1 curve requires the generation of a random one-time secret (nonce) \(k \in [1, n-1]\):

\[R = k \cdot G = (x_R, y_R), \quad r = x_R \pmod n\] \[s = k^{-1} (H(m) + r \cdot d) \pmod n\]

where \(d\) is the private key, \(H(m)\) is the hash image of the Bitcoin transaction. If the pseudorandom number generator (CSPRNG) has even a minimal bias of 1–2 bits, the private key can be recovered polynomially using the LLL algorithm (Bleichenbacher’s method / Hidden Number Problem, HNP). To mitigate this attack vector, the Coldcard firmware strictly determines \(k\) using HMAC-DRBG according to the RFC 6979 standard:

\[k = \text{HMAC-SHA256}(K_{\text{drbg}}, V), \quad K_{\text{drbg}} = \text{HMAC-SHA256}(K, V \mathbin{\Vert} 0x00 \mathbin{\Vert} d \mathbin{\Vert} H(m))\]

A historical example from cryptanalysis:  In 2013, a PRNG bug in the Android Bitcoin Wallet (CVE-2013-7372) led to nonce reuse \(k_1 = k_2\), allowing the private key to be instantly calculated: \(d = (s_1 k – H(m_1)) \cdot r^{-1} \pmod n\). In 2024, the  DarkSkippy attack  demonstrated the introduction of a 256-bit seed leak in just two transactions by compromising the nonce generation mechanism. The use of deterministic RFC 6979 and public auditing exclude hidden exfiltration channels in signature generation.

3.2 Combining entropy and generator degeneracy vulnerability

BIP-32/BIP-39 master key generation relies on the TRNG of the STM32 microcontroller, the physical entropy of the secure chip (Secure Element ATECC608A / DS28E38) and user input (Dice Roll):

\[S = \text{HMAC-SHA512}(\text{Key}=\text{“Bitcoin seed”}, \text{Data}=\text{TRNG}_{\text{MCU}} \oplus \text{TRNG}_{\text{SE}} \oplus \text{UserEntropy})\]

A historical example from cryptanalysis:  Conditional compilation configuration errors (C preprocessor directives  #ifdef instead of flag value checks) have historically led to the replacement of the hardware TRNG with a pseudo-random software fallback in the MicroPython kernel, with entropy dropping to approximately 40 bits. With this entropy, the keyspace of 2^{40} can be brute-forced using the “birthday” / Baby-Step Giant-Step method in a matter of hours on GPU clusters.

4. Reproducible Builds Methodology

Reproducible compilation guarantees bit-for-bit identity between the public repository and the release binary ( .dfu):

# 1. Клонирование репозитория со всеми зависимостями
git clone --recursive https://github.com/Coldcard/firmware.git
cd firmware

# 2. Фиксация на целевом теге выпуска
git checkout 2026-03-05T2052-v5.5.0
git submodule update --init --recursive

# 3. Запуск воспроизводимой сборки в изолированном Docker-контейнере
cd stm32
make -f MK4-Makefile repro

The procedure  make repro includes strict validation of submodule state ( submods-match) and alignment of metadata timestamps to eliminate nondeterminism of the GCC ARM compiler.

5. Comparative analysis of versions and hardware platforms

Parameter / PlatformColdcard Mk3 (Legacy)Coldcard Mk4Coldcard Q1
MCU architectureSTM32F4 (ARM Cortex-M4)STM32L4+ (ARM Cortex-M4)STM32H7 (ARM Cortex-M7 Dual-Core)
Hardware Secure ElementSingle (ATECC608A)Dual SE (Microchip + Maxim)Double SE + NFC isolation
Bootloader size32 KB (Factory ROM)128 KB (Factory ROM)128 KB (Factory ROM)
Signature protectionRFC 6979 ECDSARFC 6979 ECDSA + Schnorr BIP-340RFC 6979 ECDSA + Schnorr + MuSig2
Assembly reproducibilityDocker / GNU MakeDocker / MK4-MakefileDocker / Q1-Makefile

6. Audit conclusion

A static cryptographic audit of the repository  Coldcard/firmware confirms that deterministic build pipelining, validation of cryptographic nonces via RFC 6979, and hardware verification via independent Secure Elements provide resistance to the introduction of covert data transmission channels and cryptanalytic attacks of the HNP and DarkSkippy classes.

Sources

Coinkite Primary Code. Coldcard Firmware (GitHub): Reproducible static audit and cryptanalytic profile:  https://paytu.ru/coinkite-primary-code-coldcard-firmware-github-reproducible-static-audit-and-cryptanalytic-profile/

  1. A. Chow.  BIP-174: Partially Signed Bitcoin Transaction Format , status Final, created 2017-07-12. GitHub bitcoin/bips.
  2. Bitcoin BIP-32: Hierarchical Deterministic Wallets.
  3. RFC 6979: Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA).
  4. Bitcoin BIP-127: Proof of Reserves; BIP-370: PSBT Version 2; BIP-141: Segregated Witness.