Cryptographic key generation using weak pseudorandom number generators (PRNGs) is a critical security vulnerability in blockchain systems. This analysis examines the architectural flaws of the function random_key
, the mechanisms for exploiting them, and the implications for cryptocurrency wallets.
Theoretical Foundations of PRNG Vulnerabilities
Cryptographic requirements for PRNG :
- Statistical indistinguishability from true randomness 3
- Unable to restore previous states of generator 3
- Defense against future state prediction 3
In the ECDSA algorithm used in Bitcoin, the random number k
plays a key role in the signature formation. Its reuse or predictability allows the private key to be calculated using the formula:
s=k−1(H(m)+rd)mod Ns = k^{-1}(H(m) + rd) \mod Ns=k−1(H(m)+rd)modN
where the leak k
makes the equation solvable with respect to d
(the private key) 2 .
Analysis of typical vulnerabilities
Attack Type | Implementation mechanism | Example from practice |
---|---|---|
Weak entropy seed | Using time as an initial value | Cakewallet (2018-2021)1 |
Algorithmic bookmarks | Deliberate leakage of PRNG states | The Case of BitcoinJS 6 Library |
Restoring the state | Output Sequence Analysis | Windows XP PRNG 3 attack |
In the case of the BitcoinJS library, which used Math.random()
browsers, predictability was enhanced by:
- Limited entropy pool (48 bits instead of 128) 6
- Deterministic Algorithms in Chrome 2011-2015 6
- Cascading errors in JSBN and SecureRandom 6
Practical implications
- Cakewallet Incident (2021):
Generation of 95 million potentially vulnerable addresses over 3 years, with the possibility of brute-force testing on average equipment in a few months 1 . - Randstorm Vulnerability :
21,000 BTC (~$750M as of 2023) discovered in wallets with keys generated via vulnerable PRNG 6 . k
Bitcoin Duplication Statistics :
Recommendations for improvement
- Hardware entropy sources :
Using TRNG (Thermal Noise RNG) with a minimum speed of 2 bits/sec 5 . - Cryptographic protocols :
Implementation of BKRNG type algorithms with a cyclobyte performance of 277.96 cycles/byte versus 546.72 for CTR_DRBG 5 . - Implementation verification :
Experimental data show that switching to deterministic BIP-32 key generation schemes with HMAC-SHA512 reduces the predictability risk by 3 orders of magnitude compared to legacy solutions 4 . Modern implementations such as FIPS 140-3 Level 3 provide protection even when the generator state is compromised through continuous test verification mechanisms 5 .
Citations:
- https://dzen.ru/a/ZZ7rl5jhoGyK-Bsj
- https://habr.com/ru/articles/430240/
- https://kiwibyrd.org/2013/06/06/0712/
- https://phemex.com/ru/academy/public-key-vs-private-key
- https://www.oaepublish.com/articles/jsss.2023.45
- https://www.kaspersky.ru/blog/vulnerability-in-hot-cryptowallets-from-2011-2015/36592/
- https://www.itsec.ru/articles/upravlenie-uyazvimostyami-v-kriptokoshelkah
- https://vc.ru/education/1575030-pochemu-ne-sushestvuet-sluchainosti-v-kompyuterah-i-blokcheine
- https://habr.com/ru/articles/773412/
- https://tangem.com/ru/blog/post/entropy/
- https://cryptomus.com/ru/blog/how-to-secure-your-crypto-wallet
- https://habr.com/ru/articles/771980/
- https://ru.tradingview.com/news/forklog:3031939c867b8:0/
- https://wiki.pztrn.name/software/qemu/not_enough_entropy/
- https://www.computerra.ru/183451/prng/
- https://crypto.stackexchange.com/questions/113456/can-we-construct-a-cpa-secure-scheme-with-a-prng-and-a-random-key
- https://ru.wikipedia.org/wiki/%D0%9A%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8_%D1%81%D1%82%D0%BE%D0%B9%D0%BA%D0%B8%D0%B9_%D0%B3%D0%B5%D0%BD%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80_%D0%BF%D1%81%D0%B5%D0%B2%D0%B4%D0%BE%D1%81%D0%BB%D1%83%D1%87%D0%B0%D0%B9%D0%BD%D1%8B%D1%85_%D1%87%D0%B8%D1%81%D0%B5%D0%BB
- https://blog.whitebit.com/what-is-a-private-key-in-crypto/
- https://www.h-x.technology/ru/blog-ru/top-blockchain-security-threats-in-2024-ru
- https://intuit.ru/studies/courses/3520/762/lecture/32518
- https://www.smart-soft.ru/blog/informatsionnaja-bezopasnost/
- https://ru.stackoverflow.com/questions/523929/%D0%93%D0%B5%D0%BD%D0%B5%D1%80%D0%B0%D1%86%D0%B8%D1%8F-%D0%BA%D0%BB%D1%8E%D1%87%D0%B0-%D0%BF%D0%BE%D1%81%D1%80%D0%B5%D0%B4%D1%81%D1%82%D0%B2%D0%BE%D0%BC-securerandom-getinstancestrong
- https://vc.ru/dev/62779-generatory-sluchainyh-chisel-v-smart-kontraktah
- https://encyclopedia.pub/entry/30451
- https://firstvds.ru/technology/kak-sozdat-klyuch-dlya-avtorizacii-po-ssh-i-dobavit-ego-na-server
- https://habr.com/ru/companies/distributedlab/articles/413627/
- https://tangem.com/ru/blog/post/how-to-create-a-private-key-for-a-crypto-wallet-with-and-without-a-seed-phrase/
- https://ru.wikipedia.org/wiki/%D0%91%D0%B8%D1%82%D0%BA%D0%BE%D0%B9%D0%BD