Skip to content

Conversation

manastasova
Copy link
Contributor

@manastasova manastasova commented Apr 1, 2025

This PR adds the spec and proof for rej_eta function.

Notes::

  • rej_eta is static, thus, CHECK_FUNCTION_CONTRACTS is defined as rej_eta instead of $(MLD_NAMESPACE)rej_eta in the Makefile.
  • rej_eta is static, thus, additional assumptions, such as requires(len <= MLDSA_N && buflen <= (POLY_UNIFORM_ETA_NBLOCKS * STREAM256_BLOCKBYTES)) are made. This accelerates the performance of CBMC proofs.

Another Note::

Solves #26.

@manastasova manastasova requested a review from a team as a code owner April 1, 2025 23:47
This was referenced Apr 2, 2025
Copy link
Contributor

@hanno-becker hanno-becker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that the computation of t0,t1 itself is unsigned; it's only when you convert to signed prior to 2 - t_i and 4 - t_i that you need an explicit cast, as otherwise that subtraction is computed in unsigned. Marking t0,t1 as signed would not check for underflows in t0 = t0 - (205 * t0 >> 10) * 5; and t1 = t1 - (205 * t1 >> 10) * 5;, which we want CBMC to do.

Copy link
Contributor

@mkannwischer mkannwischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I left two comments in the code. Also, could you please add the description to the commit message as well? The PR descriptions are hard to track down after the PR has been merged. You may just refer to the commit msg in the PR description.

@mkannwischer
Copy link
Contributor

@manastasova, should we add you as contributor to mldsa-native?
Then you have a few more rights in managing the issues, I think. It will also allow you to work in local branches which will be needed as soon as we are running CI on AWS EC2 machines (as that will not work from a fork).

@rod-chapman
Copy link
Contributor

Yes... Please add Mila as a contributor here, and please add her to the Discord channel. Thanks.

@manastasova
Copy link
Contributor Author

@manastasova, should we add you as contributor to mldsa-native? Then you have a few more rights in managing the issues, I think. It will also allow you to work in local branches which will be needed as soon as we are running CI on AWS EC2 machines (as that will not work from a fork).

That would be great! Thanks @mkannwischer!

@mkannwischer
Copy link
Contributor

@manastasova, should we add you as contributor to mldsa-native? Then you have a few more rights in managing the issues, I think. It will also allow you to work in local branches which will be needed as soon as we are running CI on AWS EC2 machines (as that will not work from a fork).

That would be great! Thanks @mkannwischer!

I open this PR to add you as a contributor: pq-code-package/tsc#152
We'll get that merged in the next few days.

The PQCA Discord is open for everyone to join: https://pqca.org/get-involved/
Find us in the mldsa-native-developrs channel.

mkannwischer added a commit to pq-code-package/mlkem-native that referenced this pull request Apr 3, 2025
It was observed in pq-code-package/mldsa-native#86
that
invariant(ctr > 0 ==> array_bound(r, 0, ctr, 0, MLKEM_Q)))
can be simplified to
invariant(array_bound(r, 0, ctr, 0, MLKEM_Q)))
as
invariant(array_bound(r, 0, 0, 0, MLKEM_Q))) is just true.

This commit simplifies the one place in mlkem-native where we had a similar
implicatation.

Signed-off-by: Matthias J. Kannwischer <[email protected]>
Notes::

  - rej_eta is static, thus, CHECK_FUNCTION_CONTRACTS is defined as rej_eta instead of $(MLD_NAMESPACE)rej_eta in the Makefile.
  - rej_eta is static, thus, additional assumptions, such as requires(len <= MLDSA_N && buflen <= (POLY_UNIFORM_ETA_NBLOCKS * STREAM256_BLOCKBYTES)) are made. This accelerates the performance of CBMC proofs.

Signed-off-by: manastasova <[email protected]>
Copy link
Contributor

@mkannwischer mkannwischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @manastasova. LGTM!
I took the liberty to rebase this on top of main.

@mkannwischer mkannwischer merged commit 2b4a9f9 into pq-code-package:main Apr 6, 2025
43 checks passed
manastasova added a commit to manastasova/aws-lc that referenced this pull request Apr 7, 2025
manastasova added a commit to manastasova/aws-lc that referenced this pull request Apr 25, 2025
justsmth pushed a commit to manastasova/aws-lc that referenced this pull request Oct 2, 2025
justsmth pushed a commit to aws/aws-lc that referenced this pull request Oct 2, 2025
Change types `uint32_t t0, t1;` to` int32_t t0, t1;` due to potential
overflow in `if (t0 < 9){a[ctr++] = 4 - t0;}` causing cbmc proofs to
fail.

### Issues:
From pq-code-package/mldsa-native#86.

### Description of changes: 
The output array is of type `int32_t* a`, thus, `uint32_t` aux values
`t0, t1` cause cbmc proofs to fail due to potential overflow.

### Testing:
`./crypto/crypto_test `

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants