ECPoint

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ECPoint

rangeli nepal
Good Evening Gentlemen,

I am trying to use java ECPoint of org.bouncycastle.ec.math package. I generate random number and create ECPoing ( public coordinates) as follows.  I am using P-256 curve. My expectation is AffineXcoordiante or AffineYCoord will be 32 bytes.
However I some time get 32 other time it gives 33. am I missing something?

Your answer will be appreciated.

Thank you.
Regards,
rn


ECPoint g = x9.getG()
ECPoint pointQ = g.multiply(privateKey);
pointQ=pointQ.normalize();
byte[] datax1=pointQ.getAffineXCoord().toBigInteger().toByteArray();
byte[] datay1=pointQ.getAffineYCoord().toBigInteger().toByteArray();
System.out.println(“Len X=“+ datax1.length+”  Y=“+datay1.length)
                       
                       
Reply | Threaded
Open this post in threaded view
|

Re: ECPoint

David Hook-3

toByteArray() produces the BigInteger as a big-endian two's complement
number. Sometimes you will see an extra byte due to the need to add a
zero byte to prevent the number being interpreted as a negative.

Regards,

David

On 18/06/18 10:09, rangeli nepal wrote:

> Good Evening Gentlemen,
>
> I am trying to use java ECPoint of org.bouncycastle.ec.math package. I generate random number and create ECPoing ( public coordinates) as follows.  I am using P-256 curve. My expectation is AffineXcoordiante or AffineYCoord will be 32 bytes.
> However I some time get 32 other time it gives 33. am I missing something?
>
> Your answer will be appreciated.
>
> Thank you.
> Regards,
> rn
>
>
> ECPoint g = x9.getG()
> ECPoint pointQ = g.multiply(privateKey);
> pointQ=pointQ.normalize();
> byte[] datax1=pointQ.getAffineXCoord().toBigInteger().toByteArray();
> byte[] datay1=pointQ.getAffineYCoord().toBigInteger().toByteArray();
> System.out.println(“Len X=“+ datax1.length+”  Y=“+datay1.length)
>
>
>