# Compressed Address public key [closed]

Is it possible to get the x, y of the compressed public key?

I have decompress it and naturally it gives the xy of the decompress public key.

I need the xy coordinates of my compressed public key . How do I get it? Is there a python script I can get my hands on?

Update: I have tried it via

#! /usr/bin/env python3

import binascii

p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F

def decompress_pubkey(pk):
x = int.from_bytes(pk[1:33], byteorder='big')
y_sq = (pow(x, 3, p) + 7) % p
y = pow(y_sq, (p + 1) // 4, p)
if y % 2 != pk[0] % 2:
y = p - y
y = y.to_bytes(32, byteorder='big')
return b'\x04' + pk[1:33] + y

print(binascii.hexlify(decompress_pubkey(binascii.unhexlify('0245a6b3f8eeab8e88501a9a25391…

• What does cryptocurrency have to do with this question? Compressed ECC Point contain the exact same information as an Uncompressed ECC Point (assuming that they're valid points on the curve). The Y coordinate that one recovers from a valid Compressed ECC Point is the same as the one from Uncompressed ECC Point. Commented Oct 25, 2022 at 6:20
• Commented Oct 25, 2022 at 10:45
• @Roy Nahar: when 4 persons with high reputation on crypto-SE do not understand a question, a reasonable hypothesis is that it is unclear or off-topic. As for me, I understand neither (A) if your problem is solved (as implied by "I found the answer I need"), or not (as implied by the later "now I'm looking for the compressed xy public key coordinates"); nor (B) what "compressed xy public key coordinates" means, if that's not x and y as in your code (before y.to_bytes). Whatever, it seems your question is about bitcoin-specific stuff or terminology, thus off-topic here on crypto-SE.
– fgrieu
Commented Oct 25, 2022 at 11:15
• High reputation but by your own standards, you can click on your own profile and check the status points for reputation. Then you can find another user and click on their profile. @RoyNahar Commented Oct 25, 2022 at 12:02
• @RoyNahar: The question says you have decompressed the (public) key. You later added code doing just that (in a comment, that I turned into an update of the question), assuming the compressed (public) key is correct (the code skips some checks, and that became the topic of a new question). During this process, you obtain the x and y coordinates of the public key, and that's both for the compressed form of public key and the decompressed form of the public key. So I do not understand what the question asks (or asked, if it's solved).
– fgrieu
Commented Oct 27, 2022 at 7:03

Conceptually, an ECC public key (assuming we're talking about SEC#1 ECC), consist of a X coordinate and a Y coordinate. They may be of various forms depending on where they're used:

1. It may become a XYZ projective coordinates during computation to avoid the overhead of repeatedly computing multiplicative inverse in finite field.

2. It may become a compressed 1-Byte + X form during communication to save bandwidth.

In the 2nd case, you retrieve the XY coordinates the same way you convert it to a uncompressed ECC point - plug the value for X into the equation and compute modular square-root for Y.

If there are any confusion, let's clarify:

• The XY coordinates are the properties of a public key,
• The compressed and uncompressed forms are the communication representation of the public key.

Additionally, there is a website that contain resources to learn all the hardcore technicalities of ECC: https://secg.org/

• It's OK. I found the answer. bitcoin.stackexchange.com/questions/86234/… Commented Oct 25, 2022 at 10:09
• There he explained that when you compress you get a compressed wallet address (public key as well and when you decompress its a different address due to the hashing.) now I'm looking for the xy public key coordinates. Commented Oct 25, 2022 at 10:14