-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add coeff_signed_to_unsigned() functions and its proof #67
Add coeff_signed_to_unsigned() functions and its proof #67
Conversation
Hi @rod-chapman , If you have |
I am running NIX locally and it works well. The proof of coeff_signed_to_unsigned() works perfectly locally, but fails everying in the GitHub runner, but I can't work out why... |
If the upstream version is newer, maybe you need to update the new hash here: https://github.com/pq-code-package/mlkem-c-aarch64/blob/main/flake.nix#L31 |
36ef186
to
7c32023
Compare
Hi, @rod-chapman I came across this, and I observed the same issue as you. I figure it might be helpful to upload some logs and artifacts to make troubleshooting the inconsistent results between local and CI environments easier, or just produce more logs vis the python script in CI. I can do this, but I will need guidance on which files to upload to help resolve this kind of issue. By the way, here are the errors that I extracted from the artifact I uploaded to my fork.
|
OK... thanks for that data. If I run "make" locally (within a NIX shell), then look in the logs/result.xml file, I see things like:
which shows the same proofs succeeding. Still no idea why they are failing in CI... :-( |
I ran this locally on my x86 machine as well as on a M1 MacMini. Most obvious thing that is not controlled by nix on Mac is the compiler version, as we are using the native clang on Mac. Could it maybe be related to your issue? I'm more guessing than anything here. I have this clang version on the Mac:
Can send more outputs if needed. |
That's interesteing. I have Apple M1 Pro running macOS 13.6.7 with
and the proof of coeff_signed_to_unsigned() works every time, using both a native shell and running NIX. I also tried again using a native build of gcc 13.1.0 on PATH before /usr/bin and that also works both with and without NIX. Using Apple's clang 15 on PATH in /usr/bin/gcc, I just ran
(using CBMC 6.0.0) and I got the attached file. |
Darn... different in comments only. So... what else could be different? |
I have an Intel-based Mac here running Sonoma 14.5 with same clang version as you report above.
|
I feel very stupid. For the "--smt2" option to work, you need "z3" on PATH, or it just silently says "ERROR". Can we add z3 to the NIX config? |
Yes, that should be easy. I can look into this. |
Thanks. I have already raised diffblue/cbmc#8362 |
Z3 4.13.0 appears to be "latest". Can we settle on that for all our development platforms? |
I can't push to this branch, but if you apply the following patch, it should install 4.8.17
Can we try that first or do we need a specific version? |
Btw, I confirmed that this solves the issue on my Mac. |
Let's go for a latest version that pre-packaged in NIX, so 4.12.5 then... |
Confirmed... adding "z3_4_12" in flake.nix gets me Z3 4.12.5. I will try to open a PR to add that. |
3d72c15
to
8c2666a
Compare
I've rebased this on top of main after #85 was merged adding the required z3 dependency. @rod-chapman, apologies for guessing wrongly. Is this PR now ready to be reviewed/merged? |
If the CI runners are all good now, then yes - please review. |
I just need to back out the debugging changes... hang on... |
OK... debugging options removed... |
Looks good. Please review. |
cbmc/proofs/coeff_signed_to_unsigned/coeff_signed_to_unsigned_harness.c
Outdated
Show resolved
Hide resolved
I have one minor comments. Other than that, the PR LGTM. |
Good to merge? |
Yep. I think it's good to merge. |
I'll review tomorrow morning. |
0549f84
to
033ebac
Compare
@rod-chapman We should strive for a clean history before merging PRs; that is, squash fixup commits into the commits they apply to, remove any test-commits that are later undone, etc. Since your PR has been waiting for so long, I took the liberty to do this myself, but generally it should be the PR author. I have also renamed |
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.
After further consultation with @mkannwischer, we don't think it's acceptable even temporarily to introduce the unprotected r < 0
expression. We should instead use / introduce a suitable primitive from verify.c
. For example, we could use cmov_int16(&r, r + KYBER_Q, r < 0)
.
Noted and understood. I will update my branch and take a look at verify.c |
Signed-off-by: Rod Chapman <[email protected]>
Also, uniformize file structure of proof subdirctory for scalar_signed_to_unsigned_q_16 with those of other functions. Signed-off-by: Hanno Becker <[email protected]>
scalar_signed_to_unsigned_q_16() uses the expression `(r < 0)` for the extraction of the sign-bit, which is prone to compilers turning them into a branch. Signed-off-by: Hanno Becker <[email protected]>
Signed-off-by: Rod Chapman <[email protected]>
Signed-off-by: Rod Chapman <[email protected]>
Signed-off-by: Rod Chapman <[email protected]>
9bb9280
to
50255da
Compare
This PR adds only the coeff_signed_to_unsigned() function in poly.c and its proof.
This was previously added in support of the proof of poly_compress(), but that proof is blocked pending CBMC bug fixes.
This PR adds coeff_signed_to_unsigned() in isolation so that proofs of other functions may proceed, such as poly_tobytes()
To run proofs, cd to "cbmc/proofs/coeff_signed_to_unsigned", then either
or