Collision attacks, in the context of cryptocurrencies such as Bitcoin, are attempts to crack cryptographic keys by finding matches (collisions) between different keys. One common problem when generating private keys is using a function secrets.randbelow(N)
with an invalid value N
, which can result in about 50% of the generated keys being out of range. This can make the keys mathematically invalid and potentially vulnerable to attack.
Theoretical basis
Private Keys in Bitcoin
In Bitcoin, private keys are used to create digital signatures that prove ownership of a certain amount of bitcoin. These keys are randomly generated and must be within a certain range to be valid. Private keys are integers between 1 and $$2^{256} – 1$$, which provides a huge number of possible keys and makes them virtually invulnerable to brute force attacks.
Functionsecrets.randbelow(N)
The function secrets.randbelow(N)
is used to generate random integers in the range from 0 to N-1
. If N
does not match the allowed range for Bitcoin private keys, some of the generated keys may be outside this range. For example, if N
is less than the maximum allowed value, the keys will be shorter and potentially vulnerable. If N
is greater than the maximum allowed value, some of the keys will be too long and cannot be used directly.
Collision attacks
Collision attacks aim to find two different inputs that produce the same output hash. In the context of Bitcoin, such attacks can be used to find two different private keys that correspond to the same public key. However, due to the huge key space and the cryptographic strength of the algorithms used in Bitcoin, such attacks are virtually impossible with modern computing power.
Practical implications
Vulnerabilities in Key Generation
If private keys are generated using a function secrets.randbelow(N)
with an invalid value N
, this can lead to several problems:
- Incorrect Keys : If keys are too short or too long, they cannot be used to create valid transactions.
- Vulnerability to attacks : While collision attacks are unlikely in Bitcoin, using incorrect keys can increase the risk of a successful attack if an attacker can exploit weaknesses in key generation.
Defense against attacks
To protect against potential attacks, it is important to:
- Use Correct Values
N
: Ensure that the keys generated are within the acceptable range. - Use cryptographically strong algorithms : Ensure that key generation algorithms are secure and not susceptible to known vulnerabilities.
- Update software regularly : Update wallet and library software to avoid using outdated or vulnerable versions.
Conclusion
Collision attacks in Bitcoin are a theoretical threat, but are unlikely in practice due to the large key space and the cryptographic strength of the algorithms used. However, using a function secrets.randbelow(N)
with an incorrect value N
can result in the generation of incorrect keys, which potentially increases vulnerability to attacks. Therefore, it is important to use the correct values N
and ensure the security of the keys generated.
References
- ForkLog . The Big Bitcoin Collider Threatens Users with Wallet Hacks.[2]
- Bits.media . Blockchain Collider: Is It Possible to Find Bitcoin Keys Using Brute Force?[3]
- SecurityLab . Blockchain: attacks, security and cryptography.[6]
Citations:
[1] https://www.rbc.ru/crypto/news/5f5a51fc9a794796c6dff0be
[2] https://forklog.com/news/bolshoj-bitkoin-kollajder-ugrozhaet-polzovatelyam-vzlomom-koshelkov
[3] https://www.bits.media/blokcheynovyy-kollayder-vozmozhno-li-nayti-klyuchi-bitkoina-s-pomoshchyu-brutforsa/
[4] https://ru.tradingview.com/news/forklog:3031939c867b8:0/
[5] https://www.kaspersky.ru/blog/vulnerability-in-hot-cryptowallets-from-2011-2015/36592/
[6] https://www.securitylab.ru/blog/personal/%20Informacionnaya_bezopasnost_v_detalyah/343072.php
[7] https://habr.com/ru/articles/685720/
[8] https://rt-solar.ru/upload/iblock/3c3/report_incode_crypto_wallet.pdf