Commit 4b66648
committed
Remove unused spec for mld_montgomery_reduce, add bounds reasoning
Context:
We previously had two specifications for mld_montgomery_reduce:
- A 'weak' one where the output upper bound matches the input upper
bound of mld_reduce32().
- A 'strong' one where the output interval is (-Q,Q), exclusively.
Both contracts were combined into one in a somewhat ad-hoc way
(the 'weak' version being encoded as pre- and post-conditions as
usual, the 'strong' version being stated as an implication in the
post-condition).
The combined contract was used in the CBMC proofs of
- mld_poly_pointwise_montgomery
- mld_polyvecl_pointwise_acc_montgomery
There are two more functions which rely on mld_montgomery_reduce,
namely
- mld_fqmul
- mld_fqscale
Observations:
- The 'weak' contract of mld_montgomery_reduce is not needed:
In the context of mld_poly_pointwise_montgomery and
mld_polyvecl_pointwise_acc_montgomery, the strong version applies.
- The 'strong' version also applies in the context of mld_fqmul
and mld_fqscale.
Accordingly, this commit removes the 'weak' version and re-formulates
the 'strong' version in traditional pre/post condition form.
The commit also removes the macro wrapper around the input bound,
which I find difficult to read. It's easier to understand if the
bound is explicit.
The 'strong' version only applies to `mld_fqscale` because of the
recent modification of the iNTT output bound from 3/4*Q to Q. Otherwise,
an even stronger spec would have been needed. At present, one can
even remove mld_fqscale and just call mld_fqmul directly, but this
commit does not do this.
The commit also takes the opportunity to add some pen-and-paper
bounds reasoning for mld_montgomery_reduce.
Fixes #602
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>1 parent b4209ba commit 4b66648
File tree
5 files changed
+44
-33
lines changed- mldsa
- src
- proofs/cbmc
- fqmul
- fqscale
5 files changed
+44
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
378 | | - | |
379 | 377 | | |
380 | 378 | | |
381 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
30 | 38 | | |
31 | | - | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| 60 | + | |
| 61 | + | |
53 | 62 | | |
54 | | - | |
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 24 | | |
31 | 25 | | |
32 | 26 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 27 | + | |
| 28 | + | |
38 | 29 | | |
39 | | - | |
40 | | - | |
| 30 | + | |
| 31 | + | |
41 | 32 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 33 | + | |
| 34 | + | |
46 | 35 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 36 | + | |
| 37 | + | |
50 | 38 | | |
51 | 39 | | |
52 | 40 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
59 | 48 | | |
60 | 49 | | |
61 | 50 | | |
| |||
70 | 59 | | |
71 | 60 | | |
72 | 61 | | |
73 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
74 | 66 | | |
75 | 67 | | |
76 | 68 | | |
77 | 69 | | |
78 | 70 | | |
79 | 71 | | |
80 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
0 commit comments