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 java.lang.Objectbase 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 java.util.HashtablepreCompTableprotected 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 Modifier and Type Method Description abstract ECPointadd(ECPoint b)protected voidcheckNormalized()protected ECPointcreateScaledPoint(ECFieldElement sx, ECFieldElement sy)protected abstract ECPointdetach()voidencodeTo(boolean compressed, byte[] buf, int off)booleanequals(java.lang.Object other)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(boolean compressed)Get an encoding of the point value, optionally in compressed format.intgetEncodedLength(boolean compressed)protected static ECFieldElement[]getInitialZCoords(ECCurve curve)ECFieldElementgetRawXCoord()ECFieldElementgetRawYCoord()protected ECFieldElement[]getRawZCoords()ECFieldElementgetXCoord()Returns the x-coordinate.ECFieldElementgetYCoord()Returns the y-coordinate.ECFieldElementgetZCoord(int index)ECFieldElement[]getZCoords()inthashCode()booleanisInfinity()booleanisNormalized()booleanisValid()ECPointmultiply(java.math.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 abstract booleansatisfiesCurveEquation()protected booleansatisfiesOrder()ECPointscaleX(ECFieldElement scale)ECPointscaleXNegateY(ECFieldElement scale)ECPointscaleY(ECFieldElement scale)ECPointscaleYNegateX(ECFieldElement scale)abstract ECPointsubtract(ECPoint b)ECPointthreeTimes()ECPointtimesPow2(int e)java.lang.StringtoString()abstract ECPointtwice()ECPointtwicePlus(ECPoint b)
-
-
-
Field Detail
-
EMPTY_ZS
protected static final ECFieldElement[] EMPTY_ZS
-
curve
protected ECCurve curve
-
x
protected ECFieldElement x
-
y
protected ECFieldElement y
-
zs
protected ECFieldElement[] zs
-
preCompTable
protected java.util.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)
-
satisfiesCurveEquation
protected abstract boolean satisfiesCurveEquation()
-
satisfiesOrder
protected boolean satisfiesOrder()
-
getDetachedPoint
public final ECPoint getDetachedPoint()
-
getCurve
public ECCurve getCurve()
-
detach
protected abstract ECPoint detach()
-
getCurveCoordinateSystem
protected int getCurveCoordinateSystem()
-
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:
java.lang.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:
java.lang.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
public final ECFieldElement getRawXCoord()
-
getRawYCoord
public 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()
-
isValid
public boolean isValid()
-
scaleX
public ECPoint scaleX(ECFieldElement scale)
-
scaleXNegateY
public ECPoint scaleXNegateY(ECFieldElement scale)
-
scaleY
public ECPoint scaleY(ECFieldElement scale)
-
scaleYNegateX
public ECPoint scaleYNegateX(ECFieldElement scale)
-
equals
public boolean equals(ECPoint other)
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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
-
getEncodedLength
public int getEncodedLength(boolean compressed)
-
encodeTo
public void encodeTo(boolean compressed, byte[] buf, int off)
-
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(java.math.BigInteger k)
Multiplies thisECPointby the given number.- Parameters:
k- The multiplicator.- Returns:
k * this.
-
-