Bitcoin Forum
April 27, 2024, 09:35:16 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: uncompressed public key <->compressed samples  (Read 166 times)
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
October 07, 2019, 02:59:59 PM
 #1

Here is "How to get uncompressed public key from compressed one ?" - Python sample.
I want create converter compressed<->uncompressed in C++.
I plan using Boost multiprecision (I think, using uint256.cpp from Bitcoin sources is not enough - this have only serialization and comparision)
I search samples of pairs compressed/uncompressed or calculator online.
1714253716
Hero Member
*
Offline Offline

Posts: 1714253716

View Profile Personal Message (Offline)

Ignore
1714253716
Reply with quote  #2

1714253716
Report to moderator
Transactions must be included in a block to be properly completed. When you send a transaction, it is broadcast to miners. Miners can then optionally include it in their next blocks. Miners will be more inclined to include your transaction if it has a higher transaction fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714253716
Hero Member
*
Offline Offline

Posts: 1714253716

View Profile Personal Message (Offline)

Ignore
1714253716
Reply with quote  #2

1714253716
Report to moderator
1714253716
Hero Member
*
Offline Offline

Posts: 1714253716

View Profile Personal Message (Offline)

Ignore
1714253716
Reply with quote  #2

1714253716
Report to moderator
BrewMaster
Legendary
*
Offline Offline

Activity: 2114
Merit: 1292


There is trouble abrewing


View Profile
October 07, 2019, 03:22:26 PM
 #2

when you have a compressed public key you have one starting byte (0x02 or 0x03) followed by x. compute y2 first from x like this:
y2  = x3 + 7 (mod p)
then compute y by an square root algorithm, since p for bitcoin is like (p%4 = 3) you can simplify it as:
y = (y2)(p+1)/4 (mod p)

the acceptable y is:
if y is odd & first byte was 2 => -y
if y is even & first byte was 3 => -y
otherwise y

for examples, go to bitaddress.org generate private keys and look at the compressed and uncompressed public key results.

There is a FOMO brewing...
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!