Bitcoin Forum
May 10, 2024, 05:15:30 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: compressed pubkey version  (Read 613 times)
FabioCarpi (OP)
Sr. Member
****
Offline Offline

Activity: 375
Merit: 254



View Profile
January 05, 2015, 11:49:26 PM
 #1

How to know when to use version 02 or 03 in a compressed pubkey?

let me explain:
in the bitcoin qt, i type the command dumpprivkey in my address 1Cue...
he gave me the key Kw...
but making some tests, with version 02, i got the address 1Nra...
and with the version 03, the 1Cue...
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715361330
Hero Member
*
Offline Offline

Posts: 1715361330

View Profile Personal Message (Offline)

Ignore
1715361330
Reply with quote  #2

1715361330
Report to moderator
1715361330
Hero Member
*
Offline Offline

Posts: 1715361330

View Profile Personal Message (Offline)

Ignore
1715361330
Reply with quote  #2

1715361330
Report to moderator
1715361330
Hero Member
*
Offline Offline

Posts: 1715361330

View Profile Personal Message (Offline)

Ignore
1715361330
Reply with quote  #2

1715361330
Report to moderator
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
January 05, 2015, 11:54:54 PM
 #2

How to know when to use version 02 or 03 in a compressed pubkey?

Code:
const QByteArray MyKey32::getPublicKeyClassic ( ) const
{
  quint8 buf [65];
  getPublicKey ( buf );
//buf [0] = 0x04;
  return QByteArray ( (const char*)buf, 65 );
}
//--------------------------------------------------------------
const QByteArray MyKey32::getPublicKeyCompressed ( ) const
{
  quint8 buf [65];
  getPublicKey ( buf );
  buf [0] = 0x02 + ( buf [64] & 1 );
  return QByteArray ( (const char*)buf, 33 );
}
FabioCarpi (OP)
Sr. Member
****
Offline Offline

Activity: 375
Merit: 254



View Profile
January 05, 2015, 11:57:18 PM
 #3

sry amaclin, i post some info...
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
January 06, 2015, 12:04:46 AM
Last edit: January 06, 2015, 07:52:16 AM by amaclin
 #4

sry amaclin, i post some info...

Public key is a pair [x,y]
if 'y' is even - use 0x02
if 'y' is odd - use 0x03


Code:
buf [0] = 0x02 + ( buf [64] & 1 );
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!