-4

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…

Roy Nahar
  • 1
  • 1

1 Answers1

1

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/

DannyNiu
  • 10,640
  • 2
  • 27
  • 64