-
Notifications
You must be signed in to change notification settings - Fork 4
CBMC: Add contracts and proofs for various polyvec functions #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
29b7232
to
5c4cfad
Compare
d60ef12
to
0049ad3
Compare
I removed the proofs from here that don't have acceptable run time yet and moved them to #169. |
cdec6c2
to
6050f70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arm Cortex-A72 (Raspberry Pi 4) benchmarks (opt)
Benchmark suite | Current: 6050f70 | Previous: db0c059 | Ratio |
---|---|---|---|
ML-DSA-44 keypair |
305686 cycles |
302258 cycles |
1.01 |
ML-DSA-44 sign |
1054556 cycles |
1038859 cycles |
1.02 |
ML-DSA-44 verify |
328806 cycles |
325882 cycles |
1.01 |
ML-DSA-65 keypair |
560506 cycles |
557736 cycles |
1.00 |
ML-DSA-65 sign |
1549828 cycles |
1517159 cycles |
1.02 |
ML-DSA-65 verify |
537579 cycles |
532945 cycles |
1.01 |
ML-DSA-87 keypair |
863362 cycles |
862513 cycles |
1.00 |
ML-DSA-87 sign |
1986410 cycles |
1962426 cycles |
1.01 |
ML-DSA-87 verify |
894623 cycles |
890895 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arm Cortex-A72 (Raspberry Pi 4) benchmarks (no-opt)
Benchmark suite | Current: 6050f70 | Previous: db0c059 | Ratio |
---|---|---|---|
ML-DSA-44 keypair |
305610 cycles |
302563 cycles |
1.01 |
ML-DSA-44 sign |
949111 cycles |
1038239 cycles |
0.91 |
ML-DSA-44 verify |
329175 cycles |
325625 cycles |
1.01 |
ML-DSA-65 keypair |
560411 cycles |
557708 cycles |
1.00 |
ML-DSA-65 sign |
1543294 cycles |
1521737 cycles |
1.01 |
ML-DSA-65 verify |
536667 cycles |
533310 cycles |
1.01 |
ML-DSA-87 keypair |
865489 cycles |
861766 cycles |
1.00 |
ML-DSA-87 sign |
1994548 cycles |
1959841 cycles |
1.02 |
ML-DSA-87 verify |
897060 cycles |
889017 cycles |
1.01 |
This comment was automatically generated by workflow using github-action-benchmark.
Resolves #116 Signed-off-by: Matthias J. Kannwischer <[email protected]>
Resolves #117 Unrolling resulted in too poor performance. The direct proof works, but it requires to workaround the CBMC limitation described in: #102 diffblue/cbmc#8617 Signed-off-by: Matthias J. Kannwischer <[email protected]>
Resolves #124. Signed-off-by: Matthias J. Kannwischer <[email protected]>
Resolves #126 Signed-off-by: Matthias J. Kannwischer <[email protected]>
Resolves #127 Unrolling resulted in too poor performance. The direct proof works, but it requires to workaround the CBMC limitation described in: #102 diffblue/cbmc#8617 This also moves the correctness post-condition in poly_sub into a assert at the end of the function. This vastly improves performance. Signed-off-by: Matthias J. Kannwischer <[email protected]>
Resolves #136 Signed-off-by: Matthias J. Kannwischer <[email protected]>
Resolves #135 Unrolling resulted in too poor performance. The direct proof works, but it requires to workaround the CBMC limitation described in: #102 diffblue/cbmc#8617 Signed-off-by: Matthias J. Kannwischer <[email protected]>
6050f70
to
5a25f42
Compare
There is a measurable overhead of the whole-struct assignment CBMC workaround of 1-2% I'd say. That shouldn't stop us from proceeding, I think. |
This is ready for review now. Much pain. |
void polyvecl_add(polyvecl *w, const polyvecl *u, const polyvecl *v); | ||
void polyvecl_add(polyvecl *w, const polyvecl *u, const polyvecl *v) | ||
__contract__( | ||
requires(memory_no_alias(w, sizeof(polyvecl))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not going to work, and similar for poly_add
, since the function is being called with aliasing first and second argument -- like in mlkem-native.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poly_add
, polyvecl_add
, and polyveck_add
are always called with first and second argument matching, which violates the current preconditions assuming them to be disjoint. The signature should be changed to the destructive version, as in mlkem-native.
polyvecl_reduce
#116polyvecl_add
#117polyveck_reduce
#124polyveck_add
#126polyveck_sub
#127polyveck_pack_w1
#136polyveck_use_hint
#135polyvecl_add
,polyveck_add
,polyveck_sub
,polyveck_use_hint
,polyveck_reduce
,polyvecl_reduce
were too slow when using unrolling - I instead did a direct proof with the workaround from #92. I added them to #102 to remove the whole-struct assignments once the corresponding CBMC issue is resolved.