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 Object
base class for an elliptic curve
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classECCurve.AbstractF2mstatic classECCurve.AbstractFpclassECCurve.Configstatic classECCurve.F2mElliptic curves over F2m.static classECCurve.FpElliptic curve over Fp
-
Field Summary
Fields Modifier and Type Field Description protected ECFieldElementaprotected ECFieldElementbprotected BigIntegercofactorprotected intcoordstatic intCOORD_AFFINEstatic intCOORD_HOMOGENEOUSstatic intCOORD_JACOBIANstatic intCOORD_JACOBIAN_CHUDNOVSKYstatic intCOORD_JACOBIAN_MODIFIEDstatic intCOORD_LAMBDA_AFFINEstatic intCOORD_LAMBDA_PROJECTIVEstatic intCOORD_SKEWEDprotected ECEndomorphismendomorphismprotected FiniteFieldfieldprotected ECMultipliermultiplierprotected BigIntegerorder
-
Constructor Summary
Constructors Modifier Constructor Description protectedECCurve(FiniteField field)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckPoint(ECPoint point)protected voidcheckPoints(ECPoint[] points)protected voidcheckPoints(ECPoint[] points, int off, int len)protected abstract ECCurvecloneCurve()ECCurve.Configconfigure()protected ECMultipliercreateDefaultMultiplier()ECPointcreatePoint(BigInteger x, BigInteger y)ECPointcreatePoint(BigInteger x, BigInteger y, boolean withCompression)Deprecated.per-point compression property will be removed, usecreatePoint(BigInteger, BigInteger)and referECPoint.getEncoded(boolean)protected abstract ECPointcreateRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression)protected abstract ECPointcreateRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression)ECPointdecodePoint(byte[] encoded)Decode a point on this curve from its ASN.1 encoding.protected abstract ECPointdecompressPoint(int yTilde, BigInteger X1)booleanequals(Object obj)Compares this instance with the specified object and indicates if they are equal.booleanequals(ECCurve other)abstract ECFieldElementfromBigInteger(BigInteger x)ECFieldElementgetA()static int[]getAllCoordinateSystems()ECFieldElementgetB()BigIntegergetCofactor()intgetCoordinateSystem()ECEndomorphismgetEndomorphism()FiniteFieldgetField()abstract intgetFieldSize()abstract ECPointgetInfinity()ECMultipliergetMultiplier()Sets the defaultECMultiplier, unless already set.BigIntegergetOrder()PreCompInfogetPreCompInfo(ECPoint point, String name)inthashCode()Returns an integer hash code for this object.ECPointimportPoint(ECPoint p)voidnormalizeAll(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.voidnormalizeAll(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.voidsetPreCompInfo(ECPoint point, String name, PreCompInfo preCompInfo)AddsPreCompInfofor a point on this curve, under a given name.booleansupportsCoordinateSystem(int coord)ECPointvalidatePoint(BigInteger x, BigInteger y)ECPointvalidatePoint(BigInteger x, BigInteger y, boolean withCompression)Deprecated.per-point compression property will be removed, usevalidatePoint(BigInteger, BigInteger)and referECPoint.getEncoded(boolean)
-
-
-
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 BigInteger order
-
cofactor
protected 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(BigInteger x)
-
configure
public ECCurve.Config configure()
-
validatePoint
public ECPoint validatePoint(BigInteger x, BigInteger y)
-
validatePoint
public ECPoint validatePoint(BigInteger x, BigInteger y, boolean withCompression)
Deprecated.per-point compression property will be removed, usevalidatePoint(BigInteger, BigInteger)and referECPoint.getEncoded(boolean)
-
createPoint
public ECPoint createPoint(BigInteger x, BigInteger y)
-
createPoint
public ECPoint createPoint(BigInteger x, BigInteger y, boolean withCompression)
Deprecated.per-point compression property will be removed, usecreatePoint(BigInteger, BigInteger)and referECPoint.getEncoded(boolean)
-
cloneCurve
protected abstract ECCurve cloneCurve()
-
createRawPoint
protected abstract ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression)
-
createRawPoint
protected abstract ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression)
-
createDefaultMultiplier
protected ECMultiplier createDefaultMultiplier()
-
supportsCoordinateSystem
public boolean supportsCoordinateSystem(int coord)
-
getPreCompInfo
public PreCompInfo getPreCompInfo(ECPoint point, String name)
-
setPreCompInfo
public void setPreCompInfo(ECPoint point, String name, PreCompInfo preCompInfo)
AddsPreCompInfofor a point on this curve, under a given name. Used byECMultipliers to save the precomputation for thisECPointfor use by subsequent multiplication.- Parameters:
point- TheECPointto store precomputations for.name- AStringused to index precomputations of different types.preCompInfo- The values precomputed by theECMultiplier.
-
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 BigInteger getOrder()
-
getCofactor
public BigInteger getCofactor()
-
getCoordinateSystem
public int getCoordinateSystem()
-
decompressPoint
protected abstract ECPoint decompressPoint(int yTilde, BigInteger X1)
-
getEndomorphism
public ECEndomorphism getEndomorphism()
-
getMultiplier
public ECMultiplier getMultiplier()
Sets the defaultECMultiplier, unless already set.
-
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.
-
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(Object obj)
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.The default implementation returns
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
obj- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
-