Bitcoin Forum
May 14, 2024, 06:07:04 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Digging source code: "Private key" vs. "Secret parameter"  (Read 919 times)
oleganza (OP)
Full Member
***
Offline Offline

Activity: 200
Merit: 104


Software design and user experience.


View Profile WWW
May 31, 2013, 11:26:00 AM
 #1

I'm reading Bitcoin-QT source code and don't quite understand the difference between CPrivKey and CSecret.

key.h has some explanation:

// CPrivKey is a serialized private key, with all parameters included (279 bytes)
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;
// CSecret is a serialization of just the secret parameter (32 bytes)
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CSecret;

Looks like what we usually call a private key is a short 32 byte "secret parameter". But then I see code that uses CPrivKey in wallet.cpp. I would go to OpenSSL to study the difference between EC_KEY_get0_private_key (used in CKey::GetSecret) and i2d_ECPrivateKey (used in CKey::GetPrivKey), but OpenSSL .h documentation does not really explain much.

Why do we need a big CPrivKey when you can always generate key pair from just a secret? Where can I learn more about practical aspects of ECDSA (I already have a good theoretical guide)?

Thanks.

Bitcoin analytics: blog.oleganza.com / 1TipsuQ7CSqfQsjA9KU5jarSB1AnrVLLo
jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1255


May Bitcoin be touched by his Noodly Appendage


View Profile
May 31, 2013, 12:10:34 PM
 #2

Looks like what we usually call a private key is a short 32 byte "secret parameter".
Absolutely

Why do we need a big CPrivKey when you can always generate key pair from just a secret?
I'm interested in the answer too

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
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!