Subject: [Bitcoin-development] Compressed public keys: import/export and test cases

From: Pieter Wuille <[email-masked]>
Date: Mon, 9 Jan 2012 14:53:51 +0100

Hello all,

pull #649 now also defines an import/export format for private keys
whose public key is compressed.

Rationale: even though a compressed and uncompressed public key share
the same actual 32-byte secret, the import/export format needs a
marker that states whether the corresponding compressed or
uncompressed public key should be used (since they have different
addresses).

Format:
* uncompressed: 0x80 + [32-byte secret] + [4 bytes of Hash() of
previous 33 bytes], base58 encoded
* compressed: 0x80 + [32-byte secret] + 0x01 + [4 bytes of Hash()
previous 34 bytes], base58 encoded

Any comments or suggestions regarding this format? Below I've included
3 cases to test implementations with.

Test cases:

case 1:
  * secret (hex):
1111111111111111111111111111111111111111111111111111111111111111
  * uncompressed:
    * secret (base58): 5HwoXVkHoRM8sL2KmNRS217n1g8mPPBomrY7yehCuXC1115WWsh
    * pubkey (hex):
044f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa385b6b1b8ead809ca67454d9683fcf2ba03456d6fe2c4abe2b07f0fbdbb2f1c1
    * address (base58): 1MsHWS1BnwMc3tLE8G35UXsS58fKipzB7a
  * compressed:
    * secret (base58): KwntMbt59tTsj8xqpqYqRRWufyjGunvhSyeMo3NTYpFYzZbXJ5Hp
    * pubkey (hex):
034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa
    * address (base58): 1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9

case 2:
  * secret (hex):
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
  * uncompressed:
    * secret (base58): 5KVzsHJiUxgvBBgtVS7qBTbbYZpwWM4WQNCCyNSiuFCJzYMxg8H
    * pubkey (hex):
04ed83704c95d829046f1ac27806211132102c34e9ac7ffa1b71110658e5b9d1bdedc416f5cefc1db0625cd0c75de8192d2b592d7e3b00bcfb4a0e860d880fd1fc
    * address (base58): 1JyMKvPHkrCQd8jQrqTR1rBsAd1VpRhTiE
  * compressed:
    * secret (base58): L4ezQvyC6QoBhxB4GVs9fAPhUKtbaXYUn8YTqoeXwbevQq4U92vN
    * pubkey (hex):
02ed83704c95d829046f1ac27806211132102c34e9ac7ffa1b71110658e5b9d1bd
    * address (base58): 1NKRhS7iYUGTaAfaR5z8BueAJesqaTyc4a

case 3:
  * secret (hex):
47f7616ea6f9b923076625b4488115de1ef1187f760e65f89eb6f4f7ff04b012
  * uncompressed:
    * secret (base58): 5JMys7YfK72cRVTrbwkq5paxU7vgkMypB55KyXEtN5uSnjV7K8Y
    * pubkey (hex):
042596957532fc37e40486b910802ff45eeaa924548c0e1c080ef804e523ec3ed3ed0a9004acf927666eee18b7f5e8ad72ff100a3bb710a577256fd7ec81eb1cb3
    * address (base58): 1PM35qz2uwCDzcUJtiqDSudAaaLrWRw41L
  * compressed:
    * secret (base58): KydbzBtk6uc7M6dXwEgTEH2sphZxSPbmDSz6kUUHi4eUpSQuhEbq
    * pubkey (hex):
032596957532fc37e40486b910802ff45eeaa924548c0e1c080ef804e523ec3ed3
    * address (base58): 19ck9VKC6KjGxR9LJg4DNMRc45qFrJguvV

-- 
Pieter