Package org.bouncycastle.math.ec
Class ECPoint
- java.lang.Object
-
- org.bouncycastle.math.ec.ECPoint
-
- Direct Known Subclasses:
ECPoint.AbstractF2m,ECPoint.AbstractFp
public abstract class ECPoint extends Object
base class for points on elliptic curves.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classECPoint.AbstractF2mstatic classECPoint.AbstractFpstatic classECPoint.F2mElliptic curve points over F2mstatic classECPoint.FpElliptic curve points over Fp
-
Field Summary
Fields Modifier and Type Field Description protected ECCurvecurveprotected static ECFieldElement[]EMPTY_ZSprotected HashtablepreCompTableprotected booleanwithCompressionprotected ECFieldElementxprotected ECFieldElementyprotected ECFieldElement[]zs
-
Constructor Summary
Constructors Modifier Constructor Description protectedECPoint(ECCurve curve, ECFieldElement x, ECFieldElement y)protectedECPoint(ECCurve curve, ECFieldElement x, ECFieldElement y, ECFieldElement[] zs)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract ECPointadd(ECPoint b)protected voidcheckNormalized()protected ECPointcreateScaledPoint(ECFieldElement sx, ECFieldElement sy)protected abstract ECPointdetach()booleanequals(Object other)Compares this instance with the specified object and indicates if they are equal.booleanequals(ECPoint other)ECFieldElementgetAffineXCoord()Returns the affine x-coordinate after checking that this point is normalized.ECFieldElementgetAffineYCoord()Returns the affine y-coordinate after checking that this point is normalizedprotected abstract booleangetCompressionYTilde()ECCurvegetCurve()protected intgetCurveCoordinateSystem()ECPointgetDetachedPoint()byte[]getEncoded()Deprecated.per-point compression property will be removed, refergetEncoded(boolean)byte[]getEncoded(boolean compressed)Get an encoding of the point value, optionally in compressed format.protected static ECFieldElement[]getInitialZCoords(ECCurve curve)protected ECFieldElementgetRawXCoord()protected ECFieldElementgetRawYCoord()protected ECFieldElement[]getRawZCoords()ECFieldElementgetX()Deprecated.Use getAffineXCoord(), or normalize() and getXCoord(), insteadECFieldElementgetXCoord()Returns the x-coordinate.ECFieldElementgetY()Deprecated.Use getAffineYCoord(), or normalize() and getYCoord(), insteadECFieldElementgetYCoord()Returns the y-coordinate.ECFieldElementgetZCoord(int index)ECFieldElement[]getZCoords()inthashCode()Returns an integer hash code for this object.booleanisCompressed()Deprecated.per-point compression property will be removed, refergetEncoded(boolean)booleanisInfinity()booleanisNormalized()booleanisValid()ECPointmultiply(BigInteger k)Multiplies thisECPointby the given number.abstract ECPointnegate()ECPointnormalize()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.protected booleansatisfiesCofactor()protected abstract booleansatisfiesCurveEquation()ECPointscaleX(ECFieldElement scale)ECPointscaleY(ECFieldElement scale)abstract ECPointsubtract(ECPoint b)ECPointthreeTimes()ECPointtimesPow2(int e)StringtoString()Returns a string containing a concise, human-readable description of this object.abstract ECPointtwice()ECPointtwicePlus(ECPoint b)
-
-
-
Field Detail
-
EMPTY_ZS
protected static ECFieldElement[] EMPTY_ZS
-
curve
protected ECCurve curve
-
x
protected ECFieldElement x
-
y
protected ECFieldElement y
-
zs
protected ECFieldElement[] zs
-
withCompression
protected boolean withCompression
-
preCompTable
protected Hashtable preCompTable
-
-
Constructor Detail
-
ECPoint
protected ECPoint(ECCurve curve, ECFieldElement x, ECFieldElement y)
-
ECPoint
protected ECPoint(ECCurve curve, ECFieldElement x, ECFieldElement y, ECFieldElement[] zs)
-
-
Method Detail
-
getInitialZCoords
protected static ECFieldElement[] getInitialZCoords(ECCurve curve)
-
satisfiesCofactor
protected boolean satisfiesCofactor()
-
satisfiesCurveEquation
protected abstract boolean satisfiesCurveEquation()
-
getDetachedPoint
public final ECPoint getDetachedPoint()
-
getCurve
public ECCurve getCurve()
-
detach
protected abstract ECPoint detach()
-
getCurveCoordinateSystem
protected int getCurveCoordinateSystem()
-
getX
public ECFieldElement getX()
Deprecated.Use getAffineXCoord(), or normalize() and getXCoord(), insteadNormalizes this point, and then returns the affine x-coordinate. Note: normalization can be expensive, this method is deprecated in favour of caller-controlled normalization.
-
getY
public ECFieldElement getY()
Deprecated.Use getAffineYCoord(), or normalize() and getYCoord(), insteadNormalizes this point, and then returns the affine y-coordinate. Note: normalization can be expensive, this method is deprecated in favour of caller-controlled normalization.
-
getAffineXCoord
public ECFieldElement getAffineXCoord()
Returns the affine x-coordinate after checking that this point is normalized.- Returns:
- The affine x-coordinate of this point
- Throws:
IllegalStateException- if the point is not normalized
-
getAffineYCoord
public ECFieldElement getAffineYCoord()
Returns the affine y-coordinate after checking that this point is normalized- Returns:
- The affine y-coordinate of this point
- Throws:
IllegalStateException- if the point is not normalized
-
getXCoord
public ECFieldElement getXCoord()
Returns the x-coordinate. Caution: depending on the curve's coordinate system, this may not be the same value as in an affine coordinate system; use normalize() to get a point where the coordinates have their affine values, or use getAffineXCoord() if you expect the point to already have been normalized.- Returns:
- the x-coordinate of this point
-
getYCoord
public ECFieldElement getYCoord()
Returns the y-coordinate. Caution: depending on the curve's coordinate system, this may not be the same value as in an affine coordinate system; use normalize() to get a point where the coordinates have their affine values, or use getAffineYCoord() if you expect the point to already have been normalized.- Returns:
- the y-coordinate of this point
-
getZCoord
public ECFieldElement getZCoord(int index)
-
getZCoords
public ECFieldElement[] getZCoords()
-
getRawXCoord
protected final ECFieldElement getRawXCoord()
-
getRawYCoord
protected final ECFieldElement getRawYCoord()
-
getRawZCoords
protected final ECFieldElement[] getRawZCoords()
-
checkNormalized
protected void checkNormalized()
-
isNormalized
public boolean isNormalized()
-
normalize
public ECPoint normalize()
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.- Returns:
- a new ECPoint instance representing the same point, but with normalized coordinates
-
createScaledPoint
protected ECPoint createScaledPoint(ECFieldElement sx, ECFieldElement sy)
-
isInfinity
public boolean isInfinity()
-
isCompressed
public boolean isCompressed()
Deprecated.per-point compression property will be removed, refergetEncoded(boolean)
-
isValid
public boolean isValid()
-
scaleX
public ECPoint scaleX(ECFieldElement scale)
-
scaleY
public ECPoint scaleY(ECFieldElement scale)
-
equals
public boolean equals(ECPoint other)
-
equals
public boolean equals(Object other)
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:
other- 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)
-
toString
public String toString()
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod.
-
getEncoded
public byte[] getEncoded()
Deprecated.per-point compression property will be removed, refergetEncoded(boolean)
-
getEncoded
public byte[] getEncoded(boolean compressed)
Get an encoding of the point value, optionally in compressed format.- Parameters:
compressed- whether to generate a compressed point encoding.- Returns:
- the point encoding
-
getCompressionYTilde
protected abstract boolean getCompressionYTilde()
-
negate
public abstract ECPoint negate()
-
timesPow2
public ECPoint timesPow2(int e)
-
twice
public abstract ECPoint twice()
-
threeTimes
public ECPoint threeTimes()
-
multiply
public ECPoint multiply(BigInteger k)
Multiplies thisECPointby the given number.- Parameters:
k- The multiplicator.- Returns:
k * this.
-
-