# Class EllipticCurveGroup

java.lang.Object
org.apfloat.jscience.EllipticCurveGroup

All Implemented Interfaces:
  `Serializable, Immutable, Realtime, ValueType, XMLSerializable, GroupAdditive<EllipticCurveGroup>, Structure<EllipticCurveGroup>`

public class EllipticCurveGroup extends Object implements GroupAdditive<EllipticCurveGroup>, Realtime, XMLSerializable, Serializable
This class represents a point on an elliptic curve defined over the integers modulo a modulus. All arithmetic is done in Weierstrass form.

This class sets the modulus using `ModuloApintField.setModulus(Apint)`.

Since:
  1.15.0
Version:
  1.15.0
Author:
  Mikko Tommila
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final EllipticCurveGroup`
  `O`
  The "point at infinity".

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `EllipticCurveGroup(Apint x, Apint y)`
  Constructs a new point on the elliptic curve.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `EllipticCurveGroup`
  `copy()`
  `boolean`
  `equals(Object obj)`
  `static EllipticCurveGroup`
  `fromEdwardsPoint(Apint x, Apint y)`
  Construct a point from twisted Edwards curve coordinates.
  `static EllipticCurveGroup`
  `fromMontgomeryPoint(Apint x, Apint y)`
  Construct a point from Montgomery curve coordinates.
  `static Apint`
  `getA()`
  Returns the curve parameter a in Weierstrass form.
  `static Apint`
  `getB()`
  Returns the curve parameter b in Weierstrass form.
  `static Apint`
  `getJInvariant()`
  Returns the j-invariant of the curve.
  `Apint`
  `getX()`
  Returns the x-coordinate of this point.
  `Apint`
  `getY()`
  Returns the y-coordinate of this point.
  `int`
  `hashCode()`
  `EllipticCurveGroup`
  `opposite()`
  `EllipticCurveGroup`
  `plus(EllipticCurveGroup that)`
  `static void`
  `setEdwardsParameters(Apint a, Apint d, Apint p)`
  Set the curve parameters in twisted Edwards form.
  `static void`
  `setMontgomeryParameters(Apint b, Apint a, Apint p)`
  Set the curve parameters in Montgomery form.
  `static void`
  `setWeierstrassParameters(Apint a, Apint b, Apint p)`
  Set the curve parameters in Weierstrass form.
  `EllipticCurveGroup`
  `times(Apint that)`
  Returns this elliptic curve point multiplied by a scalar.
  `String`
  `toString()`
  `Text`
  `toText()`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### O

    public static final EllipticCurveGroup O
    The "point at infinity".

- ## Constructor Details

  - ### EllipticCurveGroup

    public EllipticCurveGroup(Apint x, Apint y)
    Constructs a new point on the elliptic curve. Uses Weierstrass coordinates.
    Parameters:
      `x` - The x-coordinate.
      `y` - The y-coordinate.

- ## Method Details

  - ### fromMontgomeryPoint

    public static EllipticCurveGroup fromMontgomeryPoint(Apint x, Apint y)
    Construct a point from Montgomery curve coordinates. The Montgomery curve parameters must be first set with `setMontgomeryParameters(Apint, Apint, Apint)`.
    Parameters:
      `x` - The Montgomery curve x-coordinate.
      `y` - The Montgomery curve y-coordinate.
    Returns:
      The point in Weierstrass coordinates.

  - ### fromEdwardsPoint

    public static EllipticCurveGroup fromEdwardsPoint(Apint x, Apint y)
    Construct a point from twisted Edwards curve coordinates. The Edwards curve parameters must be first set with `setEdwardsParameters(Apint, Apint, Apint)`.
    Parameters:
      `x` - The Edwards curve x-coordinate.
      `y` - The Edwards curve y-coordinate.
    Returns:
      The point in Weierstrass coordinates.

  - ### setWeierstrassParameters

    public static void setWeierstrassParameters(Apint a, Apint b, Apint p)
    Set the curve parameters in Weierstrass form. The elliptic curve specified in the Weierstrass form is
    y2 = x3 + a x + b

    For example, Curve25519 can be set with

    `setWeierstrassParameters(new Apint(486662), new Apint(1), ApintMath.pow(new Apint(2), 255).subtract(new Apint(19)))`

    Parameters:
      `a` - The curve parameter a.
      `b` - The curve parameter b.
      `p` - The modulus.

  - ### setMontgomeryParameters

    public static void setMontgomeryParameters(Apint b, Apint a, Apint p)
    Set the curve parameters in Montgomery form. The elliptic curve specified in the Montgomery form is
    B y2 = x3 + A x2 + x For example, Curve25519 can be set with

    `setMontgomeryParameters(new Apint(1), new Apint(486662), ApintMath.pow(new Apint(2), 255).subtract(new Apint(19)))`

    Parameters:
      `b` - The curve parameter B.
      `a` - The curve parameter A.
      `p` - The modulus.

  - ### setEdwardsParameters

    public static void setEdwardsParameters(Apint a, Apint d, Apint p)
    Set the curve parameters in twisted Edwards form. The elliptic curve specified in the twisted Edwards form is
    a x2 + y2 = 1 + d x2 y2 For example, Curve448 can be set with

    `setEdwardsParameters(new Apint(1), new Apint(-39081), ApintMath.pow(new Apint(2), 448).subtract(ApintMath.pow(new Apint(2), 224).subtract(new Apint(1))))`

    Parameters:
      `a` - The curve parameter a.
      `d` - The curve parameter d.
      `p` - The modulus.

  - ### getA

    public static Apint getA()
    Returns the curve parameter a in Weierstrass form.
    Returns:
      The curve parameter a.
    See Also:
      - `setWeierstrassParameters(Apint, Apint, Apint)`

  - ### getB

    public static Apint getB()
    Returns the curve parameter b in Weierstrass form.
    Returns:
      The curve parameter b.
    See Also:
      - `setWeierstrassParameters(Apint, Apint, Apint)`

  - ### getJInvariant

    public static Apint getJInvariant()
    Returns the j-invariant of the curve.
    Returns:
      The j-invariant of the curve.

  - ### getX

    public Apint getX()
    Returns the x-coordinate of this point.
    Returns:
      The x-coordinate.

  - ### getY

    public Apint getY()
    Returns the y-coordinate of this point.
    Returns:
      The y-coordinate.

  - ### plus

    public EllipticCurveGroup plus(EllipticCurveGroup that)
    Specified by:
      `plus` in interface `GroupAdditive<EllipticCurveGroup>`

  - ### times

    public EllipticCurveGroup times(Apint that)
    Returns this elliptic curve point multiplied by a scalar.
    Parameters:
      `that` - The multiplier.
    Returns:
      The resulting elliptic curve point.

  - ### opposite

    public EllipticCurveGroup opposite()
    Specified by:
      `opposite` in interface `GroupAdditive<EllipticCurveGroup>`

  - ### copy

    public EllipticCurveGroup copy()
    Specified by:
      `copy` in interface `ValueType`

  - ### toText

    public Text toText()
    Specified by:
      `toText` in interface `Realtime`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`