Skip to content
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

ML-KEM: Improve compression and byte conversion functions #161

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

marsella
Copy link
Contributor

Closes #144 (assuming that #160 has already been merged).

This has two parts:

  • Cleans up the compression functions. These were correct and nicely written, I just changed names and docs.
  • Attempts to clean up bits-to-bytes conversion functions.

For the second part, I am honestly kind of confused. I thought the endianness was wrong but I tried rewriting it multiple times to make it look more like the spec and it seems correct. The KATs pass and all the internal properties pass. If anyone discerns something weird I'm doing with bit ordering I would love feedback.

| ell == 0 => []
| ell > 0 => join [[ b8ij where
// Step 4. Taking the last bit is the same as modding by 2.
b8ij = Ci' ! 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: I intend to refer this to the mod2IsFinalBit property I added in #160.

Copy link
Contributor

@mccleeary-galois mccleeary-galois left a comment

Choose a reason for hiding this comment

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

Caught this on this PR, but the ML-KEM proofs currently require z3 v4.13+. This is what is installed by default with brew install cryptol but it is not what we ship with what4 solvers as that is v4.8.14. Adding a ticket to ensure we do :check-docstring against multiple z3 versions. We should also consider adding support to be able to set z3 version.

@mccleeary-galois
Copy link
Contributor

Caught this on this PR, but the ML-KEM proofs currently require z3 v4.13+. This is what is installed by default with brew install cryptol but it is not what we ship with what4 solvers as that is v4.8.14. Adding a ticket to ensure we do :check-docstring against multiple z3 versions. We should also consider adding support to be able to set z3 version.

Going to cut some tickets for CI related tasks from this and also try and figure out which properties are actually causing the problem.

@mccleeary-galois
Copy link
Contributor

For the second part, I am honestly kind of confused. I thought the endianness was wrong but I tried rewriting it multiple times to make it look more like the spec and it seems correct. The KATs pass and all the internal properties pass. If anyone discerns something weird I'm doing with bit ordering I would love feedback.

Looking at the spec I agree that this is not super clear on endianness here. I am happy with how this looks right now.

Copy link
Contributor

@mccleeary-galois mccleeary-galois left a comment

Choose a reason for hiding this comment

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

LGTM, opened up a separate issue #166 for the issue uncovered during review of this.

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.

Bring encoding and compression functions in ML-KEM up to gold standard
2 participants