Skip to content

Commit

Permalink
Merge pull request #107 from cryspen/lucas/fstar-wip
Browse files Browse the repository at this point in the history
Bertie Lax Typechecking
  • Loading branch information
karthikbhargavan authored Apr 3, 2024
2 parents 1592094 + 787a793 commit f612a59
Show file tree
Hide file tree
Showing 47 changed files with 20,952 additions and 10,472 deletions.
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use nix
export HACL_HOME="/home/lucas/repos/hacl-star"
export HAX_PROOF_LIBS_HOME="/home/lucas/repos/hax/latest-core/proof-libs/fstar"
export HAX_LIBS_HOME="/home/lucas/repos/hax/latest-core/hax-lib/proofs/fstar/extraction"
export FSTAR_HOME="/home/lucas/repos/hax/latest-core/proof-libs/fstar"
2 changes: 1 addition & 1 deletion .github/workflows/hax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
- name: 🏃🏻‍♀️ Run hax extraction
run: |
eval $(opam env)
./hax-driver.py extract
./hax-driver.py extract-fstar
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ rand = "0.8.0"
hex = "0.4.3"
tracing = "0.1"
libcrux = { version = "0.0.2-pre.2", features = ["rand"] }
hax-lib-macros = { git = "https://github.com/hacspec/hax", optional = true }

hax-lib-macros = { git = "https://github.com/hacspec/hax", optional = true}
hax-lib = { git = "https://github.com/hacspec/hax" }

[features]
default = ["api"]
test_utils = []
secret_integers = []
api = [] # The streaming Rust API that everyone should use but is not hacspec.
hax-fstar = ["dep:hax-lib-macros"]
hax-pv = ["dep:hax-lib-macros"]

[dev-dependencies]
Expand Down
14 changes: 14 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let
pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
packages = with pkgs; [
python3
rustup
];

HACL_HOME = "/home/lucas/repos/hacl-star";
HAX_PROOF_LIBS_HOME = "/home/lucas/repos/hax/latest-core/proof-libs/fstar";
HAX_LIBS_HOME = "/home/lucas/repos/hax/latest-core/hax-lib/proofs/fstar/extraction";
FSTAR_HOME = "/home/lucas/repos/hax/latest-core/proof-libs/fstar";
}
9 changes: 6 additions & 3 deletions hax-driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def shell(command, expect=0, cwd=None, env={}):
dest="sub",
help="Extract and typecheck F* etc. from the Bertie Rust code.",
)
extract_parser = sub_parser.add_parser("extract")
extract_parser = sub_parser.add_parser("extract-fstar")
extract_proverif_parser = sub_parser.add_parser("extract-proverif")
typecheck_parser = sub_parser.add_parser("typecheck")
patch_proverif_parser = sub_parser.add_parser("patch-proverif")
Expand Down Expand Up @@ -67,13 +67,16 @@ def shell(command, expect=0, cwd=None, env={}):
"-C",
"-p",
"bertie",
"-p",
"rand_core",
"--no-default-features",
";",
"into",
]

hax_env = {}

if options.sub == "extract":
if options.sub == "extract-fstar":
# The extract sub command.
shell(
cargo_hax_into
Expand All @@ -82,7 +85,7 @@ def shell(command, expect=0, cwd=None, env={}):
"-**::non_hax::** -bertie::stream::**",
"fstar",
"--interfaces",
"+**"
"+** +!bertie::tls13crypto::** +!bertie::tls13utils::**"
],
cwd=".",
env=hax_env,
Expand Down
19 changes: 19 additions & 0 deletions proofs/fstar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This directory holds the extracted F* code for the Bertie protocol layer.

The `extraction` folder is generated by running `hax-driver.py extract-fstar`

We then apply a patch to this folder for lax checking to obtain `extraction-lax`.

This patch mainly performs the following fixes which will become unnecessary with future hax fixes:

* Recursive functions are not produced with `let rec` in F*
* IndexMut implementations need to implemented by hand in F*
* Empty lists need type annotations in F*

Finally, we edit the code in `extraction-lax` by hand to obtain panic-freedom proofs in `extraction-panic-free`.
Eventually these hand-edits will be backported into Rust as pre- and post-conditions.





Loading

0 comments on commit f612a59

Please sign in to comment.