Bitcoin Forum
April 28, 2024, 05:19:13 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to securely generate private key with javascript?  (Read 240 times)
Anonymous Kid (OP)
Member
**
Offline Offline

Activity: 183
Merit: 25


View Profile
May 05, 2018, 09:28:12 AM
Last edit: May 05, 2018, 11:41:51 AM by Anonymous Kid
 #1

What is the most secure way to generate a private key for a user?

Is this secure?

Hashing a password that the user inputs (longer than 10 characters with numbers, capital letters), then hashing with the current date and time, then hashing with random number generated between 1-100,000?

Does anyone know how is private key generation handled in other clients?

Edit: This is for a wallet service, so all code should be run within the browser side.
1714324753
Hero Member
*
Offline Offline

Posts: 1714324753

View Profile Personal Message (Offline)

Ignore
1714324753
Reply with quote  #2

1714324753
Report to moderator
Remember that Bitcoin is still beta software. Don't put all of your money into BTC!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714324753
Hero Member
*
Offline Offline

Posts: 1714324753

View Profile Personal Message (Offline)

Ignore
1714324753
Reply with quote  #2

1714324753
Report to moderator
1714324753
Hero Member
*
Offline Offline

Posts: 1714324753

View Profile Personal Message (Offline)

Ignore
1714324753
Reply with quote  #2

1714324753
Report to moderator
NeuroticFish
Legendary
*
Offline Offline

Activity: 3654
Merit: 6366


Looking for campaign manager? Contact icopress!


View Profile
May 05, 2018, 09:36:57 AM
 #2

What is the most secure way to generate a private key for a user?

Is this secure?

Hashing a password that the user inputs (longer than 10 characters with numbers, capital letters), then hashing with the current date and time, then hashing with random number generated between 1-100,000?

Does anyone know how is private key generation handled in other clients?

I think that you best take a look what the code of https://www.bitaddress.org does, since it is available on GiHub.

Since that code is proven by time that's good, the security is mostly related to the internet.
So one pretty safe way is to download the bitaddress code locally, onto a stick, for example, unplug the computer from any internet activity (go offline), generate as many paper wallets you want (meaning public+private keys actually), print them to paper (printer connected by USB, not the network).
Afterwards stop the printer, format the HDD and after that you can reinstall and go online again.
Safe enough?

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

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

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

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

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

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











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











▄▄▄▄█
Aura
Sr. Member
****
Offline Offline

Activity: 518
Merit: 268


View Profile
May 05, 2018, 10:15:48 AM
 #3

The most secure way is to download the bitaddress source from Github and move it to a flashdrive, like NeuroticFish describes. Then you follow this guide:

To generate your own entropy you’ll need five 6-sided dice, preferably high quality casino dice for true random numbers.

Roll the five dice and arrange in any order to create one 5-digit number. Use this dice number list [http://world.std.com/~reinhold/dicewarewordlist.pdf] to obtain a word for the roll. If, for example, you rolled 11121, your word would be aaron. Repeat this 24 times, since you’ll need 24 words for a secure seed.

Write down each word on one piece of paper like this. This will create the seed that will be used as the random entropy for your paper wallets.

Create multiple copies of the word list and store in multiple locations. Laminate each copy and store in a fireproof safe if possible.

Remember to write it down! Then afterwards click on the "brain wallet" button, like shown below:



Fill down your 24 word list two times and click view, now you have successfully generated a bitcoin address.
Write down your paper wallet (printing adds an extra attack vector) and make sure to check for errors.
Finally destroy your flashdrive and never use it again.

 
hatshepsut93
Legendary
*
Online Online

Activity: 2954
Merit: 2145



View Profile
May 05, 2018, 10:28:23 AM
 #4

What is the most secure way to generate a private key for a user?

Is this secure?

Hashing a password that the user inputs (longer than 10 characters with numbers, capital letters), then hashing with the current date and time, then hashing with random number generated between 1-100,000?

Does anyone know how is private key generation handled in other clients?

This sounds like you are trying to invent a Key Derivation Function (KDF), and in cryptography inventing your own algorithms is generally a bad idea. Also it's unclear what exactly are you asking - do you want your users to generate Bitcoin key-adress pair on browser side or do you want to generate keys on server side, or maybe you are doing it only for yourself?

.BEST.CHANGE..███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
Anonymous Kid (OP)
Member
**
Offline Offline

Activity: 183
Merit: 25


View Profile
May 05, 2018, 11:41:15 AM
 #5

What is the most secure way to generate a private key for a user?

Is this secure?

Hashing a password that the user inputs (longer than 10 characters with numbers, capital letters), then hashing with the current date and time, then hashing with random number generated between 1-100,000?

Does anyone know how is private key generation handled in other clients?

This sounds like you are trying to invent a Key Derivation Function (KDF), and in cryptography inventing your own algorithms is generally a bad idea. Also it's unclear what exactly are you asking - do you want your users to generate Bitcoin key-adress pair on browser side or do you want to generate keys on server side, or maybe you are doing it only for yourself?

Ah yes, sorry. I seem to have gotten some mixed answers. I am creating a bitcoin wallet service so the most secure is for user to generate key on the browser side but I am unsure what method to use to generate the keypair so that it cannot be easily guessed/bruteforced - Similar to how myetherwallet.com generates keys
hatshepsut93
Legendary
*
Online Online

Activity: 2954
Merit: 2145



View Profile
May 05, 2018, 12:19:09 PM
Merited by suchmoon (2)
 #6


Ah yes, sorry. I seem to have gotten some mixed answers. I am creating a bitcoin wallet service so the most secure is for user to generate key on the browser side but I am unsure what method to use to generate the keypair so that it cannot be easily guessed/bruteforced - Similar to how myetherwallet.com generates keys

Ethereum and Bitcoin are slightly different in their standard private key handling - for Ethereum it's usually a keystore file, while for Bitcoin it's a seed phrase, so your site should resemble sites like this one: https://iancoleman.io/bip39/

Check its github page to read its code: https://github.com/iancoleman/bip39

Note that in the site I've posted the passphrase is optional - this is because user input is very unreliable source of randomness, so you should never ask users to type random characters or long words and then simply hashing them many times.

.BEST.CHANGE..███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
DannyHamilton
Legendary
*
Offline Offline

Activity: 3374
Merit: 4610



View Profile
May 06, 2018, 02:09:56 AM
Merited by HCP (1)
 #7

What is the most secure way to generate a private key for a user?

Use a well reviewed, well tested, cryptographically secure pseudorandom number generator.

Is this secure?

No.

Unless you have extensive training, experience, skill, and expertise, do NOT try and create your own "secure algorithm".
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!