Home

Awesome

<p align="center"> <img src="logo.svg"/> </p> <p align="center"> <a href="https://hacspec.org/">🌐 Website</a> | <a href="https://hacspec.org/book">📖 Book</a> | <a href="https://hacspec.org/blog">📝 Blog</a> | <a href="https://hacspec.zulipchat.com/">💬 Zulip</a> | <a href="https://hacspec.org/hax/">🛠️ Internal docs</a> | <a href="https://hax-playground.cryspen.com/">🛝 Playground</a> </p>

Hax

hax is a tool for high assurance translations that translates a large subset of Rust into formal languages such as F* or Coq. This extends the scope of the hacspec project, which was previously a DSL embedded in Rust, to a usable tool for verifying Rust programs.

So what is hacspec now?

hacspec is the functional subset of Rust that can be used, together with a hacspec standard library, to write succinct, executable, and verifiable specifications in Rust. These specifications can be translated into formal languages with hax.

<p align="center"> <a href="https://hax-playground.cryspen.com/#fstar+tc/latest-main/gist=5252f86237adbca7fdeb7a8fea0b1648"> Try out hax online now! </a> </p>

Learn more

Here are some resources for learning more about hax:

Usage

Hax is a cargo subcommand. The command cargo hax accepts the following subcommands:

Note:

Installation

<details> <summary><b>Manual installation</b></summary>
  1. Make sure to have the following installed on your system:
  1. Clone this repo: git clone git@github.com:hacspec/hax.git && cd hax
  2. Run the setup.sh script: ./setup.sh.
  3. Run cargo-hax --help
</details> <details> <summary><b>Nix</b></summary>

This should work on Linux, MacOS and Windows.

<details> <summary><b>Prerequisites:</b> <a href="https://nixos.org/">Nix package manager</a> <i>(with <a href="https://nixos.wiki/wiki/Flakes">flakes</a> enabled)</i></summary> </details> </details> <details> <summary><b>Using Docker</b></summary>
  1. Clone this repo: git clone git@github.com:hacspec/hax.git && cd hax
  2. Build the docker image: docker build -f .docker/Dockerfile . -t hax
  3. Get a shell: docker run -it --rm -v /some/dir/with/a/crate:/work hax bash
  4. You can now run cargo-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.

</details>

Supported Subset of the Rust Language

Hax intends to support full Rust, with the two following exceptions, promoting a functional style:

  1. no unsafe code (see https://github.com/hacspec/hax/issues/417);
  2. mutable references (aka &mut T) on return types or when aliasing (see https://github.com/hacspec/hax/issues/420).

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:

Hacking on Hax

The documentation of the internal crate of hax and its engine can be found here.

Edit the sources (Nix)

Just clone & cd into the repo, then run nix develop .. You can also just use direnv, with editor integration.

Structure of this repository

Compiling, formatting, and more

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.

Publications & Other material

Secondary literature, using hacspec:

Contributing

Before starting any work please join the Zulip chat, start a discussion on Github, or file an issue to discuss your contribution.

Acknowledgements

Zulip graciously provides the hacspec & hax community with a "Zulip Cloud Standard" tier.