A Rust verification tool
476
stars
5,061
commits
Rust
primary language
Sep 9, 2026
updated
hax is a tool for high assurance translations of a large subset of Rust into formal languages such as Lean, F* or Rocq.
| General purpose proof assistants | Cryptography & protocols | ||||
|
(via Aeneas) | F* |
| ProVerif |
| EasyCrypt |
| π active dev. | π’ stable | π experimental | π experimental | π experimental | π experimental |
Here are some resources for learning more about hax:
Questions? Join us on Zulip or open a GitHub Discussion. For bugs, file an Issue.
hax is a cargo subcommand.
The command cargo hax accepts the following subcommands:
into (cargo hax into BACKEND): translate a Rust crate to the backend BACKEND.json (cargo hax json): extract the typed AST of your crate as a JSON file.| Backend | Command | Description |
|---|---|---|
| Lean (via Aeneas) | cargo hax into lean | Recommended for Lean. Uses charon + aeneas. |
| Lean (legacy) | cargo hax into legacy-lean | Uses the hax engine directly. Prefer lean. |
| F* | cargo hax into fstar | Stable. |
| Rocq/Coq | cargo hax into coq | Experimental. |
| ProVerif | cargo hax into pro-verif | Experimental. |
| SSProve | cargo hax into ssprove | Experimental. |
| EasyCrypt | cargo hax into easycrypt | Experimental. |
Use --help on any subcommand for options (e.g. cargo hax into fstar --z3rlimit 100).
hax is supported on Linux and macOS, on both x86_64 and aarch64. Windows is not supported; use WSL there.
git clone git@github.com:cryspen/hax.git && cd haxopam switch create hax 5.1.1./setup.sh.
This installs hax; aeneas and charon are downloaded on demand when first needed.cargo-hax --helpThis should work on Linux and MacOS.
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Run hax on a crate directly to get Lean/F*/Coq/... (assuming you are in the crate's folder):
nix run github:cryspen/hax -- into fstar extracts F*.Install hax: nix profile install github:cryspen/hax, then run cargo hax --help anywhere
Note: in any of the Nix commands above, replace github:cryspen/hax by ./dir to compile a local checkout of hax that lives in ./some-dir
Setup binary cache: using Cachix, just cachix use hax
Note: the lean backend downloads its aeneas and charon binaries on demand (see Aeneas and Charon below); no extra install step is needed.
git clone git@github.com:cryspen/hax.git && cd haxdocker build -f .docker/Dockerfile . -t haxdocker run -it --rm -v /some/dir/with/a/crate:/work hax bashcargo-hax --help (notice here we use cargo-hax instead of cargo hax)Note: Please make sure that $HOME/.cargo/bin is in your $PATH, as
that is where setup.sh will install hax.
Note: the lean backend downloads its aeneas and charon binaries on demand (see Aeneas and Charon below); no extra install step is needed.
The lean backend (cargo hax into lean) uses the
charon +
aeneas pipeline instead of
the hax engine. It requires the aeneas and charon binaries.
Their versions are managed by hax: pre-built binaries are downloaded on demand, verified against the version manifest shipped with the release, and cached under $XDG_CACHE_HOME/hax/tools/. To see the active versions or pre-populate the cache (e.g. in CI or before going offline), run, inside your project:
cargo hax tools show
cargo hax tools install
The default versions shipped with a hax release are tested together and are the recommended choice. Pinning versions yourself is an advanced option: combinations other than the defaults are untested, so establishing that one works is up to you. To pin versions for a project, declare them in a hax.toml at your project's root:
[tools]
aeneas = "nightly-2026.07.01"
charon = "nightly-2026.07.01"
You can also build or install aeneas and charon yourself (e.g. from source) and point to them with a path entry in hax.toml (e.g. charon = { path = "vendor/bin/charon" }).
See Managing tool versions in the manual for the full reference (cargo hax tools, the hax.toml schema, resolution order, and the hax-lib compatibility check).
hax intends to support full Rust, with the one exception, promoting a functional style: mutable references (aka &mut T) on return types or when aliasing (see https://github.com/cryspen/hax/issues/420) are forbidden.
Each unsupported Rust feature is documented as an issue labeled unsupported-rust. When the issue is labeled wontfix-v1, that means we don't plan on supporting that feature soon.
Quicklinks:
The documentation of the internal crate of hax and its engine can be found here for the engine and here for the frontend.
Just clone & cd into the repo, then run nix develop ..
You can also just use direnv, with editor integration.
The flake provides several dev shells:
| Shell | Purpose |
|---|---|
nix develop . | Hacking on hax itself: the toolchain to build the Rust CLI, the frontend and the OCaml engine. Provides no backend verifier. |
nix develop .#fstar | The above plus F*, for the F* backend and the F* proof libraries. Used by CI to check the proof libraries. |
nix develop .#examples | The above plus ProVerif and Lean (through elan), for running examples/ against a hax you build yourself. |
nix develop .#ci-examples | Running examples/ against a hax built by the flake, rather than one you build from source. Used by CI. |
The first three shells give you the toolchain to build hax, not a cargo-hax binary: run just build first (see below).
frontend/: Rust library that hooks into the Rust compiler and
extracts its internal typed abstract syntax tree
THIR as JSON.engine/: the simplification and elaboration engine that translates programs
from the Rust language to various backends (see engine/backends/). Written
in OCaml.rust-engine/: an on-going rewrite of our engine from OCaml to Rust.cli/: the cargo hax subcommand and the custom rustc drivers it
uses to run the frontend.hax-lib/: helper crate providing hax-specific macros (e.g.
requires, ensures) for annotating Rust programs.hax-types/: types shared between the frontend, the CLI, and the engine.proof-libs/: a symlink to hax-lib/proof-libs/, the per-backend
proof libraries that the extracted code builds against.examples/: examples showing what hax can do.tests/: integration tests.docs/: sources of the hax website,
including the manual and the blog.We use the just command runner. If you use
Nix, the dev shell provides it automatically, if you don't use Nix,
please install just on
your system.
Anywhere within the repository, you can build and install in PATH (1)
the Rust parts with just rust, (2) the OCaml parts with just ocaml
or (3) both with just build. More commands (e.g. just fmt to
format) are available, please run just or just --list to get all
the commands.
Before starting any work please join the Zulip chat, start a discussion on Github, or file an issue to discuss your contribution.
Zulip graciously provides the hacspec & hax community with a "Zulip Cloud Standard" tier.
(top 30 of 49)
Rust
26.1%
OCaml
24.0%
Rocq Prover
16.3%
Lean
16.1%
F*
15.2%
A Rust verification tool
476
stars
5,061
commits
Rust
primary language
Sep 9, 2026
updated
hax is a tool for high assurance translations of a large subset of Rust into formal languages such as Lean, F* or Rocq.
| General purpose proof assistants | Cryptography & protocols | ||||
|
(via Aeneas) | F* |
| ProVerif |
| EasyCrypt |
| π active dev. | π’ stable | π experimental | π experimental | π experimental | π experimental |
Here are some resources for learning more about hax:
Questions? Join us on Zulip or open a GitHub Discussion. For bugs, file an Issue.
hax is a cargo subcommand.
The command cargo hax accepts the following subcommands:
into (cargo hax into BACKEND): translate a Rust crate to the backend BACKEND.json (cargo hax json): extract the typed AST of your crate as a JSON file.| Backend | Command | Description |
|---|---|---|
| Lean (via Aeneas) | cargo hax into lean | Recommended for Lean. Uses charon + aeneas. |
| Lean (legacy) | cargo hax into legacy-lean | Uses the hax engine directly. Prefer lean. |
| F* | cargo hax into fstar | Stable. |
| Rocq/Coq | cargo hax into coq | Experimental. |
| ProVerif | cargo hax into pro-verif | Experimental. |
| SSProve | cargo hax into ssprove | Experimental. |
| EasyCrypt | cargo hax into easycrypt | Experimental. |
Use --help on any subcommand for options (e.g. cargo hax into fstar --z3rlimit 100).
hax is supported on Linux and macOS, on both x86_64 and aarch64. Windows is not supported; use WSL there.
git clone git@github.com:cryspen/hax.git && cd haxopam switch create hax 5.1.1./setup.sh.
This installs hax; aeneas and charon are downloaded on demand when first needed.cargo-hax --helpThis should work on Linux and MacOS.
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Run hax on a crate directly to get Lean/F*/Coq/... (assuming you are in the crate's folder):
nix run github:cryspen/hax -- into fstar extracts F*.Install hax: nix profile install github:cryspen/hax, then run cargo hax --help anywhere
Note: in any of the Nix commands above, replace github:cryspen/hax by ./dir to compile a local checkout of hax that lives in ./some-dir
Setup binary cache: using Cachix, just cachix use hax
Note: the lean backend downloads its aeneas and charon binaries on demand (see Aeneas and Charon below); no extra install step is needed.
git clone git@github.com:cryspen/hax.git && cd haxdocker build -f .docker/Dockerfile . -t haxdocker run -it --rm -v /some/dir/with/a/crate:/work hax bashcargo-hax --help (notice here we use cargo-hax instead of cargo hax)Note: Please make sure that $HOME/.cargo/bin is in your $PATH, as
that is where setup.sh will install hax.
Note: the lean backend downloads its aeneas and charon binaries on demand (see Aeneas and Charon below); no extra install step is needed.
The lean backend (cargo hax into lean) uses the
charon +
aeneas pipeline instead of
the hax engine. It requires the aeneas and charon binaries.
Their versions are managed by hax: pre-built binaries are downloaded on demand, verified against the version manifest shipped with the release, and cached under $XDG_CACHE_HOME/hax/tools/. To see the active versions or pre-populate the cache (e.g. in CI or before going offline), run, inside your project:
cargo hax tools show
cargo hax tools install
The default versions shipped with a hax release are tested together and are the recommended choice. Pinning versions yourself is an advanced option: combinations other than the defaults are untested, so establishing that one works is up to you. To pin versions for a project, declare them in a hax.toml at your project's root:
[tools]
aeneas = "nightly-2026.07.01"
charon = "nightly-2026.07.01"
You can also build or install aeneas and charon yourself (e.g. from source) and point to them with a path entry in hax.toml (e.g. charon = { path = "vendor/bin/charon" }).
See Managing tool versions in the manual for the full reference (cargo hax tools, the hax.toml schema, resolution order, and the hax-lib compatibility check).
hax intends to support full Rust, with the one exception, promoting a functional style: mutable references (aka &mut T) on return types or when aliasing (see https://github.com/cryspen/hax/issues/420) are forbidden.
Each unsupported Rust feature is documented as an issue labeled unsupported-rust. When the issue is labeled wontfix-v1, that means we don't plan on supporting that feature soon.
Quicklinks:
The documentation of the internal crate of hax and its engine can be found here for the engine and here for the frontend.
Just clone & cd into the repo, then run nix develop ..
You can also just use direnv, with editor integration.
The flake provides several dev shells:
| Shell | Purpose |
|---|---|
nix develop . | Hacking on hax itself: the toolchain to build the Rust CLI, the frontend and the OCaml engine. Provides no backend verifier. |
nix develop .#fstar | The above plus F*, for the F* backend and the F* proof libraries. Used by CI to check the proof libraries. |
nix develop .#examples | The above plus ProVerif and Lean (through elan), for running examples/ against a hax you build yourself. |
nix develop .#ci-examples | Running examples/ against a hax built by the flake, rather than one you build from source. Used by CI. |
The first three shells give you the toolchain to build hax, not a cargo-hax binary: run just build first (see below).
frontend/: Rust library that hooks into the Rust compiler and
extracts its internal typed abstract syntax tree
THIR as JSON.engine/: the simplification and elaboration engine that translates programs
from the Rust language to various backends (see engine/backends/). Written
in OCaml.rust-engine/: an on-going rewrite of our engine from OCaml to Rust.cli/: the cargo hax subcommand and the custom rustc drivers it
uses to run the frontend.hax-lib/: helper crate providing hax-specific macros (e.g.
requires, ensures) for annotating Rust programs.hax-types/: types shared between the frontend, the CLI, and the engine.proof-libs/: a symlink to hax-lib/proof-libs/, the per-backend
proof libraries that the extracted code builds against.examples/: examples showing what hax can do.tests/: integration tests.docs/: sources of the hax website,
including the manual and the blog.We use the just command runner. If you use
Nix, the dev shell provides it automatically, if you don't use Nix,
please install just on
your system.
Anywhere within the repository, you can build and install in PATH (1)
the Rust parts with just rust, (2) the OCaml parts with just ocaml
or (3) both with just build. More commands (e.g. just fmt to
format) are available, please run just or just --list to get all
the commands.
Before starting any work please join the Zulip chat, start a discussion on Github, or file an issue to discuss your contribution.
Zulip graciously provides the hacspec & hax community with a "Zulip Cloud Standard" tier.
(top 30 of 49)
Rust
26.1%
OCaml
24.0%
Rocq Prover
16.3%
Lean
16.1%
F*
15.2%