Bitcoin Forum
May 02, 2024, 07:32:24 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Code lines for keys generation  (Read 965 times)
beckspace (OP)
Hero Member
*****
Offline Offline

Activity: 931
Merit: 500


View Profile
September 21, 2012, 10:49:04 PM
 #1


What are the lines of code that actually generate the public/private keys for Bitcoin?

I'd like to know where to look (search for words and commands) when inspecting a source code, in the original client and others alternatives clients as well (blockchain.info, bitaddress.org etc.)

Thanks.

1714678344
Hero Member
*
Offline Offline

Posts: 1714678344

View Profile Personal Message (Offline)

Ignore
1714678344
Reply with quote  #2

1714678344
Report to moderator
"You Asked For Change, We Gave You Coins" -- casascius
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714678344
Hero Member
*
Offline Offline

Posts: 1714678344

View Profile Personal Message (Offline)

Ignore
1714678344
Reply with quote  #2

1714678344
Report to moderator
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
September 21, 2012, 11:07:41 PM
 #2

Those lines you are talking about are not exactly the same across different languages. Look here https://github.com/bitcoin/bitcoin/blob/master/src/key.cpp

The whole file is relevent, but you also might want to take a look at void CKey::MakeNewKey(bool fCompressed)

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
September 26, 2012, 04:43:26 PM
 #3

The "short" version:

generate a random 256 bit number.  Use a high quality entropy source.
make sure it is less than the number of possible spots in the curve you are using (start over if it is)
-> this is your private key

do an elliptic curve multiply of your curve's generator point by the private key
-> this is your public key

Converting those keys to/from other formats (like bitcoin addresses or WIF) is another big topic.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
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!