EllipticCurvepublic class EllipticCurve extends Object This immutable class holds the necessary values needed to represent
an elliptic curve. |
Fields Summary |
---|
private final ECField | field | private final BigInteger | a | private final BigInteger | b | private final byte[] | seed |
Constructors Summary |
---|
public EllipticCurve(ECField field, BigInteger a, BigInteger b)Creates an elliptic curve with the specified elliptic field
field and the coefficients a and
b .
this(field, a, b, null);
| public EllipticCurve(ECField field, BigInteger a, BigInteger b, byte[] seed)Creates an elliptic curve with the specified elliptic field
field , the coefficients a and
b , and the seed used for curve generation.
if (field == null) {
throw new NullPointerException("field is null");
}
if (a == null) {
throw new NullPointerException("first coefficient is null");
}
if (b == null) {
throw new NullPointerException("second coefficient is null");
}
checkValidity(field, a, "first coefficient");
checkValidity(field, b, "second coefficient");
this.field = field;
this.a = a;
this.b = b;
if (seed != null) {
this.seed = (byte[]) seed.clone();
} else {
this.seed = null;
}
|
Methods Summary |
---|
private static void | checkValidity(java.security.spec.ECField field, java.math.BigInteger c, java.lang.String cName)
// can only perform check if field is ECFieldFp or ECFieldF2m.
if (field instanceof ECFieldFp) {
BigInteger p = ((ECFieldFp)field).getP();
if (p.compareTo(c) != 1) {
throw new IllegalArgumentException(cName + " is too large");
} else if (c.signum() < 0) {
throw new IllegalArgumentException(cName + " is negative");
}
} else if (field instanceof ECFieldF2m) {
int m = ((ECFieldF2m)field).getM();
if (c.bitLength() > m) {
throw new IllegalArgumentException(cName + " is too large");
}
}
| public boolean | equals(java.lang.Object obj)Compares this elliptic curve for equality with the
specified object.
if (this == obj) return true;
if (obj instanceof EllipticCurve) {
EllipticCurve curve = (EllipticCurve) obj;
if ((field.equals(curve.field)) &&
(a.equals(curve.a)) &&
(b.equals(curve.b)) &&
(Arrays.equals(seed, curve.seed))) {
return true;
}
}
return false;
| public java.math.BigInteger | getA()Returns the first coefficient a of the
elliptic curve.
return a;
| public java.math.BigInteger | getB()Returns the second coefficient b of the
elliptic curve.
return b;
| public java.security.spec.ECField | getField()Returns the finite field field that this
elliptic curve is over.
return field;
| public byte[] | getSeed()Returns the seeding bytes seed used
during curve generation. May be null if not specified.
if (seed == null) return null;
else return (byte[]) seed.clone();
| public int | hashCode()Returns a hash code value for this elliptic curve.
return (field.hashCode() << 6 +
(a.hashCode() << 4) +
(b.hashCode() << 2) +
(seed==null? 0:seed.length));
|
|