|
|
|
|
|
by Someone
1339 days ago
|
|
Relevant code (from https://gitlab.com/swisspost-evoting/crypto-primitives/crypt...): ๐ ๐ โ 8530092
โท I.e. 0b100000100010100010101100: for all primes ๐ โค 23,
TestBit(๐ ๐, ๐) = true
if ๐ โค 23 then
โท Quick check for small values, simpler and faster
than testing equality on each option
return TestBit(๐ ๐, ๐)
end if
if ยฌTestBit(๐, 0) then return โฅ
โท I.e. ๐ is even and, as per line 2, ๐ > 2 thus composite
end if
And it indeed is a bug. The function guarantees to return false โif the number can be determined to be compositeโ and true for all primes, so it should err in only one way.I would further improve the code by having it shortcut for all primes smaller than 31 (adding 29 and 31) or 63. |
|
This is step 1 of the algorithm they're using: https://en.wikipedia.org/wiki/Baillie%E2%80%93PSW_primality_...