Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get x and y components from ecc public key in PEM format using openssl

I am generating a KeyPair for ECC from curve 'secp128r1' using openssl

Steps I followed :

  • first I generated a private key using the command

    openssl ecparam -genkey -name secp128r1 -noout -out private.pem

  • then i viewed the corresponding public key using the command

    openssl ec -in private.pem -text -noout

    which showed an output as :

    read EC key

    Private-Key: (128 bit)
    priv:
    00:9f:bf:2b:bd:06:86:3a:a1:bc:7c:3e:90:57:40:
    f4:bc
    pub:
    04:04:ce:24:34:d4:cb:f2:58:94:2f:8a:5f:06:d7:
    3f:ed:5a:50:ef:fb:cc:b7:49:62:16:62:9e:aa:d5:
    30:a8:a5

    ASN1 OID: secp128r1

I want explicitly x and y components from the public key generated here, please can anyone suggest the correct way of doing this ?
The above public key is 264 bits long, hence cannot take(/split) it as is
Thanks

like image 441
Dhruv Agarwal Avatar asked Apr 11 '15 21:04

Dhruv Agarwal


People also ask

What is X and Y in public key?

A public key is the (X,Y) coordinate pair corresponding to that number (the private key) multiplied by the base point (which is a property of the curve used).

What is the public key in ECC?

An ECC key pair includes a private and public key. The ECC private key is used to generate digital signatures, and the ECC public key is used to verify digital signatures. ICSF generates ECC key pairs using the Elliptic Curve Digital Signature Algorithm (ECDSA).


1 Answers

Pub:
04:04:ce:24:34:d4:cb:f2:58:94:2f:8a:5f:06:d7:
3f:ed:5a:50:ef:fb:cc:b7:49:62:16:62:9e:aa:d5:
30:a8:a5
  • 0x04 indicates uncompressed form
  • From what remains:
    • X is first half 04:ce:24:34:d4:cb:f2:58:94:2f:8a:5f:06:d7:3f:ed
    • Y is second half 5a:50:ef:fb:cc:b7:49:62:16:62:9e:aa:d5:30:a8:a5

UPD. Found this website that contains further details.

like image 179
Daniel Avatar answered Oct 26 '22 16:10

Daniel