Hey everyone, wanna share some code I wrote. Might be useful if you’re into crypto security!
So, it generates a private key using a random number between 2^204 and 2^256 for crypto and prints it straight to a receipt printer. No saving is done on the computer.
If you find this amusing, drop a note!
Check out the demo video I made!
Generating Wallets and Printing Them Securely
7 replies 399 views
Wait, are you saying it doesn’t store data on disk?
I think it’s temporarily stored in memory, which means it can be accessed by software with the right permissions.
Your approach might not boost security, especially since you're sending the key to a printer that often has closed firmware.
Not worried about that. If you don’t know your gear, that’s on you. A malicious actor could look at anything on your PC, even banking info.
gwei_blockNewbie
Posts: 185 · Reputation: 37
#4Jan 11, 2025, 09:12 PM
I see a potential problem in your code. It looks like it could generate private keys outside the valid range.
A Bitcoin private key should be between 1 and n-1, where n is the generator point in hex.
Sure, the chances are slim, but it’s not impossible if your code is right. Might throw errors down the line when generating public keys.
As long as secp256k1 is solid, I’m cool with the code.
A tiny wallet possible is still way larger than Bitcoin's biggest puzzles. Plus, keep your cryptos safe by never sending from wallets you’ve used before. Always go for a fresh private key for unspent funds.
gwei_blockNewbie
Posts: 185 · Reputation: 37
#6Jan 13, 2025, 05:24 AM
Yeah, secp256k1 has been considered secure for ages.
But your code doesn’t stop generating out-of-bounds numbers, which leads to invalid private keys.
Good luck hoping the library catches these edge cases because I’m not counting on that.
I fixed that private key range issue you mentioned!
Thanks for pointing it out!
Now it throws an error when it tries to go out of bounds. Always better to prevent problems.
If you really care about security, you'd wanna swap out random for secrets.
Using the right libraries is key for safety.
Related topics
- Do derivative traders move funds to wallets after closing positions? 19
- Major Bitcoin Wallets Gain Confidence as BTC Surges 20
- Issues with importing miniscript wallets into Core 2
- Sending OP_Return Data from Mobile Wallets 6
- Issues with BTC Transfer Between Wallets 10
- Is Mempool.space Accurate for Fee Estimates? 19