java.lang.Object
net.i2p.crypto.ECUtil

final class ECUtilextends Object
Elliptic curve utility functions for cryptographic operations.

This class provides essential mathematical operations for elliptic curve cryptography used throughout I2P, including scalar multiplication, point operations, and curve parameter handling. It supports multiple curve types with optimized implementations for common cryptographic operations.

Key operations include:

  • Scalar multiplication of curve points
  • Point addition and doubling operations
  • Curve parameter validation and extraction
  • Support for standard NIST curves (P-192, P-256, P-384, P-521)
  • Field Details

    • TWO

      private static final BigInteger TWO
      The constant 2.
    • THREE

      private static final BigInteger THREE
      The constant 3.
  • Constructor Details

    • ECUtil

      ECUtil()
      Constructor. Every operation below is a static function of its curve arguments, so an instance holds nothing.
  • Method Details

    • addPoint

      private static ECPoint addPoint(ECPoint r, ECPoint s, EllipticCurve curve)
      Adds two points on a curve.
      Parameters:
      r - the first point
      s - the second point
      curve - the curve they lie on
      Returns:
      the sum of the two points
    • doublePoint

      private static ECPoint doublePoint(ECPoint r, EllipticCurve curve)
      Doubles a point on a curve.
      Parameters:
      r - the point to double
      curve - the curve it lies on
      Returns:
      twice the point