EasyCrypt is a toolset for reasoning about relational properties of probabilistic computations with adversarial code. Its main application is the construction and verification of code-based, game-playing cryptographic security proofs, but it's capable of more general formal verification tasks. Another important application of EasyCrypt is proving the functional correctness of low-level implementations—particularly those in Jasmin—against high-level specifications.
EasyCrypt is part of the Formosa Crypto project.
- EasyCrypt: Computer-Aided Cryptographic Proofs
- Installation
- Setup and Configuration
- Useful Resources
There are several ways to install EasyCrypt and its dependencies. The recommended method is to use OPAM, a package manager for OCaml (the programming language EasyCrypt is written in). This guide provides a brief overview of that process. For more detailed instructions, caveats, and alternative installation methods, please refer to INSTALL.md. Also, if you encounter any issues, be sure to consult the list of known installation quirks and corresponding troubleshooting tips.
Note: The last two steps covered here are actually part of the (post-installation) setup and configuration, which is further detailed below.
- Install OPAM.
Common methods include:- Via your package manager.
Run<package-install-command> <opam-package>
(e.g.,apt-get install opam
for Debian/Ubuntu). - Via one of OPAM's installation scripts.
Download and run this script on Unix-like systems or this script on Windows systems using PowerShell.
- Via your package manager.
- Initialize OPAM.
Runopam init
(and make sure to read the output and follow any instructions). - Optional, but recommended:
- Create a dedicated OPAM switch.
Runopam switch --empty create <switch-name>
.
(Alternatively, runopam switch create <switch-name> <compiler-version>
to pick a specific compiler version yourself, instead of letting OPAM pick one for you during the installation of EasyCrypt's dependencies.) - Activate the dedicated switch.
Runopam switch set <switch-name>
(and make sure to read the output and follow any instructions).
- Create a dedicated OPAM switch.
- Add EasyCrypt's OPAM package.
Runopam pin -yn add easycrypt https://github.com/EasyCrypt/easycrypt.git
. (This requiresgit
, so make sure you have that installed first.) - Install EasyCrypt's dependencies.
Runopam install --deps-only easycrypt
.- If your OPAM version is below 2.1 (which you can find out by running
opam --version
), first runopam install opam-depext
andopam depext easycrypt
, in that order (and make sure to read the output and follow any instructions).
- If your OPAM version is below 2.1 (which you can find out by running
- Install compatible SMT solvers.
For example, to install Alt-Ergo version 2.6.0, runopam install alt-ergo.2.6.0
. - Install EasyCrypt.
Runopam install easycrypt
.
(Alternatively, install from source by cloning or downloading this repository, navigating to its root, and runningmake
followed bymake install
.) - Configure Why3.
Runeasycrypt why3config
. - Install a front-end.
After installing EasyCrypt and its dependencies, some additional setup and configuration are required to ensure everything works properly. First, if you haven't yet installed at least one suitable SMT solver, you should do that first. Then, it's crucial to configure Why3 so that EasyCrypt can interface with the installed SMT solvers. Lastly, if you want to do more than just verify existing proof scripts from the command-line, it's strongly recommended to install a suitable front-end. Even for very simple inspection and interaction with proof scripts, having a front-end is highly recommended.
Why3 and SMT solvers are independent pieces of software with their own version-specific interactions. Setting up a working environment may require installing specific versions of some solvers.
EasyCrypt currently depends on Why3, version >= 1.8 and < 1.9, which supports the following recommended SMT solvers:
Alt-Ergo is available via OPAM. To install version 2.6.0, run
opam install alt-ergo.2.6.0
If you've installed a different version of Alt-Ergo, you can switch to version
2.6.0 by running opam pin alt-ergo 2.6.0
.
After installing, removing, or updating any SMT solvers you plan to use with EasyCrypt, you should (re)configure Why3 to reflect these changes.
You can do this manually, or let EasyCrypt handle it using the why3config
sub-command:
easycrypt why3config
By default, EasyCrypt saves the generated Why3 configuration file
to $XDG_CONFIG_HOME/easycrypt/why3.conf
on Unix-like systems (falling
back to $HOME/.config/easycrypt/why3.conf
if $XDG_CONFIG_HOME
is unset),
and to %HOME%\Local Settings\easycrypt\why3.conf
on Windows systems.
If you'd prefer to store the configuration file elsewhere, pass
the desired path (represented by <configuration-file>
below) to the -why3
option:
easycrypt why3config -why3 <configuration-file>
Note that EasyCrypt does not remember custom configuration paths: Unless
told otherwise, it will only search in some default locations
(including the standard generation path and certain system-wide locations).
To run EasyCrypt with a Why3 configuration file stored in a non-default location,
again use the -why3
option to pass the path to the file:
easycrypt -why3 <configuration-file>
(In this case, you’re simply running EasyCrypt with
the specified configuration file, not generating
a new one—hence the omission of the why3config
sub-command.)
While using EasyCrypt directly from the command line can be sufficient for verifying existing proof scripts, it's highly recommended to install a suitable front-end when engaging in anything more than that (even for simply inspecting and interacting with proof scripts). At present, the only available front-end is based on Emacs's Proof General. However, a front-end for VSCode is currently in development.
EasyCrypt mode has been integrated upstream. Please, go to https://github.com/ProofGeneral/PG and follow the instructions.
Work in progress.
Examples of how to use EasyCrypt are in the examples
directory. You
will find basic examples at the root of this directory, as well as a
more advanced example in the MEE-CBC
sub-directory and a tutorial on
how to use the complexity system in cost
sub-directory.