简体   繁体   中英

Can you do basic EC operations in Java 7 without a third-party library?

Java 7 comes with SunEC , which provides ECDH and ECDSA operations. I was attempting to do basic EC operations (point addition, scalar multiplication).

I start with

ECParameterSpec p256 = NamedCurve.getECParameterSpec("secp256r1");
ECPoint generator = p256.getGenerator();
BigInteger scalar = new BigInteger("23"); 

But from there, I do not see the next step. There is no ECPoint.scalarMultiply() or ECPoint.add() or EllipticCurve.multiply() .

Am I missing something, or is the answer just "you can't do it without a third-party library?"

You can't do it directly without a third-party library. I think the situation with elliptic curves in the JCE is basically analogous to that of RSA. The classes represents instances of various keys and encodings. You can go between encodings and key specs using KeyFactory, you can generate public and private keys using a KeyPairGenerator, etc. But just like there is no RSAPublicKey.exponentiate() there is also no ECPoint.add(). These things happen under the hood in the Signature, KeyAgreement, and Cipher classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM