-
Notifications
You must be signed in to change notification settings - Fork 34
Add hol-server for programmatic HOL Light communication #883
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
Merged
+120
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright (c) The mldsa-native project authors | ||
| # SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT | ||
| # | ||
| # HOL Light server for programmatic communication | ||
| # Based on https://github.com/monadius/hol_server | ||
| # | ||
| # Usage: hol-server [port] | ||
|
|
||
| set -e | ||
|
|
||
| PORT=${1:-2012} | ||
|
|
||
| # These are replaced by nix | ||
| HOL_LIGHT_DIR="@hol_light@/lib/hol_light" | ||
| HOL_SERVER_SRC="@hol_server_src@" | ||
|
|
||
| # cd to x86_64 proofs directory if in mldsa-native repo | ||
| PROOF_DIR="$(git rev-parse --show-toplevel 2>/dev/null)/proofs/hol_light/x86_64" | ||
| [ -d "$PROOF_DIR" ] && cd "$PROOF_DIR" | ||
|
|
||
| echo "Starting HOL Light server on port $PORT..." | ||
|
|
||
| { | ||
| # Load required libraries for server2.ml | ||
| echo '#directory "+unix";;' | ||
| echo '#directory "+threads";;' | ||
| echo '#load "unix.cma";;' | ||
| echo '#load "threads.cma";;' | ||
|
|
||
| # Load the server using #use (not loads) for proper evaluation | ||
| echo "#use \"$HOL_SERVER_SRC/server2.ml\";;" | ||
|
|
||
| # Start the server | ||
| echo "start ~single_connection:false $PORT;;" | ||
|
|
||
| # Keep stdin open for the server to continue running | ||
| cat | ||
| } | exec "$HOL_LIGHT_DIR/hol.sh" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Copyright (c) The mldsa-native project authors | ||
| # SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT | ||
|
|
||
| # HOL Light server for programmatic communication | ||
| # Based on https://github.com/monadius/hol_server | ||
| { fetchFromGitHub, runCommand, hol_light' }: | ||
|
|
||
| let | ||
| hol_server_src = fetchFromGitHub { | ||
| owner = "monadius"; | ||
| repo = "hol_server"; | ||
| rev = "vscode"; | ||
| hash = "sha256-o98ule5uuazm36+ppsvX2KCbtVbVwzHxGboUhbbrPCQ="; | ||
| }; | ||
|
|
||
| hol_server_start = runCommand "hol-server" { } '' | ||
| mkdir -p $out/bin | ||
| substitute ${./hol-server.sh} $out/bin/hol-server \ | ||
| --replace-fail "@hol_light@" "${hol_light'}" \ | ||
| --replace-fail "@hol_server_src@" "${hol_server_src}" | ||
| chmod +x $out/bin/hol-server | ||
| ''; | ||
|
|
||
| in | ||
| { | ||
| inherit hol_server_src hol_server_start; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| [//]: # (SPDX-License-Identifier: CC-BY-4.0) | ||
|
|
||
| # HOL Light functional correctness proofs | ||
|
|
||
| This directory contains functional correctness proofs for x86_64 assembly routines | ||
| used in mldsa-native. The proofs are written in the [HOL Light](https://hol-light.github.io/) theorem | ||
| prover, utilizing the assembly verification infrastructure from [s2n-bignum](https://github.com/awslabs/s2n-bignum). | ||
|
|
||
| Each function is proved in a separate `.ml` file in [x86_64/proofs/](x86_64/proofs). Each file | ||
| contains the byte code being verified, as well as the specification that is being proved. | ||
|
|
||
| ## Reproducing the proofs | ||
|
|
||
| To reproduce the proofs, enter the nix shell via | ||
|
|
||
| ```bash | ||
| nix develop .#hol_light --experimental-features 'nix-command flakes' | ||
| ``` | ||
|
|
||
| from mldsa-native's base directory. Then | ||
|
|
||
| ```bash | ||
| make -C proofs/hol_light/x86_64 | ||
| ``` | ||
|
|
||
| will build and run the proofs. Note that this may take hours even on powerful machines. | ||
|
|
||
| ## Interactive proof development | ||
|
|
||
| For interactive proof development, start the HOL Light server: | ||
|
|
||
| ```bash | ||
| hol-server [port] # default port is 2012 | ||
| ``` | ||
|
|
||
| Then use the [HOL Light extension for VS Code](https://marketplace.visualstudio.com/items?itemName=monadius.hol-light-simple) | ||
| to connect and send commands interactively. | ||
|
|
||
| Alternatively, send commands using netcat: | ||
|
|
||
| ```bash | ||
| echo '1+1;;' | nc -w 5 127.0.0.1 2012 | ||
| ``` | ||
|
|
||
| ## What is covered? | ||
|
|
||
| - x86_64 forward NTT: [mldsa_ntt.S](x86_64/mldsa/mldsa_ntt.S) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.