Class ECAlgorithms


  • public class ECAlgorithms
    extends java.lang.Object
    • Constructor Detail

      • ECAlgorithms

        public ECAlgorithms()
    • Method Detail

      • isF2mCurve

        public static boolean isF2mCurve​(ECCurve c)
      • isF2mField

        public static boolean isF2mField​(FiniteField field)
      • isFpCurve

        public static boolean isFpCurve​(ECCurve c)
      • isFpField

        public static boolean isFpField​(FiniteField field)
      • sumOfMultiplies

        public static ECPoint sumOfMultiplies​(ECPoint[] ps,
                                              java.math.BigInteger[] ks)
      • sumOfTwoMultiplies

        public static ECPoint sumOfTwoMultiplies​(ECPoint P,
                                                 java.math.BigInteger a,
                                                 ECPoint Q,
                                                 java.math.BigInteger b)
      • sumOfTwoMultipliesSecret

        public static ECPoint sumOfTwoMultipliesSecret​(ECPoint P,
                                                       java.math.BigInteger a,
                                                       ECPoint Q,
                                                       java.math.BigInteger b)
      • sumOfTwoMultipliesSecret

        public static ECPoint sumOfTwoMultipliesSecret​(ECPoint P,
                                                       java.math.BigInteger a,
                                                       ECPoint Q,
                                                       java.math.BigInteger b,
                                                       java.math.BigInteger order)
      • shamirsTrick

        public static ECPoint shamirsTrick​(ECPoint P,
                                           java.math.BigInteger k,
                                           ECPoint Q,
                                           java.math.BigInteger l)
      • montgomeryTrick

        public static void montgomeryTrick​(ECFieldElement[] zs,
                                           int off,
                                           int len)
      • referenceMultiply

        public static ECPoint referenceMultiply​(ECPoint p,
                                                java.math.BigInteger k)
        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.
      • multiply

        public static ECPoint multiply​(ECPoint p,
                                       java.math.BigInteger k)
      • multiplySecret

        public static ECPoint multiplySecret​(ECPoint p,
                                             java.math.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.

        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. See ECConstantTimeMultiplier for 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

        public static ECPoint multiplySecret​(ECPoint p,
                                             java.math.BigInteger k,
                                             java.math.BigInteger order)
        As multiplySecret(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, whereas ECCurve.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 order order.
        k - the secret scalar; must be less than order.
        order - the group order; must be odd, as every standard EC group order is.
        Returns:
        kP.