BouncyCastle

Primitives

Supports short-Weierstrass curves for the usual (ECDSA, ECDH). Supports X25519, Ed25519. Also more exotic stuff like ECMQV, GOST key exchange and signatures and lots of others.

Lots of scalarmults available:
Several coordinate systems supported:
  • Affine

  • Projective (Homogenous)

  • Jaobian

  • Jacobian-Chudnovsky

  • Jacobian-Modified

  • Lambda-Affine? (binary-field curves only)

  • Lambda-Projective? (binary-field curves only)

  • Skewed? (binary-field curves only)

Some curve-custom code in: https://github.com/bcgit/bc-java/tree/r1rv76/core/src/main/java/org/bouncycastle/math/ec/custom/sec Specifically, fast-prime modular reduction for SECG curves, and (weirdly) a short-Weierstrass implementation of Curve25519.

Ed25519 based on Mike Hamburg’s work.

ECDH

KeyGen:
Derive:
  • Short-Weierstrass

  • GLV if possible, else Window NAF via ECDHBasicAgreement.calculateAgreement -> ECPoint.multiply -> ECCurve.getMultiplier -> ECCurve.createDefaultMultiplier.

  • Jacobian-Modified via ECCurve.FP_DEFAULT_COORDS. SECP curves use Jacobian, SECT curves use Lambda-Projective.

  • Formulas same as KeyGen.

ECDSA

KeyGen:
  • Short-Weierstrass

  • Comb via ECKeyPairGenerator.generateKeyPair -> ECKeyPairGenerator.createBasePointMultiplier.

  • Jacobian-Modified via ECCurve.FP_DEFAULT_COORDS. SECP curves use Jacobian, SECT curves use Lambda-Projective.

  • Formulas same as KeyGen.

Sign:
  • Short-Weierstrass

  • Comb via ECDSASigner.generateSignature -> ECDSASigner.createBasePointMultiplier.

  • Jacobian-Modified via ECCurve.FP_DEFAULT_COORDS. SECP curves use Jacobian, SECT curves use Lambda-Projective.

  • Formulas same as KeyGen.

Verify:

X25519

KeyGen:
  • Twisted-Edwards

  • Comb via X25519.generatePublicKey -> X25519.scalarMultBase -> Ed25519.scalarMultBaseYZ -> Ed25519.scalarMultBase.

  • Many coordinate systems: Extended, half-Niels, affine.

  • Some HWCD formulas are used.

Derive:

Ed25519

KeyGen:
  • Twisted-Edwards

  • Comb via Ed25519.generatePublicKey -> Ed25519.scalarMultBaseEncoded -> Ed25519.scalarMultBase.

  • Many coordinate systems: Extended, half-Niels, affine.

  • Some HWCD formulas are used.

Sign:
  • Twisted-Edwards

  • Comb via Ed25519.sign -> Ed25519.implSign -> Ed25519.scalarMultBaseEncoded -> Ed25519.scalarMultBase.

  • Many coordinate systems: Extended, half-Niels, affine.

  • Some HWCD formulas are used.

Verify: