Bitcoin Forum
May 11, 2024, 10:51:21 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin key size and elliptic curve in 2009 and now  (Read 182 times)
MrFreeDragon (OP)
Sr. Member
****
Offline Offline

Activity: 443
Merit: 350


View Profile
October 14, 2019, 05:26:40 PM
 #1

Sorry for the question, may be it was already discussed earlier.
I understand that the curve selected for bitcoin was the same (secp256k1) since the start in 2009, however in the first code of bitcoin application (dated 2009 year) i found the following comments:

Code:
key.h

// secp160k1
// const unsigned int PRIVATE_KEY_SIZE = 192;
// const unsigned int PUBLIC_KEY_SIZE  = 41;
// const unsigned int SIGNATURE_SIZE   = 48;
//
// secp192k1
// const unsigned int PRIVATE_KEY_SIZE = 222;
// const unsigned int PUBLIC_KEY_SIZE  = 49;
// const unsigned int SIGNATURE_SIZE   = 57;
//
// secp224k1
// const unsigned int PRIVATE_KEY_SIZE = 250;
// const unsigned int PUBLIC_KEY_SIZE  = 57;
// const unsigned int SIGNATURE_SIZE   = 66;
//
// secp256k1:
// const unsigned int PRIVATE_KEY_SIZE = 279;
// const unsigned int PUBLIC_KEY_SIZE  = 65;
// const unsigned int SIGNATURE_SIZE   = 72;
//
// see www.keylength.com
// script supports up to 75 for single byte push

So, 2 questions:
1) Did bitcoin really used other curves than secp256k1 in the past years? What was the reason to put the comments about secp160k1, secp192k1 and secp224k1?
2) Why is the PRIVATE_KEY_SIZE for secp256k1 equals to 279? The private key is 256bit, so what for is the additional 279-256 = 23 bits?

Unlike traditional banking where clients have only a few account numbers, with Bitcoin people can create an unlimited number of accounts (addresses). This can be used to easily track payments, and it improves anonymity.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715467881
Hero Member
*
Offline Offline

Posts: 1715467881

View Profile Personal Message (Offline)

Ignore
1715467881
Reply with quote  #2

1715467881
Report to moderator
1715467881
Hero Member
*
Offline Offline

Posts: 1715467881

View Profile Personal Message (Offline)

Ignore
1715467881
Reply with quote  #2

1715467881
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


View Profile WWW
October 14, 2019, 07:50:15 PM
Merited by suchmoon (4), MrFreeDragon (2), ABCbits (1), hugeblack (1), aliashraf (1)
 #2

So, 2 questions:
1) Did bitcoin really used other curves than secp256k1 in the past years?
No.

What was the reason to put the comments about secp160k1, secp192k1 and secp224k1?
Presumably because those are the other secp curves that could have been used.

2) Why is the PRIVATE_KEY_SIZE for secp256k1 equals to 279? The private key is 256bit, so what for is the additional 279-256 = 23 bits?
It is not the bit length of the private key. It is a byte length of a DER encoded private key as denoted in ASN.1 in the SEC standard: http://www.secg.org/sec1-v2.pdf.

This private key contains the private key itself as well as all of the curve parameters and the public key which makes it much larger than just the private key itself. So that it means it has the private key, the public key, the parameters for the curve equation, the finite field for the curve, the generator curve point, and the order of the generator. There are several 32 byte values, along with several bytes of overhead due to DER, and some more bytes for version numbers. This makes the total size of a private key encoded in this way to be 279 bytes.

The reason this encoding was used is because that is how openssl encoded private keys. This encoding is still being used for private keys in the wallet storage in order to maintain backwards compatibility. When compatibility was not necessary such as in the introduction of encrypted wallets, the private key was encoded just as itself thus significantly saving space.

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!