Skip to content

Regarding compressions #920

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

Open
5 of 12 tasks
vincentvbh opened this issue Mar 29, 2025 · 8 comments
Open
5 of 12 tasks

Regarding compressions #920

vincentvbh opened this issue Mar 29, 2025 · 8 comments
Labels
enhancement New feature or request

Comments

@vincentvbh
Copy link

vincentvbh commented Mar 29, 2025

Platform:
Which platform does this concern?

  • platform independent
  • aarch64
  • x86_64
  • rv64
  • other

Issue category:

Which part(s) of mlkem-native does this issue concern:

  • core crypto: ML-KEM
  • core crypto: FIPS202
  • documentation
  • integration
  • CBMC
  • CI
  • Testing

I notice that currently the compression functions are updated. The Barrett-based compressions were already released here https://github.com/vincentvbh/Compressions. You can find various implementations for each of them, including Armv7-M, Armv7E-M, Armv8-A Neon, and AVX2. Some of the implementations are also formally verified and the paper will be out soon.

The optimization relies on the following:

  • Work on the signed integer instead of unsigned ones.
  • Sharpening the precision of Barrett-based compressions with brute-force testing.

The resulting computations are formally verified and remove the need to convert elements from signed integers to unsigned.
Additional details will be public once the paper is published, and detailed explanations of the implementations are included in my thesis that I'm currently working.

Vincent Hwang

@vincentvbh vincentvbh added the enhancement New feature or request label Mar 29, 2025
@vincentvbh
Copy link
Author

Oops! The Armv7-M implementations are only in a private repo and not in the repo mentioned earlier. Anyway, the Armv7-M implementations are just the straightforward assembly of the C versions.

@vincentvbh
Copy link
Author

See earlier PR here pq-crystals/kyber#83.

@hanno-becker
Copy link
Contributor

hanno-becker commented Mar 29, 2025

@vincentvbh Thanks for bringing this to our attention! I can't say we would / would not want this off hand, but a good base for discussions would be a draft PR exemplifying your approach by adjusting some of the C compression routines. We'd also need to confirm that CBMC can still prove correctness of your code, please have a try (for 16-bit arithmetic, most things can just be brute-forced, so I'm not worried). We'd rather not want to pull in a third verification toolchain in addition to CBMC and HOL-Light.

@mkannwischer
Copy link
Contributor

Thanks for the pointer @vincentvbh.

Do you have an estimate on the performance impact on AArch64 (or x86_64) platforms?

@hanno-becker
Copy link
Contributor

On second thought, let's keep discussing the merits and impact of the proposal here first; no PR needed for now. @vincentvbh Please share your paper once available.

@mkannwischer
Copy link
Contributor

@vincentvbh could you please clarify if you think some code in mlkem-native can be improved or if this issue is mostly a pointer to your work that we should consider? It isn't entirely clear to me.

@vincentvbh
Copy link
Author

The code in mlkem-native could be improved: Take compressd_10 and compressd_11 as examples, they are using uint64_t. We can instead use int32_t if we keep the elements as signed integers instead.

@vincentvbh
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants