Package org.bouncycastle.math.ec
Class ECCurve
- java.lang.Object
-
- org.bouncycastle.math.ec.ECCurve
-
- Direct Known Subclasses:
ECCurve.AbstractF2m
,ECCurve.AbstractFp
public abstract class ECCurve extends java.lang.Object
base class for an elliptic curve
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ECCurve.AbstractF2m
static class
ECCurve.AbstractFp
class
ECCurve.Config
static class
ECCurve.F2m
Elliptic curves over F2m.static class
ECCurve.Fp
Elliptic curve over Fp
-
Field Summary
Fields Modifier and Type Field Description protected ECFieldElement
a
protected ECFieldElement
b
protected java.math.BigInteger
cofactor
protected int
coord
static int
COORD_AFFINE
static int
COORD_HOMOGENEOUS
static int
COORD_JACOBIAN
static int
COORD_JACOBIAN_CHUDNOVSKY
static int
COORD_JACOBIAN_MODIFIED
static int
COORD_LAMBDA_AFFINE
static int
COORD_LAMBDA_PROJECTIVE
static int
COORD_SKEWED
protected ECEndomorphism
endomorphism
protected FiniteField
field
protected ECMultiplier
multiplier
protected java.math.BigInteger
order
-
Constructor Summary
Constructors Modifier Constructor Description protected
ECCurve(FiniteField field)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkPoint(ECPoint point)
protected void
checkPoints(ECPoint[] points)
protected void
checkPoints(ECPoint[] points, int off, int len)
protected abstract ECCurve
cloneCurve()
ECCurve.Config
configure()
ECLookupTable
createCacheSafeLookupTable(ECPoint[] points, int off, int len)
Create a cache-safe lookup table for the specified sequence of points.protected ECMultiplier
createDefaultMultiplier()
ECPoint
createPoint(java.math.BigInteger x, java.math.BigInteger y)
protected abstract ECPoint
createRawPoint(ECFieldElement x, ECFieldElement y)
protected abstract ECPoint
createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs)
ECPoint
decodePoint(byte[] encoded)
Decode a point on this curve from its ASN.1 encoding.protected abstract ECPoint
decompressPoint(int yTilde, java.math.BigInteger X1)
boolean
equals(java.lang.Object obj)
boolean
equals(ECCurve other)
abstract ECFieldElement
fromBigInteger(java.math.BigInteger x)
ECFieldElement
getA()
static int[]
getAllCoordinateSystems()
ECFieldElement
getB()
java.math.BigInteger
getCofactor()
int
getCoordinateSystem()
ECEndomorphism
getEndomorphism()
FiniteField
getField()
abstract int
getFieldSize()
abstract ECPoint
getInfinity()
ECMultiplier
getMultiplier()
Sets the defaultECMultiplier
, unless already set.java.math.BigInteger
getOrder()
PreCompInfo
getPreCompInfo(ECPoint point, java.lang.String name)
int
hashCode()
ECPoint
importPoint(ECPoint p)
abstract boolean
isValidFieldElement(java.math.BigInteger x)
void
normalizeAll(ECPoint[] points)
Normalization ensures that any projective coordinate is 1, and therefore that the x, y coordinates reflect those of the equivalent point in an affine coordinate system.void
normalizeAll(ECPoint[] points, int off, int len, ECFieldElement iso)
Normalization ensures that any projective coordinate is 1, and therefore that the x, y coordinates reflect those of the equivalent point in an affine coordinate system.PreCompInfo
precompute(ECPoint point, java.lang.String name, PreCompCallback callback)
Compute aPreCompInfo
for a point on this curve, under a given name.abstract ECFieldElement
randomFieldElement(java.security.SecureRandom r)
abstract ECFieldElement
randomFieldElementMult(java.security.SecureRandom r)
boolean
supportsCoordinateSystem(int coord)
ECPoint
validatePoint(java.math.BigInteger x, java.math.BigInteger y)
-
-
-
Field Detail
-
COORD_AFFINE
public static final int COORD_AFFINE
- See Also:
- Constant Field Values
-
COORD_HOMOGENEOUS
public static final int COORD_HOMOGENEOUS
- See Also:
- Constant Field Values
-
COORD_JACOBIAN
public static final int COORD_JACOBIAN
- See Also:
- Constant Field Values
-
COORD_JACOBIAN_CHUDNOVSKY
public static final int COORD_JACOBIAN_CHUDNOVSKY
- See Also:
- Constant Field Values
-
COORD_JACOBIAN_MODIFIED
public static final int COORD_JACOBIAN_MODIFIED
- See Also:
- Constant Field Values
-
COORD_LAMBDA_AFFINE
public static final int COORD_LAMBDA_AFFINE
- See Also:
- Constant Field Values
-
COORD_LAMBDA_PROJECTIVE
public static final int COORD_LAMBDA_PROJECTIVE
- See Also:
- Constant Field Values
-
COORD_SKEWED
public static final int COORD_SKEWED
- See Also:
- Constant Field Values
-
field
protected FiniteField field
-
a
protected ECFieldElement a
-
b
protected ECFieldElement b
-
order
protected java.math.BigInteger order
-
cofactor
protected java.math.BigInteger cofactor
-
coord
protected int coord
-
endomorphism
protected ECEndomorphism endomorphism
-
multiplier
protected ECMultiplier multiplier
-
-
Constructor Detail
-
ECCurve
protected ECCurve(FiniteField field)
-
-
Method Detail
-
getAllCoordinateSystems
public static int[] getAllCoordinateSystems()
-
getFieldSize
public abstract int getFieldSize()
-
fromBigInteger
public abstract ECFieldElement fromBigInteger(java.math.BigInteger x)
-
isValidFieldElement
public abstract boolean isValidFieldElement(java.math.BigInteger x)
-
randomFieldElement
public abstract ECFieldElement randomFieldElement(java.security.SecureRandom r)
-
randomFieldElementMult
public abstract ECFieldElement randomFieldElementMult(java.security.SecureRandom r)
-
configure
public ECCurve.Config configure()
-
validatePoint
public ECPoint validatePoint(java.math.BigInteger x, java.math.BigInteger y)
-
createPoint
public ECPoint createPoint(java.math.BigInteger x, java.math.BigInteger y)
-
cloneCurve
protected abstract ECCurve cloneCurve()
-
createRawPoint
protected abstract ECPoint createRawPoint(ECFieldElement x, ECFieldElement y)
-
createRawPoint
protected abstract ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs)
-
createDefaultMultiplier
protected ECMultiplier createDefaultMultiplier()
-
supportsCoordinateSystem
public boolean supportsCoordinateSystem(int coord)
-
getPreCompInfo
public PreCompInfo getPreCompInfo(ECPoint point, java.lang.String name)
-
precompute
public PreCompInfo precompute(ECPoint point, java.lang.String name, PreCompCallback callback)
Compute aPreCompInfo
for a point on this curve, under a given name. Used byECMultiplier
s to save the precomputation for thisECPoint
for use by subsequent multiplication.- Parameters:
point
- TheECPoint
to store precomputations for.name
- AString
used to index precomputations of different types.callback
- Called to calculate thePreCompInfo
.
-
normalizeAll
public void normalizeAll(ECPoint[] points)
Normalization ensures that any projective coordinate is 1, and therefore that the x, y coordinates reflect those of the equivalent point in an affine coordinate system. Where more than one point is to be normalized, this method will generally be more efficient than normalizing each point separately.- Parameters:
points
- An array of points that will be updated in place with their normalized versions, where necessary
-
normalizeAll
public void normalizeAll(ECPoint[] points, int off, int len, ECFieldElement iso)
Normalization ensures that any projective coordinate is 1, and therefore that the x, y coordinates reflect those of the equivalent point in an affine coordinate system. Where more than one point is to be normalized, this method will generally be more efficient than normalizing each point separately. An (optional) z-scaling factor can be applied; effectively each z coordinate is scaled by this value prior to normalization (but only one actual multiplication is needed).- Parameters:
points
- An array of points that will be updated in place with their normalized versions, where necessaryoff
- The start of the range of points to normalizelen
- The length of the range of points to normalizeiso
- The (optional) z-scaling factor - can be null
-
getInfinity
public abstract ECPoint getInfinity()
-
getField
public FiniteField getField()
-
getA
public ECFieldElement getA()
-
getB
public ECFieldElement getB()
-
getOrder
public java.math.BigInteger getOrder()
-
getCofactor
public java.math.BigInteger getCofactor()
-
getCoordinateSystem
public int getCoordinateSystem()
-
decompressPoint
protected abstract ECPoint decompressPoint(int yTilde, java.math.BigInteger X1)
-
getEndomorphism
public ECEndomorphism getEndomorphism()
-
getMultiplier
public ECMultiplier getMultiplier()
Sets the defaultECMultiplier
, unless already set. We avoid synchronizing for performance reasons, so there is no uniqueness guarantee.
-
decodePoint
public ECPoint decodePoint(byte[] encoded)
Decode a point on this curve from its ASN.1 encoding. The different encodings are taken account of, including point compression forFp
(X9.62 s 4.2.1 pg 17).- Returns:
- The decoded point.
-
createCacheSafeLookupTable
public ECLookupTable createCacheSafeLookupTable(ECPoint[] points, int off, int len)
Create a cache-safe lookup table for the specified sequence of points. All the points MUST belong to thisECCurve
instance, and MUST already be normalized.
-
checkPoint
protected void checkPoint(ECPoint point)
-
checkPoints
protected void checkPoints(ECPoint[] points)
-
checkPoints
protected void checkPoints(ECPoint[] points, int off, int len)
-
equals
public boolean equals(ECCurve other)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-