public final class EllipticCurve extends EllipticCurve implements Cloneable
EllipticCurve
. Take a look at the latter
for a comprehensive support of EC arithmetic.
Either use one of the getCurve(java.security.spec.EllipticCurve)
,
getCurve(java.security.spec.EllipticCurve, AlgorithmID)
,
getCurve(Field, BigInteger, BigInteger, BigInteger)
,
getCurve(Field, BigInteger, BigInteger, BigInteger, byte[])
, and
getCurve(Field, BigInteger, BigInteger, BigInteger, MessageDigest, byte[])
methods to obtain a custom elliptic curve object or
ECStandardizedParameterFactory
in order to obtain standardized
curves.
References:
[1] ANSI X9.62-2005, "American National Standard for Financial Services - The Elliptic Curve Digital Signature Algorithm (ECDSA)", ASC X9, November 2005.
ECStandardizedParameterFactory
Modifier and Type | Method and Description |
---|---|
ECPoint |
addPoint(ECPoint p,
ECPoint q)
Adds two points.
|
EllipticCurve |
clone() |
boolean |
containsPoint(ECPoint p)
Returns true, iff
p satisfies the curve equation. |
ECPoint |
decodePoint(byte[] encodedPoint)
Decodes an encoded point.
|
ECPoint |
decodePoint(byte[] encodedPoint,
int length)
Decodes an encoded point.
|
byte[] |
encodePoint(ECPoint p)
Encodes a point, i.e.
|
byte[] |
encodePoint(ECPoint p,
PointEncoders encoder)
Encodes a point, i.e.
|
boolean |
equals(Object obj) |
static EllipticCurve |
getCurve(EllipticCurve curve)
Constructs a new wrapped curve from a JDK curve.
|
static EllipticCurve |
getCurve(EllipticCurve curve,
iaik.asn1.structures.AlgorithmID hashAlgorithm)
Constructs a new wrapped curve from a JDK curve.
|
static EllipticCurve |
getCurve(Field field,
BigInteger a,
BigInteger b,
BigInteger order)
Constructs a new curve.
|
static EllipticCurve |
getCurve(Field field,
BigInteger a,
BigInteger b,
BigInteger order,
byte[] seed)
Constructs a new curve.
|
static EllipticCurve |
getCurve(Field field,
BigInteger a,
BigInteger b,
BigInteger order,
MessageDigest md,
byte[] seed)
Constructs a new curve.
|
CurveTypes |
getCurveType()
Return the curve type of the curve, i.e.
|
Field |
getField() |
EllipticCurve |
getIAIKCurve()
Returns the internally used elliptic curve implementation.
|
int |
hashCode() |
ECPoint |
multiplyGenerator(BigInteger n)
Performs the scalar multiplication
n * g , where g
is the generator of the curve group. |
ECPoint |
multiplyPoint(ECPoint p,
BigInteger n)
Performs the scalar multiplication
n * p employing
precomputation. |
ECPoint |
multiplyPointSimultaneouslyWithGenerator(BigInteger k,
ECPoint q,
BigInteger l)
Performs the simultaneous scalar multiplication
k * g + l * q ,
where g is the generator. |
ECPoint |
negatePoint(ECPoint p)
Negates a point.
|
ECPoint |
secureMultiplyGenerator(BigInteger n)
Securely performs the scalar multiplication
n * g by using
blinding, where g is the generator of the curve group. |
ECPoint |
secureMultiplyGenerator(BigInteger n,
SecureRandom random)
Securely performs the scalar multiplication
n * g by using
blinding, where g is the generator of the curve group. |
ECPoint |
secureMultiplyPoint(ECPoint p,
BigInteger n)
Performs the scalar multiplication
n * p employing
precomputation and blinding of n . |
ECPoint |
secureMultiplyPoint(ECPoint p,
BigInteger n,
SecureRandom random)
Performs the scalar multiplication
n * p employing
precomputation and blinding of n . |
void |
setGenerator(ECPoint g)
Sets the curve's generator and performs precomputation to speed up scalar
multiplications that involve the generator.
|
ECPoint |
subtractPoint(ECPoint p,
ECPoint q)
Subtracts two points.
|
iaik.asn1.SEQUENCE |
toASN1Object()
Converts a curve to the following ASN.1 structure:
Curve ::= SEQUENCE {
a FieldElement, -- Elliptic curve coefficient a
b FieldElement, -- Elliptic curve coefficient b
seed BIT STRING OPTIONAL -- The seed that was used to generate this curve
}
|
iaik.asn1.OCTET_STRING |
toASN1Object(ECPoint p)
The ASN.1 representation of the given point
p as defined in
[1]. |
ECPoint |
toIAIKECPoint(ECPoint p)
Converts a JDK ECPoint object into an IAIK ECPoint.
|
String |
toString()
Returns a
String representation of this curve. |
getA, getB, getSeed
public static EllipticCurve getCurve(EllipticCurve curve) throws InvalidCurveException
curve
- a JDK elliptic curveEllipticCurve
instanceInvalidCurveException
- in case that the curve validation failedpublic static EllipticCurve getCurve(EllipticCurve curve, iaik.asn1.structures.AlgorithmID hashAlgorithm) throws InvalidCurveException
curve
- a JDK elliptic curvehashAlgorithm
- the approved hash algorithm that was used to generate the curve;
if it is null
, but the seed is given, then SHA-1 will
be used to validate the curveEllipticCurve
instanceInvalidCurveException
- in case that the curve validation failedpublic static EllipticCurve getCurve(Field field, BigInteger a, BigInteger b, BigInteger order, MessageDigest md, byte[] seed) throws InvalidCurveException
field
- the underlying binary fielda
- a positive value representing the curve parameter a
b
- a positive value representing the curve parameter b
order
- the order of the associated curve groupmd
- the approved hash algorithm that was used to generate the curve;
if it is null
, but the seed is given, then SHA-1 will
be used to validate the curveseed
- the seed that was used to generate this curveEllipticCurve
instanceInvalidCurveException
- in case that the curve validation failedpublic static EllipticCurve getCurve(Field field, BigInteger a, BigInteger b, BigInteger order, byte[] seed) throws InvalidCurveException
field
- the underlying binary fielda
- a positive value representing the curve parameter a
b
- a positive value representing the curve parameter b
order
- the order of the associated curve groupseed
- the seed that was used to generate this curveEllipticCurve
instanceInvalidCurveException
- in case that the curve validation failedpublic static EllipticCurve getCurve(Field field, BigInteger a, BigInteger b, BigInteger order) throws InvalidCurveException
field
- the underlying binary fielda
- a positive value representing the curve parameter a
b
- a positive value representing the curve parameter b
order
- the order of the associated curve groupEllipticCurve
instanceInvalidCurveException
- in case that the curve validation failedpublic EllipticCurve getIAIKCurve()
public ECPoint multiplyPoint(ECPoint p, BigInteger n)
n * p
employing
precomputation.p
- a point on the curven
- the scalarp
public ECPoint secureMultiplyPoint(ECPoint p, BigInteger n)
n * p
employing
precomputation and blinding of n
.p
- a point on the curven
- the scalarp
public ECPoint secureMultiplyPoint(ECPoint p, BigInteger n, SecureRandom random)
n * p
employing
precomputation and blinding of n
.p
- a point on the curven
- the scalarrandom
- a SecureRandom
instancep
public ECPoint addPoint(ECPoint p, ECPoint q)
p
- a point on the curveq
- a second point on the curvep
and q
public ECPoint subtractPoint(ECPoint p, ECPoint q)
p
- a point on the curveq
- a second point on the curvep
and q
public ECPoint negatePoint(ECPoint p)
p
- a point on the curvep
public void setGenerator(ECPoint g)
g
- the generator of the curve grouppublic ECPoint multiplyGenerator(BigInteger n)
n * g
, where g
is the generator of the curve group. Note a generator must be set previous
to calling this method using setGenerator(ECPoint)
.n
- the scalarg
public ECPoint secureMultiplyGenerator(BigInteger n)
n * g
by using
blinding, where g
is the generator of the curve group. Note a
generator must be set previous to calling this method using
setGenerator(ECPoint)
.n
- the scalarg
public ECPoint secureMultiplyGenerator(BigInteger n, SecureRandom random)
n * g
by using
blinding, where g
is the generator of the curve group. Note a
generator must be set previous to calling this method using
setGenerator(ECPoint)
.n
- the scalarrandom
- a SecureRandom
instanceg
public ECPoint multiplyPointSimultaneouslyWithGenerator(BigInteger k, ECPoint q, BigInteger l)
k * g + l * q
,
where g
is the generator. Note a generator must be set
previous to calling this method using setGenerator(ECPoint)
.k
- the first scalarq
- the second point on the curvel
- the second scalarg
public Field getField()
getField
in class EllipticCurve
public boolean containsPoint(ECPoint p)
p
satisfies the curve equation.p
- the ECPointp
satisfies the curve equationpublic byte[] encodePoint(ECPoint p)
byte[]
, using the
default encoding algorithm.p
- the point to be encodedbyte[]
representing the encoded pointPointEncoders.getDefaultPointEncoder()
,
PointEncoders.setDefaultPointEncoder(iaik.security.ec.common.PointEncoders)
public byte[] encodePoint(ECPoint p, PointEncoders encoder)
byte[]
, using the
default encoding algorithm.p
- the point to be encodedencoder
- the point encoding algorithm to be usedbyte[]
representing the encoded pointPointEncoders.getDefaultPointEncoder()
,
PointEncoders.setDefaultPointEncoder(iaik.security.ec.common.PointEncoders)
public 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 encodedPoint
could not be decodedpublic 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 encodedPoint
could not be decodedpublic ECPoint toIAIKECPoint(ECPoint p)
p
- the JDK ECPointpublic iaik.asn1.SEQUENCE toASN1Object()
Curve ::= SEQUENCE {
a FieldElement, -- Elliptic curve coefficient a
b FieldElement, -- Elliptic curve coefficient b
seed BIT STRING OPTIONAL -- The seed that was used to generate this curve
}
public iaik.asn1.OCTET_STRING toASN1Object(ECPoint p)
p
as defined in
[1].p
- the point to be ASN.1 encodedpublic CurveTypes getCurveType()
public boolean equals(Object obj)
equals
in class EllipticCurve
public int hashCode()
hashCode
in class EllipticCurve
public EllipticCurve clone()
Copyright © 2011–2022 Stiftung SIC. All rights reserved.