I'd like to use a curve that's not included in the Bouncy Castle EC named curves spec, specifically E-521.

According to the BC javadocs, you need a few values in order to do this: q, a, and b for the curve, then G and n for the parameter spec.

import org.bouncycastle.math.ec.ECCurve;
import org.bouncycastle.jce.spec.ECParameterSpec;
ECCurve curve = new ECCurve.Fp(
            new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
            new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
            new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
ECParameterSpec ecSpec = new ECParameterSpec(
            curve.decodePoint(Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
            new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");
g.initialize(ecSpec, new SecureRandom());
KeyPair pair = g.generateKeyPair();

I think q is the field.

Would a and b be base points?

What should be used for G and n?

  • $\begingroup$ BouncyCastle only supports weierstrass for curves. So you'd need to convert the curve and the points from edwards to weierstrass before use. Of course this negates most of the advantage of E521 over curves like P521, the fast and constant time arithmetic in edwards or montgomery form. $\endgroup$ – CodesInChaos Sep 22 '14 at 7:54

In order to do this, first convert the Edwards curve to Montgomery form, then to Weierstrass form, per this thread.

But, as the above thread explains, as well as CodesInChaos' comment, this will result in poor performance.

Thanks to CodesInChaos for pointing me in the right direction despite the stupid question.

Also see:


Not the answer you're looking for? Browse other questions tagged or ask your own question.