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

Add functional correctness proofs for AArch64-optimized NTT and invNTT in HOL Light #662

Merged
merged 6 commits into from
Jan 28, 2025

Conversation

potsrevennil
Copy link
Contributor

@potsrevennil potsrevennil commented Jan 15, 2025

Summary:

Steps:

  • The makefile in s2n-bignum/arm/ is copied to proofs/hol_light and adjusted to be compatible with nix.
  • The nix patches for hol_light and s2n-bignum mainly fix the path issue (e.g. using relative paths) of the 2 projects.

Performed local tests:

  • lint passing
  • tests all passing
  • tests bench passing
  • tests cbmc passing

Do you expect this change to impact performance: Yes/No

If yes, please provide local benchmarking results.

@potsrevennil potsrevennil force-pushed the hol_light branch 5 times, most recently from 95845ba to e8d9c90 Compare January 16, 2025 16:01
@potsrevennil potsrevennil marked this pull request as ready for review January 16, 2025 16:50
@potsrevennil potsrevennil requested a review from a team as a code owner January 16, 2025 16:50
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.

Something is still fishy in the Makefile target for object files -- see comments.

Also, the following fails:

make -j8 p256/bignum_montmul_p256.native
$S2N_BIGNUM_DIR/tools/run-proof.sh ./p256/bignum_montmul_p256.native ./p256_output
> Fatal error: exception Failure("dest_cons4: 4-byte inst code 2839547939 != first 4 bytes of []")

Could you also add a brief README that explains what one should do to fully compile + run a proof, and refer to the nix environment for setup? Is it feasible to run at least one proof in CI to confirm that the setup is functional? (e.g. a "hol-light sanity check" job or similar)

@potsrevennil potsrevennil force-pushed the hol_light branch 2 times, most recently from 218e722 to 0d4929c Compare January 17, 2025 07:32
@hanno-becker hanno-becker self-requested a review January 17, 2025 08:37
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.

Thank you @potsrevennil for fixing the Makefile issue.

Something is still not right, though:

make -j8 p256/bignum_montmul_p256.correct

continues to fail with

Fatal error: exception Failure("dest_cons4: 4-byte inst code 2839547939 != first 4 bytes of []")
make: *** [Makefile:440: p256/bignum_montmul_p256.correct] Error 2

@potsrevennil potsrevennil force-pushed the hol_light branch 6 times, most recently from 81db6f5 to a670c3e Compare January 21, 2025 03:44
@hanno-becker hanno-becker force-pushed the hol_light branch 6 times, most recently from c486428 to b8d3fdf Compare January 24, 2025 09:43
@hanno-becker hanno-becker changed the title Package hol_light and s2n-bignum into nix derivations Add functional correctness proofs for NTT and invNTT in HOL Light Jan 24, 2025
@hanno-becker hanno-becker changed the title Add functional correctness proofs for NTT and invNTT in HOL Light Add functional correctness proofs for AArch64-optimized NTT and invNTT in HOL Light Jan 24, 2025
@hanno-becker hanno-becker force-pushed the hol_light branch 2 times, most recently from 25776b6 to 051bc32 Compare January 24, 2025 12:31
@rod-chapman
Copy link
Contributor

I have tried to reproduce proof results on macOS. In short:

  1. pulled and checked out this branch.
  2. Re-started NIX
  3. cd proofs/hol_light/arm
  4. make
    terminates with
Fatal error: exception Failure("not an ELF file")
mlkem/mlkem_ntt.native had errors!
make: *** [Makefile:112: mlkem/mlkem_ntt.correct] Error 1

@rod-chapman
Copy link
Contributor

I note that

$ file mlkem/mlkem_ntt.o
mlkem/mlkem_ntt.o: Mach-O 64-bit arm64 object

which is obviously "not an ELF file". Is this the problem?

@hanno-becker
Copy link
Contributor

Yes, s2n-bignum/HOL-Light's object file parser only supports ELF

@rod-chapman
Copy link
Contributor

To confirm this PR is working OK, we need a testcase which is much smaller and faster than either NTT or INTT. What's the smallest, simplest, fastest proof that we can add?

@hanno-becker
Copy link
Contributor

We've tested small examples before. Now the PR is targeting the actual ML-KEM proofs.

@rod-chapman
Copy link
Contributor

I have reproduced the proofs successfully on an EC2 Graviton 3 (c7g) machine, running Ubuntu 24.04.

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.

Thanks @potsrevennil for the work!

potsrevennil and others added 6 commits January 28, 2025 09:44
The scripts in s2n_bignum assume execution within the $ROOT/<arch>/
directory and rely on relative paths. To integrate these scripts with
Nix, it is necessary to adjust the paths used for loading scripts to
ensure compatibility.

Additionally, the Makefile located under $ROOT/<arch> has been copied
to the mlkem-native directory and modified as needed to support this
change.

Signed-off-by: Thing-han, Lim <[email protected]>
@hanno-becker hanno-becker merged commit 9492a8b into main Jan 28, 2025
200 checks passed
@hanno-becker hanno-becker deleted the hol_light branch January 28, 2025 11:34
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.

Add HOL-Light & s2n-bignum infrastructure to nix environment
3 participants