Bitcoin Forum
May 03, 2024, 09:22:51 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How do i make sure my Bitcoin Private Key is Random and secure?  (Read 245 times)
NinjaBitcoiner (OP)
Member
**
Offline Offline

Activity: 77
Merit: 10


View Profile
November 16, 2022, 05:38:27 PM
 #1

So this thing keeps giving me stress and i need answer  Huh

So i know bitcoin private key is secure and there are 2^256 private keys and i also understand that it's impossible for 2 people to generate the same btc private key.
BUT what i think is possible is a bitcoin wallet generating a bitcoin address whose private key is in the range of 1 to say 10000?? then it's vulnerable to attack right?
See basically a private key is an integer between 1 and 2^256 converted to hex right. So what's stopping Random number generator to pick a private key from say first few million integers??
Isn't this a vulnerability?
Of course, advanced user can simply convert their private key to hex and to decimal to check if it's a large enough integer but what about noobies?

Here -  https://privatekeys.pw/keys/bitcoin/1
You can see on the above link. Any attacker can easily brute force first few million private keys so how to prevent such attack?
1714728172
Hero Member
*
Offline Offline

Posts: 1714728172

View Profile Personal Message (Offline)

Ignore
1714728172
Reply with quote  #2

1714728172
Report to moderator
1714728172
Hero Member
*
Offline Offline

Posts: 1714728172

View Profile Personal Message (Offline)

Ignore
1714728172
Reply with quote  #2

1714728172
Report to moderator
Unlike traditional banking where clients have only a few account numbers, with Bitcoin people can create an unlimited number of accounts (addresses). This can be used to easily track payments, and it improves anonymity.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714728172
Hero Member
*
Offline Offline

Posts: 1714728172

View Profile Personal Message (Offline)

Ignore
1714728172
Reply with quote  #2

1714728172
Report to moderator
1714728172
Hero Member
*
Offline Offline

Posts: 1714728172

View Profile Personal Message (Offline)

Ignore
1714728172
Reply with quote  #2

1714728172
Report to moderator
hosseinimr93
Legendary
*
Offline Offline

Activity: 2394
Merit: 5235



View Profile
November 16, 2022, 05:57:06 PM
Merited by hugeblack (2), ABCbits (1)
 #2

So i know bitcoin private key is secure and there are 2^256 private keys
Number of valid private keys is slightly less than 2256


it's impossible for 2 people to generate the same btc private key.
Not completely impossible. Almost impossible and very very unlikely.


BUT what i think is possible is a bitcoin wallet generating a bitcoin address whose private key is in the range of 1 to say 10000?? then it's vulnerable to attack right?
Yes, that's possible if the wallet hasn't been coded properly and that's why you should use always an open-source wallet to know how the keys are generated.


See basically a private key is an integer between 1 and 2^256 converted to hex right.
That's between 1 and FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
bitmover
Legendary
*
Offline Offline

Activity: 2296
Merit: 5917


bitcoindata.science


View Profile WWW
November 16, 2022, 06:06:17 PM
 #3

ou can see on the above link. Any attacker can easily brute force first few million private keys so how to prevent such attack?

Use a good software. Never use a bad wallet when generating your private keys.

What are good software? The most recommended ones:
Electrum, ledger nano, trezor, blue wallet...

You may be using a bad software,  which might have a pior randomness and your private keys might be insecure. That is possible.
But if you generated your private keys using the software I suggested,  there is no risk of poor randomness

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
LoyceV
Legendary
*
Online Online

Activity: 3304
Merit: 16586


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
November 16, 2022, 07:04:00 PM
Last edit: November 17, 2022, 03:17:38 PM by LoyceV
 #4

See basically a private key is an integer between 1 and 2^256 converted to hex right. So what's stopping Random number generator to pick a private key from say first few million integers??
What's stopping the random number generator from doing that, is chance probability. What you're suggesting has a chance of 1 in (give or take) 100000000000000000000000000000000000000000000000000000000000000000000000 to happen. It's not going to happen, don't worry about it.

NinjaBitcoiner (OP)
Member
**
Offline Offline

Activity: 77
Merit: 10


View Profile
November 16, 2022, 07:38:27 PM
 #5

ou can see on the above link. Any attacker can easily brute force first few million private keys so how to prevent such attack?

Use a good software. Never use a bad wallet when generating your private keys.

What are good software? The most recommended ones:
Electrum, ledger nano, trezor, blue wallet...

You may be using a bad software,  which might have a pior randomness and your private keys might be insecure. That is possible.
But if you generated your private keys using the software I suggested,  there is no risk of poor randomness

1.)I checked the electrum code and it also uses RNG that just picks a random number between 1 and 2^256 so therotically RNG can a pick a 10 digit number too? or am i missing something here?

2.) Second question i have is. We all know how SHA256 can be used to convert any 'text' to a hash which is a valid private key right a.k.a brain wallets.
So say i generate a very secure private key using very secure hardware wallet. so that private key is the hash of "some text" which we don't know because SHA256 is one way function but indeed there is "some text" on which we do SHA256 will give the same private key. So my question is what if my wallet generate a key which is secure but what if that key is SHA256 hash of some 'poor dictionary word'? There's no way to check this except comparing with all SHA256 of dictionary words. It's indeed a risk right? Am i being paranoid here?
hosseinimr93
Legendary
*
Offline Offline

Activity: 2394
Merit: 5235



View Profile
November 16, 2022, 07:52:05 PM
 #6

1.)I checked the electrum code and it also uses RNG that just picks a random number between 1 and 2^256 so therotically RNG can a pick a 10 digit number too? or am i missing something here?
That's true only in theory. The probability of getting a 10 digit number is almost zero.


2.) Second question i have is. We all know how SHA256 can be used to convert any 'text' to a hash which is a valid private key right a.k.a brain wallets.
It's not recommended to use brain wallets. It's recommended to generate a random private key.


So my question is what if my wallet generate a key which is secure but what if that key is SHA256 hash of some 'poor dictionary word'?
No. There is no risk. What you worry about can happen only in theory. A private key generated properly provides enough security.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NinjaBitcoiner (OP)
Member
**
Offline Offline

Activity: 77
Merit: 10


View Profile
November 16, 2022, 09:08:29 PM
 #7

1.)I checked the electrum code and it also uses RNG that just picks a random number between 1 and 2^256 so therotically RNG can a pick a 10 digit number too? or am i missing something here?
That's true only in theory. The probability of getting a 10 digit number is almost zero.


2.) Second question i have is. We all know how SHA256 can be used to convert any 'text' to a hash which is a valid private key right a.k.a brain wallets.
It's not recommended to use brain wallets. It's recommended to generate a random private key.


So my question is what if my wallet generate a key which is secure but what if that key is SHA256 hash of some 'poor dictionary word'?
No. There is no risk. What you worry about can happen only in theory. A private key generated properly provides enough security.

Regarding your answer to second question. I was not saying i am using brain wallet. Please read again.
I meant i generate a bitcoin private key using secure wallet say for example mycellium wallet which is completely random key BUT the private key that i got now is 100% a SHA256 hash of some random 'text'. so that text might be a 'word' from the dictionary. There's a chance for that. This is what i meant to ask.
hosseinimr93
Legendary
*
Offline Offline

Activity: 2394
Merit: 5235



View Profile
November 16, 2022, 09:41:23 PM
 #8

Regarding your answer to second question. I was not saying i am using brain wallet. Please read again.
I fully understood you.

I meant i generate a bitcoin private key using secure wallet say for example mycellium wallet which is completely random key BUT the private key that i got now is 100% a SHA256 hash of some random 'text'. so that text might be a 'word' from the dictionary. There's a chance for that. This is what i meant to ask.
There's a chance of that, but that's almost impossible.
If you know that any bitcoin address can be generated by 2^96 private keys on average, you may worry even more. But as I said in my previous post, a bitcoin private key provides enough security and there's nothing to worry about.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NinjaBitcoiner (OP)
Member
**
Offline Offline

Activity: 77
Merit: 10


View Profile
November 16, 2022, 10:04:43 PM
 #9

Regarding your answer to second question. I was not saying i am using brain wallet. Please read again.
I fully understood you.

I meant i generate a bitcoin private key using secure wallet say for example mycellium wallet which is completely random key BUT the private key that i got now is 100% a SHA256 hash of some random 'text'. so that text might be a 'word' from the dictionary. There's a chance for that. This is what i meant to ask.
There's a chance of that, but that's almost impossible.
If you know that any bitcoin address can be generated by 2^96 private keys on average, you may worry even more. But as I said in my previous post, a bitcoin private key provides enough security and there's nothing to worry about.


Ok thanks
One last question. Is it more secure to generate a 24 word seed using dice/coins (manually) OR using CSPRNG present is software like electrum etc ?  Which is more secure?
hosseinimr93
Legendary
*
Offline Offline

Activity: 2394
Merit: 5235



View Profile
November 16, 2022, 10:24:19 PM
 #10

One last question. Is it more secure to generate a 24 word seed using dice/coins (manually) OR using CSPRNG present is software like electrum etc ?  Which is more secure?
In both cases the seed phrase is generated completely randomly (assuming your dice is balanced and all the numbers have the same probability to be chosen) and is secure enough.
It may worth mentioning that, if you want 100% security, you should generate your seed phrase on an air-gapped device.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4615



View Profile
November 17, 2022, 03:24:50 AM
Merited by LoyceV (6), ABCbits (3), Pmalek (2)
 #11

So this thing keeps giving me stress and i need answer  Huh

It's going to be ok. Take some deep breaths. No need to stress.

So i know bitcoin private key is secure and there are 2^256 private keys and i also understand that it's impossible for 2 people to generate the same btc private key.

You're off to a good start. Already you understand more than the majority of crypto users.

BUT what i think is possible is a bitcoin wallet generating a bitcoin address whose private key is in the range of 1 to say 10000??

That depends on what you mean when you say "possible".

then it's vulnerable to attack right?

Sure. If you generate a private key that is a relatively small integer (or very close to the high end of the range, or one that coincides with a sha256 hash of any common phrase or password), then it would be vulnerable.

See basically a private key is an integer between 1 and 2^256 converted to hex right.

Effectively, yes.  Perhaps a better way to think of it is that a private key is an element of data that can be represented by a computer as a set of 256 binary digits.  Any set of binary digits can technically also be represented as a base10 integer, so therefore your private key (just like EVERYTHING a computer stores) can be represented as a base10 integer.

So what's stopping Random number generator to pick a private key from say first few million integers??

Probability.

If your private key is generated randomly, then what you are saying is that it is generated by randomly choosing either a 1 or a 0 for each one of the 256 binary digits. Ending up with a private key that translates to an integer less than 1,000,000,000,000 is equivalent to randomly flipping a completely balanced coin and having it come up the exact same way 216 TIMES IN A ROW, and then for the remaining 40 flips it sometimes comes up one way and sometimes the other.  Think about that for a bit, maybe even try it yourself with a coin.  How many lifetimes of the universe do you think you'd need to continuously flip that perfect coin before it would come up the same way 216 times in a row? Is it realistic that it will ever happen?  Is it "possible" the way a normal person would think of things being possible?

Isn't this a vulnerability?

No.

Of course, advanced user can simply convert their private key to hex and to decimal to check if it's a large enough integer

You could if you're actually concerned about it.

but what about noobies?

Regarding this concern, they'll be fine. There are MUCH more common problems for them to worry about and mess up.
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6726


bitcoincleanup.com / bitmixlist.org


View Profile WWW
November 17, 2022, 04:10:36 AM
 #12

So i know bitcoin private key is secure and there are 2^256 private keys and i also understand that it's impossible for 2 people to generate the same btc private key.
BUT what i think is possible is a bitcoin wallet generating a bitcoin address whose private key is in the range of 1 to say 10000?? then it's vulnerable to attack right?

You would easily be able to notice that in an open-source wallet because the key would either be very tiny, very close to the maximum keys, or you would see a list of privkey hex characters the wallet selects from for no good reason. In closed source wallets you can't check this so that is another reason why to avoid such wallets.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NinjaBitcoiner (OP)
Member
**
Offline Offline

Activity: 77
Merit: 10


View Profile
November 17, 2022, 12:15:49 PM
 #13


Sure. If you generate a private key that is a relatively small integer (or very close to the high end of the range, or one that coincides with a sha256 hash of any common phrase or password), then it would be vulnerable.


How do i specifically avoid this? If i generate a private key using secure wallet like hardware wallet or may be software wallet like electrum then how do i make sure it's not vulnerable to this? (a small integer/or coincides with SHA256 hash of common phrase) ? or the probability of this happening is not worth considering?
NinjaBitcoiner (OP)
Member
**
Offline Offline

Activity: 77
Merit: 10


View Profile
November 17, 2022, 12:31:07 PM
 #14

Here -  https://privatekeys.pw/keys/bitcoin/1
You can see on the above link. Any attacker can easily brute force first few million private keys so how to prevent such attack?

Private key/address on those website is generated on-demand (basically when you access the page). I would recommend you try clicking button "Random" or "Last" on that website. Actual attacker could brute force either from beginning, ending, other specific range of number or even randomly.

One last question. Is it more secure to generate a 24 word seed using dice/coins (manually) OR using CSPRNG present is software like electrum etc ?  Which is more secure?

People usually would say both option are secure enough. Although it's hard to say which one is more secure since there are many variable involved needed to answer the question (such as quality of the dice or whether you call CSPRNG just after boot on device with very little activity/input). But FYI, Electrum actually utilize CSPRNG provided by operating system through function os.random()[1]. Electrum would use /dev/urandom on linux/unix-based OS and CryptGenRandom() on Windows OS[1].

[1] https://github.com/spesmilo/electrum/blob/4.3.2/electrum/wallet.py#L433
[2] https://docs.python.org/3.10/library/os.html#os.urandom

so using CSPRNG on new OS installation and just after reboot is not secure enough? So what time should i wait before booting system to make sure there's enough entropy? Also i guess on live machine/VM it's not safe to use CSPRNG?
NinjaBitcoiner (OP)
Member
**
Offline Offline

Activity: 77
Merit: 10


View Profile
November 18, 2022, 08:56:02 AM
 #15

--snip--
so using CSPRNG on new OS installation and just after reboot is not secure enough?

An expert say it's not secure enough only when your device has very little activity (such as headless or embedded device)[1]. But his research was performed a decade ago, so i don't know if it's applicable in 2022. Besides, average customer PC have lots activity including mouse movement, keyboard input and various application which opened on background after you login. So i wouldn't worry about insufficient entropy.

So what time should i wait before booting system to make sure there's enough entropy?

According to research i mentioned earlier, at least 1 minute. Although i'd recommend to do some activity (such as checking system log, perform internet speed test or use file explorer) to increase the entropy instead.

Also i guess on live machine/VM it's not safe to use CSPRNG?

If both live machine and VM has lots of activity and you wait few minutes, i don't see reason why it's not safe.

[1] https://dl.acm.org/doi/10.5555/2362793.2362828

The same applies to offline cold storage PC as well? If the system is not connected to internet. Then also there will be enough sources of entropy right?
ABCbits
Legendary
*
Offline Offline

Activity: 2870
Merit: 7460


Crypto Swap Exchange


View Profile
November 18, 2022, 09:55:16 AM
Merited by PawGo (1)
 #16

--snip--
The same applies to offline cold storage PC as well? If the system is not connected to internet.

Yes, internet usage is just one of many entropy source.

Then also there will be enough sources of entropy right?

Yes (assuming it's not headless or embedded device). But if you have very very very serious security concern, just run this command and make sure the value is either 256 (Linux kernel 5.10.119 or newer) or 4096 (Up to 5.10.118)[1].

Code:
cat /proc/sys/kernel/random/entropy_avail

[1] https://unix.stackexchange.com/a/704743

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
albert0bsd
Hero Member
*****
Offline Offline

Activity: 850
Merit: 660



View Profile WWW
November 24, 2022, 02:38:04 AM
Merited by ABCbits (1)
 #17

Use the next Linux command

Code:
</dev/urandom tr -dc 'A-F0-9' | head -c 64  ; echo

Please read the next article if you have concerns about urandom

https://www.2uo.de/myths-about-urandom/

BlackHatCoiner
Legendary
*
Online Online

Activity: 1512
Merit: 7340


Farewell, Leo


View Profile
November 24, 2022, 04:36:20 PM
 #18

If you don't feel confident with your hardware, generate the entropy yourself in a provably random way. For example, make sure that a coin is fair enough[1], and toss it. You can use iancoleman's software for that (click on "Show entropy details"). Preferably use the entropy as a seed, and not as an individual private key.

[1] Simple trick to reduce coin bias: https://markd87.github.io/snippets/von_neumann_trick/

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!