TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Swiss evoting system – IsProbablePrime is incorrect for input 19

36 pointsby herr_gurkeover 2 years ago

7 comments

Someoneover 2 years ago
Relevant code (from <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;swisspost-evoting&#x2F;crypto-primitives&#x2F;crypto-primitives&#x2F;-&#x2F;raw&#x2F;master&#x2F;Crypto-Primitives-Specification.pdf" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;swisspost-evoting&#x2F;crypto-primitives&#x2F;crypt...</a>):<p><pre><code> 𝑠𝑝 ← 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, 𝑛 &gt; 2 thus composite end if </code></pre> 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.<p>I would further improve the code by having it shortcut for all primes smaller than 31 (adding 29 and 31) or 63.
评论 #33200800 未加载
评论 #33201025 未加载
nairboonover 2 years ago
For context: Switzerland doesn&#x27;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.
评论 #33200988 未加载
评论 #33200913 未加载
评论 #33201024 未加载
评论 #33200949 未加载
评论 #33200861 未加载
评论 #33200962 未加载
trompover 2 years ago
&gt; since 19 is a prime number, if I am not mistaken.<p>That is one modest reviewer!
评论 #33200924 未加载
raverbashingover 2 years ago
I would be very weary of changing such constants as this<p>19 should have been tested by a lookup table, there&#x27;s no need to apply such heavy test to it<p>However, by changing that constant (if not properly verified) I&#x27;d worry it might change the primality test for some classes of numbers. Where this might be later manipulated to produce a weak key
评论 #33201540 未加载
omega3over 2 years ago
Could someone explain why they&#x27;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?
gsk22over 2 years ago
Can someone explain how such a simple and easily-testable bug existed in a seemingly-important system like this?<p>I don&#x27;t know much about Swiss e-voting, but seems even the most brain-dead unit test of the IsProbablePrime function should have caught this.
评论 #33200761 未加载
评论 #33200734 未加载
评论 #33200811 未加载
评论 #33200744 未加载
ameliusover 2 years ago
Perhaps the word &quot;probable&quot; has something to do with it?