Open OlivierBBB opened 4 days ago
Here are two 256 bits "0-1-balanced" primes:
0xF076B857FA9947C1F9EC558262C72704099CA8CD325566F73FB99238102ED171
0xC809C9170CA6FAEC82D43EE6754DBAD01D198ECAE0823BAC23CA30C7F0C9657D
Code snippet from ShfExtensiveTest.java
whose logic can be extracted, turned into a support method and re-used:
for (String XY : XYs) {
String mask = XY + "00".repeat(31);
String maskXorValue =
String.format("%064X", new BigInteger(mask, 16).xor(new BigInteger(value, 16)));
shfWithMaskTestSourceList.add(Arguments.of(maskXorValue, k, l, XY));
}
As part of the work to produce "exhaustive" tests for the simpler modules (
SHF
,EXP
,MUL
,MOD
, ...) and given the fact that theMUL
module is blowing up on certain reference tests, with the EXP instruction (e.g.BlockchainReferenceTest_10
), it makes sense to expand our test coverage.The major difficulty will be that dealing with EXP can use up to
4096 = 256 * ( 8 + 8 )
rows (each multiplication is 8 rows and every bit of the exponent is responsible for 1 or 2 multiplication in the square and multiply algorithm that the module implements. So the batching strategy for the tests is an open question. These tests will likely be very long time wise but won't have to be run regularly, only when we modify the MUL module.Generalities
There are 3 regimes for EXP instructions:
OLI
: whenever exponent or base is $\in \{0, 1\}$TRIVIAL_EXP_REGIME
: whenever the result ofB^E mod 2^256
is predicted to be zero (and the instruction isn't a OLI)NONTRIVIAL_EXP_REGIME
: whenever the result ofB^E mod 2^256
is predicted to be nonzero (and the instruction isn't aOLI
)Test values
Test vectors
We should exhaustively test the following pairings:
even_base
&special_exponents
: these are short (or even very short)simple_odd_base
&special_exponents
: longsimple_odd_base
&complex_exponents
: very longother_odd_base
&complex_exponents
: very, very long