Reddit Posts
We're searching for Bitcoin wallets generated with weak entropy from 2009-2012 — here's what early wallet software got wrong
Ever wondered how those "weak key" exploits actually work? I made a research tool for it
Can we use AES hardware acceleration to improve PCG or LCG generator?
Mentions
As I use Keystone, I got AI to review the actual code, it looks good: # Keystone3 Firmware RNG Security Analysis ## Executive Summary The Keystone3 firmware has a **robust, multi-source RNG architecture** that is **significantly more secure** than the Coldcard RNG vulnerability (which affected Coldcard Mk2/Mk3 v4, Mk4, Q, and Mk5 devices). The Keystone implementation uses **three independent hardware RNG sources XORed together**, making it resistant to the class of vulnerabilities that affected Coldcard. However, there are **several security concerns** worth noting: --- ## 1. RNG Architecture (Good) The Keystone firmware implements a strong `random_buffer()` in `src/managers/keystore.c`: ```c void random_buffer(uint8_t *buf, size_t len) { TrngGet(buf, len); // MCU hardware TRNG SE_GetDS28S60Rng(tempBuf1, len); // DS28C50 secure element SE_GetAtecc608bRng(tempBuf2, len); // ATECC608B secure element for (size_t i = 0; i < len; i++) { buf[i] ^= tempBuf1[i] ^ tempBuf2[i]; // XOR all three } } ``` This is a **defense-in-depth** approach: even if one source is compromised, the XOR with the other two maintains entropy. ### RNG Sources Used Across the Firmware: | Location | RNG Used | Purpose | |----------|----------|---------| | `keystore.c::random_buffer()` | TRNG ⊕ DS28C50 ⊕ ATECC608B | Wallet entropy, key generation | | `drv_trng.c::TrngGet()` | MCU hardware TRNG | Nonces, AES IVs, encryption keys | | `drv_atecc608b.c::Atecc608bGetRng()` | ATECC608B hardware RNG | SE operations, encrypted reads/writes | | `slip39.c` | `random_buffer()` (overridden) | Shamir secret splitting | | `data_parser_task.c` | `TrngGet()` | ECDH private keys for USB pairing | --- ## 2. Critical Difference from Coldcard Vulnerability The **Coldcard vulnerability** (Block/Coinkite, July 2026) was caused by: - `MICROPY_HW_ENABLE_RNG` defined as `0`, disabling hardware RNG - Libngu's `#ifndef` check passed (macro exists, but value is 0) - Fell back to a **deterministic Yasmarang PRNG** seeded from UID + timer - Secure-element reseed only updated 32 bits of state **Keystone does NOT have this vulnerability** because: - It does not use MicroPython or libngu - It directly calls hardware TRNG peripherals - It never has a software PRNG fallback path - The `mh_rand.c` LCG is explicitly guarded by `#ifndef RAND_PLATFORM_INDEPENDENT` and is only for testing --- ## 3. Security Concerns Found ### 3.1 Trezor Crypto RNG Comment (Low Risk — Mitigated) The file `src/crypto/slip39/trezor-crypto/rand.c` contains: ```c #pragma message("NOT SUITABLE FOR PRODUCTION USE! Replace random32() function with your own secure code.") static uint32_t seed = 0; // LCG with zero initial seed ``` **However**, Keystone overrides the weak `random_buffer()` via the `__attribute__((weak))` mechanism in `keystore.c`. In production builds (`#ifndef COMPILE_SIMULATOR`), the strong triple-RNG version is used. **This is a documentation/code hygiene issue, not an active vulnerability.** ### 3.2 MCU TRNG: No Health Checks The `TrngGet()` function in `drv_trng.c` simply reads from the TRNG data register: ```c void TrngGet(void *buf, uint32_t len) { for (uint32_t i = 0; i < len; i += 16) { TRNG_Start(TRNG0); while (0 != TRNG_Get(buf4, TRNG0)); // Wait for S128 memcpy((uint8_t *)buf + i, buf4, 16); } } ``` - The TRNG does have an **attack detection flag** (`RNG_CSR_ATTACK`), but it is **not checked** in the production `TrngGet()` path - If the TRNG detects an attack, the data may be invalid but is still returned - The `mh_rand.c` does have `mh_trand_buf_attack_get()` but it's not wired into the main entropy flow **Risk**: If the MCU TRNG is under attack (e.g., voltage glitching), corrupted random data could be used. ### 3.3 Dice Roll Validation is Heuristic The dice roll feature validates entropy quality with: - Minimum length check (50 for 128-bit, 100 for 256-bit) - Maximum frequency check: no single digit > 30% of total rolls This is a **statistical heuristic**, not cryptographic validation. A user who deliberately inputs biased rolls (e.g., "111111...") would be caught, but the validation is not rigorous (e.g., no chi-squared test, no NIST SP 800-22 compliance). ### 3.4 Slip39 Uses `random_buffer()` for Shamir Shares `slip39.c` calls `random_buffer()` for Shamir secret splitting: ```c random_buffer(tempShare[i], enMasterSecretLen); ``` This is OK because Keystone overrides the weak RNG. But if a build configuration accidentally uses the platform-independent (weak) version, Shamir shares would be predictable. ### 3.5 No Periodic Re-seeding The RNG does not periodically re-seed. Once initialized, the TRNG continues producing data, but there's no mechanism to detect TRNG degradation over the device's lifetime. --- ## 4. Comparison: Keystone vs Coldcard RNG | Aspect | Keystone3 | Coldcard (vulnerable) | |--------|-----------|----------------------| | Primary RNG | MCU TRNG + 2 SE chips | STM32 hardware RNG (disabled in fallback) | | Fallback | None | Deterministic Yasmarang PRNG | | Entropy sources | 3 independent hardware sources | 1 (when working) | | RNG composition | XOR of 3 sources | Single source or fallback | | Re-seed mechanism | Not needed (always hardware) | 32-bit reseed (weak) | | Attack detection | Present but not enforced | None in fallback path | | Software PRNG risk | None (overridden) | **Critical** (deterministic) | --- ## 5. Recommendations 1. **Enforce TRNG attack detection**: Check the `RNG_CSR_ATTACK` flag in `TrngGet()` and refuse to return data if an attack is detected. 2. **Add NIST SP 800-22 statistical tests**: Run periodic self-tests on RNG output to detect degradation. 3. **Remove or clearly mark the weak LCG**: The trezor-crypto `rand.c` should be excluded from production builds via build flags, not just relied upon to be overridden. 4. **Add entropy health monitoring**: Periodically verify that all three RNG sources are producing valid entropy. 5. **Improve dice roll validation**: Add a proper statistical test (chi-squared, runs test) rather than just frequency checks. --- ## Conclusion **The Keystone3 firmware does NOT suffer from the Coldcard RNG vulnerability.** Its triple-source hardware RNG design is fundamentally different and more secure. The primary RNG path in production always uses hardware entropy from three independent sources. The known weak RNG code (trezor-crypto LCG) is only used in simulator/test builds and is overridden in production. The main remaining concerns are: - TRNG attack detection not enforced in the production path - No periodic self-testing of RNG health - Heuristic-only dice roll validation These are **defense-in-depth improvements** rather than critical vulnerabilities.
That's used to be the case. But (collectible) CCG's like MTG are now falling out of fashion with a big chunk of the gaming community. LCG's are now increasingly popular. Netrunner, Marvel Champions, Lord of the Rings, Star Wars: The Card Game, Arkham Horror, etc. The "random-element" and artificial rarity is no longer in fashion. People want to just play the game, not spend their entire salary just to buy the one card you need to own before you can win.
Imaging we're the generation that got rich with crypto and the next generation LCG (lost century generation) will blame us for all the inherited problems like global warming and the future shity financial system