Commit c160cd9
Add clarrifying comment to poly_chknorm
It is a little unintuitive why in poly_chknorm it suffices to check that
the coefficients of absolute value less than B even though the inputs are NOT
canonically reduced.
The answer is:
* Specification: The definition of the infinity norm in FIPS-204 requires
* signed canonical reduction prior to applying the bounds check.
* However, `-B < (a mod± MLDSA_Q) < B` is equivalent to
* `-B < a < B` under the assumption that
* `B <= MLDSA_Q - REDUCE32_RANGE_MAX` (cf. the assertion in
* the code). Hence, the present spec and implementation are
* correct without reduction.
Before we were using B <= (MLDSA_Q - 1) / 8) (as it is checked in the
reference implementation), but the more natural bound is the slightly
larger MLDSA_Q - REDUCE32_RANGE_MAX.
This commits changes the pre-condition, adds a comment to poly_chknorm, and
also adds an assertion for what I said above. CBMC proves this just fine.
Resolves #504
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>1 parent d92af65 commit c160cd9
3 files changed
+27
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
268 | | - | |
| 267 | + | |
| 268 | + | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
323 | 325 | | |
324 | 326 | | |
325 | 327 | | |
| |||
341 | 343 | | |
342 | 344 | | |
343 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
344 | 357 | | |
345 | 358 | | |
346 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
311 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
312 | 321 | | |
313 | 322 | | |
314 | 323 | | |
315 | 324 | | |
316 | 325 | | |
317 | | - | |
| 326 | + | |
318 | 327 | | |
319 | 328 | | |
320 | 329 | | |
| |||
0 commit comments