Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Recover elliptic curve public key from private?

bobococoOct 8 2014 — edited Oct 15 2014

Hello,

I wonder if it is possible to recover the public key corresponding to a particular private key stored in the java card?

Suppose that n is the private key, then the public key is n*G where G is the base point of the curve.

Consequently, a possibility would be using Addition/ Scalar multiplication of Points on elliptic curves. This is explored in this topic:

Addition/ Scalar multiplication of Points on elliptic curves

I am using a Yubikey that supports the following (elliptic curve parameter from secp256k1):

ECPrivateKey prv_key = (ECPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, LENGTH_EC_FP_256, false);

[...]

KeyAgreement keyAgreement = KeyAgreement.getInstance((byte)3, false); // ALG_EC_SVDP_DH_PLAIN (https://javacard.kenai.com/javadocs/connected/javacard/security/KeyAgreement.html#ALG_EC_SVDP_DH_PLAIN)

keyAgreement.init(prv_key);

short lenOut = keyAgreement.generateSecret(SECP256K1_G, (short) 0, (short) SECP256K1_G.length, buffer, (short)0);

apdu.setOutgoingAndSend((short) 0, lenOut);

Where SECP256K1_G is the base point of the curve...

This test code works great, however, as described in this Wikipedia article, the method only returns the x coordinate of the public key (point) corresponding to the private key!

Is it possible to recover also the y-coordinate, or at least the parity of the y-coordinate (to get the compressed form of the public key)?

After hours of trial, I am only one (parity) bit from recovering the public key, that's a bit frustrating :-)

I find it surprisingly difficult to simply recover the public key for a given private key.

May be I missed a more obvious method?

Thanks a lot for your help!!!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2014
Added on Oct 8 2014
3 comments
2,322 views