public class PolynomialModTest
extends junit.framework.TestCase
Polynomial.mod3(short), Polynomial.mod3(byte) and
Polynomial.modQ(int, int) used to be written with the % operator, which
compiles to an integer division whose latency depends on its operands - and all three run on
secret data (the secret key polynomials f and g, the message polynomials r and m, and the
coefficients recovered during decapsulation). They are now division-free, matching the
reference implementation, and these tests pin them to the values % produced across the
entire input domain that reaches them.
This test has to live in org.bouncycastle.pqc.math.ntru rather than the
...ntru.test package alongside PolynomialTest,
because the methods are package-private.
| Constructor and Description |
|---|
PolynomialModTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
testMod3ByteOverEveryInput() |
void |
testMod3IsAlwaysTernary()
The callers treat the result as a ternary coefficient, so nothing may escape 0..2 - the
masked conditional subtraction has to leave the folded value fully reduced.
|
void |
testMod3ShortOverEveryInput() |
void |
testModQIsInRange() |
void |
testModQOverEveryInputAndParameterSet()
Every call site passes a dividend already masked to 16 bits, so that is the domain that
has to agree with
%; q is a power of two for every parameter set. |
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 testMod3ShortOverEveryInput()
public void testMod3ByteOverEveryInput()
public void testMod3IsAlwaysTernary()
public void testModQOverEveryInputAndParameterSet()
%; q is a power of two for every parameter set.public void testModQIsInRange()