public class GFTest
extends junit.framework.TestCase
GF used to be implemented with log/exp/inv/sqr lookup tables indexed by field
elements, which leaked secret-derived values through the cache; it is now table-free and
branch-free. These tests pin the arithmetic to the values the tables produced, so a future
change cannot alter a result while the HQC known-answer tests happen to keep passing on the
subset of inputs they exercise.
The expected values come from an independent construction: log and exp tables built here by iterating the generator X over GF(2)[X]/(X^8 + X^4 + X^3 + X^2 + 1), so the oracle takes a different computational route (discrete logs) from the implementation (carryless multiply and reduce). Field laws are checked as well, in case both sides were to be wrong the same way.
| Constructor and Description |
|---|
GFTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
setUp() |
void |
testDivAgainstOracle() |
void |
testFieldLaws() |
void |
testInvAgainstOracle() |
void |
testMul3AgainstOracle()
mul3 is exercised on a stride rather than all 16777216 triples, to keep the legacy Ant
builds (which run this on a real JRE 1.3/1.4) quick; mul itself is covered exhaustively
above and mul3 is defined in terms of it.
|
void |
testMulAgainstOracle() |
void |
testOracleIsTheExpectedField()
Guard the oracle itself: these are the opening entries of the classic GF(256) exp table
for this field polynomial, and the cycle must close back on 1.
|
void |
testSqrAgainstOracle() |
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, tearDown, toStringpublic void setUp()
setUp in class junit.framework.TestCasepublic void testOracleIsTheExpectedField()
public void testMulAgainstOracle()
public void testSqrAgainstOracle()
public void testInvAgainstOracle()
public void testDivAgainstOracle()
public void testMul3AgainstOracle()
public void testFieldLaws()