public class ECConstantTimeMultiplierTest
extends junit.framework.TestCase
ECConstantTimeMultiplier.
The multiplier exists to remove a timing side channel, not to compute anything new, so its
output must agree exactly with the existing multipliers for every scalar. That is what is
checked here, against ECAlgorithms.referenceMultiply(org.bouncycastle.math.ec.ECPoint, java.math.BigInteger) (plain double-and-add) and against
whatever multiplier the curve is configured with, across every named curve - which covers the
Fp custom curves, the generic Fp curves, the binary (F2m) curves, and the GLV curve secp256k1
whose endomorphism this multiplier deliberately bypasses.
The scalars are not only random: the recoding forces the scalar odd, splits it into fixed-width signed odd digits and relies on no digit being zero and on the accumulator never colliding with a table entry, so the boundary values below (1, 2, order-1, powers of two, values either side of a window boundary) are the cases most likely to break those assumptions.
| Constructor and Description |
|---|
ECConstantTimeMultiplierTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
testAgainstReferenceOnAllNamedCurves() |
void |
testBasePoint()
The base point is a legitimate input too, even though the fixed-base comb would normally be
used for it - a caller cannot be assumed to know which point it holds.
|
void |
testOutOfSubgroupPointSemantics()
The subgroup precondition, pinned: the odd-forcing step computes (k + n)P in place of an
even kP, which is the same point exactly when the order of P divides n.
|
void |
testRejectsEvenOrder() |
void |
testRejectsScalarLargerThanOrder() |
void |
testSignAndInfinityHandling() |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toStringpublic void testAgainstReferenceOnAllNamedCurves()
public void testBasePoint()
public void testSignAndInfinityHandling()
public void testOutOfSubgroupPointSemantics()
public void testRejectsEvenOrder()
public void testRejectsScalarLargerThanOrder()