Bitcoin Forum
October 15, 2019, 07:59:37 AM
 News: Latest Bitcoin Core release: 0.18.1 [Torrent]
 Home Help Search Login Register More
 Pages: [1]
 Author Topic: uncompressed public key <->compressed samples  (Read 44 times)
Frodek
Member

Offline

Activity: 118
Merit: 12

 October 07, 2019, 02:59:59 PM

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.
1571126377
Hero Member

Offline

Posts: 1571126377

Ignore
 1571126377

1571126377
 Report to moderator
1571126377
Hero Member

Offline

Posts: 1571126377

Ignore
 1571126377

1571126377
 Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1571126377
Hero Member

Offline

Posts: 1571126377

Ignore
 1571126377

1571126377
 Report to moderator
BrewMaster
Hero Member

Offline

Activity: 1330
Merit: 814

There is trouble abrewing

 October 07, 2019, 03:22:26 PM

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.

 ░░░░░▄▄██████▄▄░░▄████▀▀▀▀▀▀████▄░███▀░░░░░░░░░░▀█▀████░░░▄██████▄▄░░░██░░░░░█████████░░░░██▌░░░░█████████████████░░░░█████████████████░░░░░███████████████████▄░░▀██████▀░░░████▀█▄▄░░░░░░░░░░▄███░░▀████▄▄▄▄▄▄████▀░░░░░▀▀██████▀▀ .ChipMixer.{ MIXING REINVENTED FOR YOUR PRIVACY #.ChipMixer. ░░░░░▄▄██████▄▄░░▄████▀▀▀▀▀▀████▄░███▀░░░░░░░░░░▀█▀████░░░▄██████▄▄░░░██░░░░░█████████░░░░██▌░░░░█████████████████░░░░█████████████████░░░░░███████████████████▄░░▀██████▀░░░████▀█▄▄░░░░░░░░░░▄███░░▀████▄▄▄▄▄▄████▀░░░░░▀▀██████▀▀
 Pages: [1]