Score:-4

Compressed Address public key

fi flag

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…
DannyNiu avatar
vu flag
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.
Roy Nahar avatar
fi flag
It has everything to do with ECDSA SECP256k1. No it doesn't. [code moved to the question by moderator] Any other option?
yyyyyyy avatar
in flag
@DannyNiu The question mentions "address" — cryptocurrency lingo for a public key or hash of a public key.
DannyNiu avatar
vu flag
I'm regretfully aware of the fact that many people are introduced to cryptography, hash, digital signature, and elliptic curves through blockchain/cryptocurrency. @yyyyyyy
fgrieu avatar
ng flag
Now that we see your code: it seems to be an implementation (except for checks of the first byte, and other checks) of [Octet-String-to-Elliptic-Curve-Point Conversion](https://www.secg.org/sec1-v2.pdf#subsubsection.2.3.4) for a compressed [secp256k1](https://www.secg.org/sec2-v2.pdf#subsubsection.2.4.1) public key, followed by [rebuilding the uncompressed key](https://www.secg.org/sec1-v2.pdf#subsubsection.2.3.3). It's unclear to me, and I guess to the 3 other contributors who closed your question, what else you mean by _"the xy of my compressed public key"_.
Roy Nahar avatar
fi flag
[offensive statement moderated out] I found [the answer I need](https://bitcoin.stackexchange.com/questions/86234/how-to-uncompress-a-public-key). 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 compressed xy public key coordinates. That's it. Its simple English.
kelalaka avatar
in flag
Duplicate of [How to expand elliptic curve public key from compressed form?](https://crypto.stackexchange.com/q/100606/18298)
fgrieu avatar
ng flag
@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.
DannyNiu avatar
vu flag
`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
fgrieu avatar
ng flag
@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](https://crypto.stackexchange.com/q/102403/555)). 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).
Score:1
vu flag

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/

Roy Nahar avatar
fi flag
It's OK. I found the answer. https://bitcoin.stackexchange.com/questions/86234/how-to-uncompress-a-public-key
Roy Nahar avatar
fi flag
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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.