public abstract class EllipticCurve extends Object
It offers the (arithmetical) functionality that is required to perform
operations on points of an elliptic curve. The curve-specific code is
implemented by subclasses, which are not visible. Use the factories to
BinaryWeierstrassCurveFactory
to obtain binary Weierstrass-type
curves and PrimeWeierstrassCurveFactory
to obtain prime
Weierstrass-type curves.
The different coordinate systems that are supported are listed in
BinaryCurveCoordinateTypes
for binary curves and
PrimeCurveCoordinateTypes
for prime curves.
Note that (almost) all methods in this class work in-place. So, there is no guarantee that values input to methods in this class will not be overridden. In case of doubt and if values need to be reused, always clone the value, before inputting it to a method.
ECPoint
,
BinaryWeierstrassCurveFactory
,
PrimeWeierstrassCurveFactory
,
BinaryCurveCoordinateTypes
,
PrimeCurveCoordinateTypes
Modifier and Type | Method and Description |
---|---|
abstract ECPoint |
addPoint(ECPoint a,
ECPoint b)
Computes
a += b . |
boolean |
containsPoint(ECPoint p)
Returns true, iff
p satisfies the curve equation. |
ECPoint |
decodePoint(byte[] encodedPoint)
Decodes an encoded point.
|
abstract ECPoint |
decodePoint(byte[] encodedPoint,
int length)
Decodes an encoded point.
|
abstract ECPoint |
doublePoint(ECPoint a)
Computes
a *= 2 . |
byte[] |
encodePoint(ECPoint p)
Encodes a point, i.e.
|
abstract byte[] |
encodePoint(ECPoint p,
PointEncoders encoder)
Encodes a point, i.e.
|
abstract boolean |
equals(Object obj) |
GenericField |
getField()
Returns the underlying finite field of
this . |
ECPoint |
getGenerator()
Returns the generator of the elliptic curve (sub-)group.
|
ECPoint |
getNeutralPoint()
Returns the curve's neutral element.
|
BigInteger |
getOrder()
Returns the curve order of
this , i.e. |
abstract ECPoint |
getPoint(GenericFieldElement x)
Returns a point on the curve corresponding to
x , if
x is a valid x-coordinate. |
abstract ECPoint |
getPoint(GenericFieldElement x,
int yBit)
Returns a point on the curve corresponding to
x and
yBit (which uniquely determines the y-coordinate), if
x is a valid x-coordinate. |
abstract int |
hashCode() |
ECPoint |
hashToPoint(byte[] message)
Hash
message to a point on a curve. |
ECPoint |
hashToPoint(String message)
Hash
message to a point on a curve. |
abstract boolean |
isNeutralPoint(ECPoint p)
Returns
true , iff p is the neutral element. |
static boolean |
isRegular(Field field,
BigInteger a,
BigInteger b)
Determines whether a curve over field
field with parameters
a, b is regular. |
abstract ECPoint |
mixedAddPoint(ECPoint a,
ECPoint b)
Computes
a += b , where b is scaled. |
ECPoint |
mixedSubtractPoint(ECPoint a,
ECPoint b)
Computes
a -= b , where b is scaled. |
ECPoint |
multiplyPoint(ECPoint a,
BigInteger k)
Scalar multiplication of a point and an integer
a *= k . |
ECPoint |
multiplyPrecomputedPoint(BigInteger k)
Scalar multiplication of the point
a set for precomputation
and an integer a *= k using precomputation. |
ECPoint |
multiplySimultaneously(BigInteger[] scalars,
ECPoint[] points)
This method multiplies multiple points simultaneously.
|
ECPoint |
multiplySimultaneously(ECPoint a,
BigInteger k,
ECPoint b,
BigInteger l)
This method multiplies two points simultaneously.
|
ECPoint |
multiplySimultaneouslyWithPrecomputedPoint(BigInteger k,
ECPoint b,
BigInteger l)
This method multiplies two points simultaneously.
|
abstract ECPoint |
negatePoint(ECPoint a)
Negates the specified point on the curve.
|
ECPoint |
newPoint(ECPoint p)
Creates an ECPoint from a JDK ECPoint that is associated with this curve.
|
abstract ECPoint |
newPoint(GenericFieldElement x,
GenericFieldElement y)
Returns a point on the curve corresponding to
(x,y) , if
(x,y) is a point on the curve. |
void |
precompute(ECPoint a)
Computes the precomputation data for point
a and stores it
internally. |
abstract ECPoint |
scaledAddPoint(ECPoint a,
ECPoint b)
Computes
a += b , where a and b are
both scaled. |
abstract ECPoint |
scaledDoublePoint(ECPoint a)
Computes
a *= 2 , where a is scaled. |
ECPoint |
scaledSubtractPoint(ECPoint a,
ECPoint b)
Computes
a -= b , where a and b are
both scaled. |
abstract ECPoint |
scalePoint(ECPoint a)
Scales the specified point, i.e.
|
ECPoint[] |
scalePoints(ECPoint[] points)
Simultaneously scales the specified points, i.e.
|
ECPoint |
subtractPoint(ECPoint a,
ECPoint b)
Computes
a -= b . |
public GenericField getField()
this
.public static boolean isRegular(Field field, BigInteger a, BigInteger b)
field
with parameters
a, b
is regular.field
- the underyling fielda
- the first curve coefficientb
- the second curve coefficienttrue
if the curve is regular, false
if it
is singularpublic final BigInteger getOrder()
this
, i.e. the number of points on
the elliptic curve including the neutral element.null
if unknownpublic final ECPoint getGenerator()
public abstract ECPoint addPoint(ECPoint a, ECPoint b)
a += b
. The points must be elements of the group
(must lie on the curve). Subclasses do not need to check this.a
- the point a, to which b will be addedb
- the point b, which is added to a.public abstract ECPoint mixedAddPoint(ECPoint a, ECPoint b)
a += b
, where b
is scaled. The points
must be elements of the group (must lie on the curve). Subclasses do not
need to check this.a
- the point a, to which b will be addedb
- the point b, which is added to a.this
instance holding the resultpublic abstract ECPoint scaledAddPoint(ECPoint a, ECPoint b)
a += b
, where a
and b
are
both scaled. The points must be elements of the group (must lie on the
curve). Subclasses do not need check this.a
- the point a, to which b will be addedb
- the point b, which is added to a.this
instance holding the resultpublic ECPoint subtractPoint(ECPoint a, ECPoint b)
a -= b
. The points must be elements of the group
(must lie on the curve). Subclasses do not need to check this.a
- the point a, from which b will be subtractedb
- the point b, which is subtracted from a.this
instance holding the resultpublic ECPoint mixedSubtractPoint(ECPoint a, ECPoint b)
a -= b
, where b
is scaled. The points
must be elements of the group (must lie on the curve). Subclasses do not
need to check this.a
- the point a, from which b will be subtractedb
- the point b, which is subtracted from a.public ECPoint scaledSubtractPoint(ECPoint a, ECPoint b)
a -= b
, where a
and b
are
both scaled. The points must be elements of the group (must lie on the
curve). Subclasses do not need to check this.a
- the point a, from which b will be subtractedb
- the point b, which is subtracted from a.public abstract ECPoint doublePoint(ECPoint a)
a *= 2
. The point must be an element of the group
(must lie on the curve). Subclasses do not need to check this.a
- the point on this curvepublic abstract ECPoint scaledDoublePoint(ECPoint a)
a *= 2
, where a
is scaled. The point
must be element of the group (must lie on the curve). Subclasses do not
need to check this.a
- the point on this curvethis
instance holding the resultpublic abstract ECPoint negatePoint(ECPoint a)
a
- the point to be inverted.public abstract ECPoint scalePoint(ECPoint a)
Z=1
.a
- the point to be scaled.public ECPoint[] scalePoints(ECPoint[] points)
Z=1
. Note: this operation is beneficial as it
makes use of simultaneous inversion.points
- the points to be scaled.public ECPoint multiplyPoint(ECPoint a, BigInteger k)
a *= k
. It is
assumed that k
is a scalar modulo the order of the curve
group.a
- the point and resultk
- the factora
public void precompute(ECPoint a)
a
and stores it
internally.a
- the point a
public ECPoint multiplyPrecomputedPoint(BigInteger k)
a
set for precomputation
and an integer a *= k
using precomputation. It is assumed that
k
is a scalar modulo the order of the curve group.k
- the factora
public ECPoint multiplySimultaneouslyWithPrecomputedPoint(BigInteger k, ECPoint b, BigInteger l)
k * a + l * b
, where a
has been used with
precompute(ECPoint)
before. It is assumed that k, l
are scalars modulo the order of the curve group.k
- the first scalarb
- the second pointl
- the second scalark * a + l * b
public ECPoint multiplySimultaneously(ECPoint a, BigInteger k, ECPoint b, BigInteger l)
k * a + l * b
. It is assumed that k, l
are
scalars modulo the order of the curve group.a
- the first pointk
- the first scalarb
- the second pointl
- the second scalark * a + l * b
public ECPoint multiplySimultaneously(BigInteger[] scalars, ECPoint[] points)
k_1 * a_1 + k_2 * a_2 + ... + k_n * a_n
. It is
assumed that k_1, ..., k_n
are scalars modulo the order of the
curve group.scalars
- the scalars k_ipoints
- the points a_ik_1 * a_1 + k_2 * a_2 + ... + k_n * a_n
public final ECPoint getNeutralPoint()
public abstract boolean isNeutralPoint(ECPoint p)
true
, iff p
is the neutral element.p
- a point on the curvep
is the neutral elementpublic final boolean containsPoint(ECPoint p)
p
satisfies the curve equation.p
- the JDK ECPointp
satisfies the curve equationpublic final ECPoint newPoint(ECPoint p)
p
- the JDK ECPointpublic abstract ECPoint newPoint(GenericFieldElement x, GenericFieldElement y)
(x,y)
, if
(x,y)
is a point on the curve.x
- the x-coordinatey
- the y-coordinatenull
if x
is not a valid
x-coordinate, or a point corresponding to x
and
y
.public abstract byte[] encodePoint(ECPoint p, PointEncoders encoder)
byte[]
. The user can
choose between point compression and non-compressed encoding.p
- the point to be encodedencoder
- the point encoding algorithm to be usedbyte[]
holding the encoded pointpublic byte[] encodePoint(ECPoint p)
byte[]
. The user can
choose between point compression and non-compressed encoding.p
- the point to be encodedbyte[]
holding the encoded pointpublic abstract ECPoint decodePoint(byte[] encodedPoint, int length) throws DecodingException
encodedPoint
- the octet string to be converted into a point (either compressed
or uncompressed), including the PC byte.length
- the length of the sub-array to be consideredDecodingException
- if the point could not be decodedpublic ECPoint decodePoint(byte[] encodedPoint) throws DecodingException
encodedPoint
- the octet string to be converted into a point (either compressed
or uncompressed), including the PC byte.DecodingException
- if the point could not be decodedpublic abstract ECPoint getPoint(GenericFieldElement x)
x
, if
x
is a valid x-coordinate.x
- the x-coordinatenull
if x
is not a valid
x-coordinate, or a point corresponding to x
.public abstract ECPoint getPoint(GenericFieldElement x, int yBit)
x
and
yBit
(which uniquely determines the y-coordinate), if
x
is a valid x-coordinate.x
- the x-coordinateyBit
- determines which y-coordinate will be chosennull
if x
is not a valid
x-coordinate, or a point corresponding to x
.public final ECPoint hashToPoint(byte[] message) throws UnsupportedOperationException
message
to a point on a curve.message
- message to hashUnsupportedOperationException
- if hashing to this curve is not supported.public final ECPoint hashToPoint(String message) throws UnsupportedOperationException
message
to a point on a curve. This is the same as first
applying Util.toByteArray(String)
on the message and
then calling {hashToPoint(byte[])
.message
- message to hashUnsupportedOperationException
- if hashing to this curve is not supported.Util.toByteArray(String)
,
hashToPoint(byte[])
Copyright © 2011–2022 Stiftung SIC. All rights reserved.