LessThanOrEquals needs a sanity check on bitlength?
Closed this issue · 1 comments
rubensayshi commented
It seems like there's some magical threshold for the bitlength of the numeric context and the bitlength of the modulus at which LessThanOrEquals
breaks.
I thought that the bitlength of the modulus would have to be >= 2x bitlength of the numeric context, but it doesn't seem that way, at higher sizes the bitlength can be much bigger than 1/2 the modulus and at lower sizes the bitlength needs to be much smaller than 1/2 the modulus...
There's probably a logical reason / relation and it might be good to have a sanity check there.
these 2 tests both fail (while 453 / 512 for example works fine);
@Test
public void test_compareLt_Sequential454_512() {
TestParameters tp = new TestParameters()
.field(new MersennePrimeFieldDefinition(512, 569))
.maxBitLength(454);
runTest(new CompareTests.TestCompareLT<>(), tp);
}
@Test
public void test_compareLt_Sequential32_64() {
TestParameters tp = new TestParameters()
.field(new MersennePrimeFieldDefinition(64, 569))
.maxBitLength(32);
runTest(new CompareTests.TestCompareLT<>(), tp);
}
rubensayshi commented
another odd thing;
if you do compareLEQ(0, 2 ^ maxBitLength)
then the result is 2