| 1 | # Bedrock2 field-arithmetic backend |
| 2 | |
| 3 | The code in this subdirectory creates proofs and code for field arithmetic using |
| 4 | fiat-crypto's pipeline. |
| 5 | |
| 6 | ## Structure |
| 7 | |
| 8 | `Common/` : generally useful definitions and proofs for bedrock2 field |
| 9 | arithmetic |
| 10 | |
| 11 | `Synthesis/` : tactics and proofs that string together the fiat-crypto pipeline |
| 12 | and the bedrock2 translation, and that make it easy to create full suites of |
| 13 | bedrock2 operations with proofs for different fields |
| 14 | |
| 15 | `Translation/` : the compiler that translates from fiat-crypto's AST to |
| 16 | bedrock2, and its correctness proofs |
| 17 | |
| 18 | ## Usage |
| 19 | |
| 20 | Generally, you would (following the pattern in `Synthesis/Examples`) first |
| 21 | create a suite of field operations for your chosen field using the premade |
| 22 | synthesis tactics. For each field operation, you get a bedrock2 function, a |
| 23 | specification, and a proof that the function obeys the specification. Using |
| 24 | these, you can prove higher-level functions using the usual bedrock2 logic. |
| 25 | |
| 26 | For more custom use cases, it's also possible to call the translator directly on |
| 27 | an arbitrary expression in fiat-crypto's AST. The top-level function for this |
| 28 | purpose is `translate_func` from `Translation/Func.v`, and its correctness proof |
| 29 | is `translate_func_correct` from `Translation/Proofs/Func.v`. To prove that the |
| 30 | expression is valid input to the compiler, it's also likely helpful to take a |
| 31 | look at the computable version of `valid_func` from |
| 32 | `Translation/Proofs/ValidComputable/Func.v`. |
| 33 | |
| 34 | ## Examples |
| 35 | |
| 36 | Examples of generating, translating, and proving arithmetic operations can be |
| 37 | found in `Synthesis/Examples/` and `../End2End/*/Field*.v`. |
| 38 | Examples of generated output (printed as C code) can be found outside this |
| 39 | subdirectory, in the top-level `fiat-bedrock2` subdirectory. Please note that |
| 40 | the translation from bedrock2 to C is just for readability, and is unverified. |