# Structure

This folder is structured as follows:

## Meta
- `Readme.md`  This file
- `gentest.py` Test generation script to create commands to formally verify the correctness of the assembly files.
- `test.sh`    Helper script to manually call and run the tests. Uses `./gentest.py`.

## Assembly files

All those assembly files have been generated by [CryptOpt](https://github.com/0xADE1A1DE/CryptOpt) on ten different CPUs.

The structure is `./fiat_<CURVE>_<METHOD>/seed<SEED>_ratio<RATIO>.asm`.
Every folder contains optimized and proven correct implementations of the respective function using the CryptOpt Framework.
The `<CURVE>` is one of Fiat Cryptography's main supported curves: `curve25519` `curve25519_solinas` `p224` `p256` `p384` `p434` `p448_solinas` `p521` `poly1305` `secp256k1_dettman` `secp256k1_montgomery`
The `<METHOD>` is one of the respective `multiply` or `square` (carry) if it is based on the solinas primes.

The `<SEED>` value is the seed that CryptOpt was called with to create this file, the `<RATIO>` is an indication of the measured performance during optimization.
Specifically, a `<RATIO>`-value of `abbbb` corresponds to a performance ratio of `a.bbbb`x compared to the assembly that `clang-15 -O3 -march=native -mtune=native` would have produces on the system.
Hence, the higher the value the faster the code.
Every `asm` file contains a footer comment with some metadata on which CPU it was produced.

All assembly files use the *Linux System-V ABI* and require the CPU flags `-adx` and `-bmi2` (Supported at least from Intel Cores since the 6th generation (Skylake), released in 2016).
The files are written using Intel assembly syntax.
