Bitcoin Forum
April 24, 2024, 05:35:25 AM *
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 963 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.

You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713936925
Hero Member
*
Offline Offline

Posts: 1713936925

View Profile Personal Message (Offline)

Ignore
1713936925
Reply with quote  #2

1713936925
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!