𝑠𝑝 ← 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.
For context: Switzerland doesn't have evoting. This is just some big company trying to re-sell a evoting system to the government. It has been in the news a few times, due to software and cryptographic quality issues.
I can't really dispute it if that's what you claim that you're doing, but how can that be? Article 2.3 from the file "Political rights of the Swiss abroad", which is available under your link, asserts:
>2.3 E-voting
>The option to vote online in federal votes and elections has been on hold since mid-2019.
>Adjustments are to be made to the pilot scheme by the end of 2020. The aim is to establish a stable scheme, using the latest technology, and create an accurate and transparent end-to-end voting system that also preserves the secrecy of the ballot. Efforts are also being made to raise levels of public confidence in e-voting by extending independent monitoring, ensuring greater transparency with regard to e-voting systems and how they operate, and involving the scientific community more effectively. The necessary conditions for resuming the e-voting trials will be redefined by 2020.
Is the government information out of date? If so, this should be reported.
There is also a bare minimum of manners for polite conversation. I for one prefer when people act politely here. HN is one of the few places online that's normally civil in the comments section.
>Swiss Post has been providing an e-voting system for the cantons since 2016. It has been developing its new system with complete verifiability at its IT site in Neuchâtel since 2020, providing an e-voting system from Switzerland.
In addition, another page on the same website says:
>The cantons of Neuchâtel, Fribourg, Thurgau and Basel-Stadt used Swiss Post’s previous e-voting system until 2019. The following cantons (among others) are planning to use the new Swiss Post system once this becomes legally and technically possible: [list of cantons follows]
>Since the beginning of 2021, Swiss Post’s future e-voting system has been put through its paces by independent experts from all over the world. Another testing opportunity is now available: in addition to the ongoing test options, ethical hackers can now attack the e-voting infrastructure for a period of four weeks. This means that, for the first time, they can accurately simulate and target the vote casting process on the voting portal using sample voting cards. The aim is to detect potential vulnerabilities and rectify them in good time. Swiss Post expects to make its new e-voting system available for use by interested cantons during the course of 2023.
I don't understand why you must be so haughty (vide "Do the bare minimum research before posting please."). Certainly, you are correct for some definition of "Switzerland has an e-voting system" --- there is one under development, and it had been piloted for a limited time period. However, at the moment, it's only in the public testing stage, it's not officially recognized, cannot be used to cast votes, and there is no guarantee that it will get a green light. I think that's the more accepted definition of "to have an e-voting system", in which case the OP was right, and it was you who did not do adequate research.
I would be very weary of changing such constants as this
19 should have been tested by a lookup table, there's no need to apply such heavy test to it
However, by changing that constant (if not properly verified) I'd worry it might change the primality test for some classes of numbers. Where this might be later manipulated to produce a weak key
I think you're misunderstanding the constant: it is only used for small numbers (≤ 23), which are tested with a lookup table, and the constant is itself that lookup table. The test for small numbers is literally just checking a bit, so is not heavy at all.
They intended to do 2^2+2^3+2^5+2^7+2^11+2^13+2^17+2^19+2^23 = 9054380, but they accidentally left out 2^19, and got 2^2+2^3+2^5+2^7+2^11+2^13+2^17+2^23 = 8530092.
Could someone explain why they've used a constant sp instead of hardcoding the primes? How was it created, did someone manually hardcoded the bits then converted into a number?
It is brain dead but this is old code from what I recall. We do not have e-voting at this time although the Post which outsourced this first nightmare of a version is still trying to push for it.
I highly doubt we will see e-voting here until there is a verifiable proof that it is verifiable. There was a lot of bad press about this and people don't trust this crap.
They tried a similar thing for E-ID which was supposed to be built by some private cooperation and run on some centralized servers. The people voted against it and now the government has done the right thing and is building an E-ID system that is decentralized and government run. It still has some quirks but it's going in the right direction.
The sad thing is for the governments first version (outsource to private industry) their claim at the poles was that it would take many years for an E-ID if we don't do it this way. Now only 1 year later we have a very good proposal. There is too much corporate interest pushing around pawns in Government at this time even in a direct democracy like Switzerland.
Well, unfortunately they do plan to relaunch their e-voting system next year, after having "tested their system against more than 60'000 attacks from hackers" (whatever that is supposed to mean)...
Likely none, but nation-states can also manipulate traditional voting with enough effort.
(classic spycraft, blackmailing of key persons, intercept mailvoting, etc.)
Nothing is 100% secure.
So the question is, is it good enough?
They said they took great effort to verificate the voting and detect manipulation. I cannot confirm or verify it, but since it is open, I could. That is a great step forward, compared to the closed black boxes, e-voting systems I have heard of before.
I think this is the specification for the software that would be used for e-voting. There is code in that repository too, and it calls a method named isProbablePrime, but I can't see a definition of it.
I would further improve the code by having it shortcut for all primes smaller than 31 (adding 29 and 31) or 63.