I get stack on my error of point multiplication using standard projective coordinates. I don\'t know what i missed but the multiplied points do not lie on the curve and some t
The most important errors are in NISTCurves.P192: p and the order are in base-10, not in base-16. Also, when you construct the EllipticCurve-object, you provide the parameters in the wrong order. Your method requires (a, b, p)
, but you call it with (p, a, b)
(so my guess about p
not being prime was correct).
Another problem is in your verify-method, when you unwrap r
and s
. Since they are in unsigned format, you should use new BigInteger(1, rArr)
instead of the normal constructor.
With those changes your code works for me (I can validate the signatures - I have not verified the correctness of the implementation).
(Old answer below:)
Since you have not given us the code that matches the stacktrace, this will merely be a guess:
During elliptic curve addition (with a curve over a prime field), you should only be calling BigInteger.modInverse()
with the prime p
(the order of the prime field) as the modulus.
The most probable way for this to fail sporadically with "BigInteger not invertible" is if p
is not actually a prime.
Where are you getting p
from? Try inserting
if(!ec.getP().isProbablePrime(100)) throw new RuntimeException("P is not a prime");
somewhere.