Class ECAlgorithms
java.lang.Object
org.bouncycastle.math.ec.ECAlgorithms
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ECPointcleanPoint(ECCurve c, ECPoint p) static ECPointimportPoint(ECCurve c, ECPoint p) static booleanstatic booleanisF2mField(FiniteField field) static booleanstatic booleanisFpField(FiniteField field) static voidmontgomeryTrick(ECFieldElement[] zs, int off, int len) static voidmontgomeryTrick(ECFieldElement[] zs, int off, int len, ECFieldElement scale) static ECPointmultiplySecret(ECPoint p, BigInteger k) Multiply a point by a scalar that must not be leaked - a private key, or any value derived from one - without exposing the scalar through control flow or memory-access pattern.static ECPointmultiplySecret(ECPoint p, BigInteger k, BigInteger order) AsmultiplySecret(ECPoint, BigInteger), with the group order supplied rather than taken from the curve.static ECPointSimple shift-and-add multiplication.static ECPointshamirsTrick(ECPoint P, BigInteger k, ECPoint Q, BigInteger l) static ECPointsumOfMultiplies(ECPoint[] ps, BigInteger[] ks) static ECPointsumOfTwoMultiplies(ECPoint P, BigInteger a, ECPoint Q, BigInteger b) static ECPoint
-
Constructor Details
-
ECAlgorithms
public ECAlgorithms()
-
-
Method Details
-
isF2mCurve
-
isF2mField
-
isFpCurve
-
isFpField
-
sumOfMultiplies
-
sumOfTwoMultiplies
-
shamirsTrick
-
importPoint
-
montgomeryTrick
-
montgomeryTrick
-
referenceMultiply
Simple shift-and-add multiplication. Serves as reference implementation to verify (possibly faster) implementations, and for very small scalars. CAUTION: This implementation is NOT constant-time in any way. It is only intended to be used for diagnostics.- Parameters:
p- The point to multiply.k- The multiplier.- Returns:
- The result of the point multiplication
kP.
-
multiplySecret
Multiply a point by a scalar that must not be leaked - a private key, or any value derived from one - without exposing the scalar through control flow or memory-access pattern.ECPoint.multiply(BigInteger)uses the curve's configured multiplier, which for most curves is a windowed-NAF implementation whose timing depends on the scalar; it is the right choice for a public scalar (verification, for instance) but not for a secret one. Use this method wherever the scalar is secret and the point is supplied by a peer.The result is the same point
ECPoint.multiply(BigInteger)would return; only the timing profile differs. SeeECConstantTimeMultiplierfor what is and is not covered.- Parameters:
p- the point to multiply, typically a peer's public key; must lie in the subgroup whose order is the curve's.k- the secret scalar; must be less than the curve order.- Returns:
kP.
-
multiplySecret
AsmultiplySecret(ECPoint, BigInteger), with the group order supplied rather than taken from the curve. Prefer this form wherever the order is to hand - domain parameters always carry it, whereasECCurve.getOrder()is null for a curve built without one.- Parameters:
p- the point to multiply, typically a peer's public key; must lie in the subgroup of orderorder.k- the secret scalar; must be less thanorder.order- the group order; must be odd, as every standard EC group order is.- Returns:
kP.
-
validatePoint
-
cleanPoint
-