public class ExponentiationAlgorithms
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static double |
WNAF_INVERSION_COST_THRESHOLD
If number of inversions per group op is at least this, use wNAF instead of the sliding window algorithm.
|
| Constructor and Description |
|---|
ExponentiationAlgorithms() |
| Modifier and Type | Method and Description |
|---|---|
static GroupElementImpl |
binSquareMultiplyExp(GroupElementImpl base,
java.math.BigInteger k)
Calculates the result of applying the group operation k times,
i.e.
|
static int |
getNLeastSignificantBits(long i,
int numberOfLowBits)
Retrieves the given number of least significant bits of
i. |
static GroupElementImpl |
interleavingSlidingWindowMultiExp(Multiexponentiation multiexp,
int windowSize)
Evaluates a multi-exponentiation using the interleaved sliding window algorithm.
|
static GroupElementImpl |
interleavingWnafMultiExp(Multiexponentiation multiexp,
int windowSize)
Evaluates a multi-exponentiation using an interleaved WNAF-bases algorithm.
|
static int[] |
precomputeExponentDigitsForWnaf(java.math.BigInteger exponent,
int windowSize)
Prepares WNAF representation (see master thesis by Swante Scholz) of exponent.
|
static GroupElementImpl |
slidingWindowExp(GroupElementImpl base,
java.math.BigInteger exponent,
SmallExponentPrecomputation precomputation,
int windowSize) |
static GroupElementImpl |
wnafExp(GroupElementImpl base,
java.math.BigInteger exponent,
SmallExponentPrecomputation precomputation,
int windowSize) |
public static final double WNAF_INVERSION_COST_THRESHOLD
public static GroupElementImpl interleavingSlidingWindowMultiExp(Multiexponentiation multiexp, int windowSize)
Powers are computed per basis, instead of for all basis together like for the simultaneous approach. This means that cached powers can be reused in other multi-exponentiations, and, for a large amount of bases, the precomputation is a lot cheaper than in the simultaneous approach. For negative exponents, the base is inverted which does mean the precomputation has to be done anew.
public static GroupElementImpl interleavingWnafMultiExp(Multiexponentiation multiexp, int windowSize)
Useful in groups where inversion is as cheap or cheaper than the group operation itself, such as elliptic curves.
public static GroupElementImpl binSquareMultiplyExp(GroupElementImpl base, java.math.BigInteger k)
For negative exponents k, computes this.inv().pow(-k).
public static GroupElementImpl slidingWindowExp(GroupElementImpl base, java.math.BigInteger exponent, SmallExponentPrecomputation precomputation, int windowSize)
public static GroupElementImpl wnafExp(GroupElementImpl base, java.math.BigInteger exponent, SmallExponentPrecomputation precomputation, int windowSize)
public static int getNLeastSignificantBits(long i,
int numberOfLowBits)
i.
Works for all n < 32.
public static int[] precomputeExponentDigitsForWnaf(java.math.BigInteger exponent,
int windowSize)
exponent - the exponent to compute WNAF representation for.windowSize - the window size to use. This determines width of the WNAF representation.