Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: oleganza on May 31, 2013, 11:26:00 AM



Title: Digging source code: "Private key" vs. "Secret parameter"
Post by: oleganza on May 31, 2013, 11:26:00 AM
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.


Title: Re: Digging source code: "Private key" vs. "Secret parameter"
Post by: jackjack on May 31, 2013, 12:10:34 PM
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