aboutsummaryrefslogtreecommitdiff
path: root/src/Specific/CurveParameters
Commit message (Collapse)AuthorAge
* Pass -mbmi2 to gccGravatar Jason Gross2018-01-19
| | | | | This will hopefully fix the issue where travis gcc complains about not being able to inline mulx. I hope.
* Add x25519 donna versions with the new way of generating C codeGravatar Jason Gross2018-01-15
|
* Generate fecarry for solinasGravatar Jason Gross2018-01-10
| | | | | | | This is a one-line change in generate_parameters.py (plus some whitespace trimming), and running `make regenerate-curves` This handles part of #294
* add back incorrectly deleted filesGravatar jadep2017-11-12
|
* new autogenerated filesGravatar jadep2017-11-12
|
* update remake-curves.sh and MakefileGravatar jadep2017-11-12
|
* changes to parameter-generation scriptGravatar jadep2017-11-12
|
* clang -fbracket-depth=999999Gravatar Andres Erbsen2017-11-03
|
* use clangGravatar Andres Erbsen2017-11-03
|
* python3 generate_parameters.py primes.txt; (cd ↵Gravatar Jason Gross2017-11-03
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f)
* python3 generate_parameters.py primes.txt; (cd ↵Gravatar Jason Gross2017-11-03
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f)
* fibe: Only define bitwidth on the command lineGravatar Jason Gross2017-11-03
| | | | | | | | | | We generate the PRI macros and the limb_t type from the bitwidth in the C preprocessor My reasoning here is that generate_parameters.py and the generated *.json files are more user-facing than fibe.c, so we should optimize for cleanliness of that user-facing code. If this is the wrong direction to go in, then this commit should be reverted.
* python3 generate_parameters.py primes.txt; (cd ↵Gravatar Jason Gross2017-11-03
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f)
* python3 generate_parameters.py primes.txt; (cd ↵Gravatar Jason Gross2017-11-03
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f)
* Add montgomery fesquare filesGravatar Jason Gross2017-11-03
|
* python3 generate_parameters.py primes.txt; (cd ↵Gravatar Andres Erbsen2017-11-02
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f)
* python3 generate_parameters.py primes.txt; (cd ↵Gravatar Jason Gross2017-11-02
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f)
* python3 generate_parameters.py primes.txt; pushd ↵Gravatar Jason Gross2017-11-02
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f; popd
* python3 generate_parameters.py primes.txt; pushd ↵Gravatar Jason Gross2017-11-02
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f; popd
* python3 generate_parameters.py primes.txt; pushd ↵Gravatar Jason Gross2017-11-02
| | | | src/Specific/CurveParameters/; ./remake_curves.sh -f; popd
* Add -D compiler arguments for gmpxx.cppGravatar Jason Gross2017-11-02
|
* Add tight and loose bounds, no carry in add, subGravatar Jason Gross2017-10-22
| | | | | | | | Following Andres' suggestions to allow making ladderstep from other synthesis things. It went though mostly without a hitch, though there were a number of boilerplate changes needed.
* Default carry chains in json filesGravatar Jason Gross2017-10-18
| | | | | | The default carry chain now makes sense to me, and seems like a very reasonable default value, so there's no need to specify the [0; 1] part at the end, I think.
* Fold Karatsuba into json format and synthesisGravatar Jason Gross2017-10-18
| | | | | The json format now takes an additional, optional "goldilocks" boolean / boolean-string key determining if we're doing karatsuba.
* Build curve-specific files from jsonGravatar Jason Gross2017-10-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The X25519 curves are now generated from `.json` files. This code only works in >= 8.7, because it makes use of the recently-merged-from-fiat `transparent_abstract` tactic to allow defining things in tactics without massive slowdown. The structure is as follows: 0. The module types and tactic definitions that set up the infrastructure live in `src/Specific/Framework/` 1. There are `.json` files in `src/Specific/CurveParameters/` that specify curve characteristics. A simple example is `x2555_130.json`, which is: ```json { "modulus" : "2^255-5", "base" : "130", "a24" : "121665 (* XXX TODO(andreser) FIXME? Is this right for this curve? *)", "sz" : "3", "bitwidth" : "128", "carry_chain1" : "default", "carry_chain2" : ["0", "1"], "coef_div_modulus" : "2", "operations" : ["ladderstep"] } ``` A more complicated example is `x25519_c64.json`: ```json { "modulus" : "2^255-19", "base" : "51", "a24" : "121665", "sz" : "5", "bitwidth" : "64", "carry_chain1" : "default", "carry_chain2" : ["0", "1"], "coef_div_modulus" : "2", "operations" : ["femul", "fesquare", "freeze", "ladderstep"], "extra_files" : ["X25519_C64/scalarmult.c"], "compiler" : "gcc -march=native -mtune=native -std=gnu11 -O3 -flto -fomit-frame-pointer -fwrapv -Wno-attributes", "mul_header" : "(* Micro-optimized form from curve25519-donna-c64 by Adam Langley (Google) and Daniel Bernstein. See <https://github.com/agl/curve25519-donna/blob/master/LICENSE.md>. *)", "mul_code" : " uint128_t t[5]; limb r0,r1,r2,r3,r4,s0,s1,s2,s3,s4,c; r0 = in[0]; r1 = in[1]; r2 = in[2]; r3 = in[3]; r4 = in[4]; s0 = in2[0]; s1 = in2[1]; s2 = in2[2]; s3 = in2[3]; s4 = in2[4]; t[0] = ((uint128_t) r0) * s0; t[1] = ((uint128_t) r0) * s1 + ((uint128_t) r1) * s0; t[2] = ((uint128_t) r0) * s2 + ((uint128_t) r2) * s0 + ((uint128_t) r1) * s1; t[3] = ((uint128_t) r0) * s3 + ((uint128_t) r3) * s0 + ((uint128_t) r1) * s2 + ((uint128_t) r2) * s1; t[4] = ((uint128_t) r0) * s4 + ((uint128_t) r4) * s0 + ((uint128_t) r3) * s1 + ((uint128_t) r1) * s3 + ((uint128_t) r2) * s2; r4 *= 19; r1 *= 19; r2 *= 19; r3 *= 19; t[0] += ((uint128_t) r4) * s1 + ((uint128_t) r1) * s4 + ((uint128_t) r2) * s3 + ((uint128_t) r3) * s2; t[1] += ((uint128_t) r4) * s2 + ((uint128_t) r2) * s4 + ((uint128_t) r3) * s3; t[2] += ((uint128_t) r4) * s3 + ((uint128_t) r3) * s4; t[3] += ((uint128_t) r4) * s4; ", "square_header" : "(* Micro-optimized form from curve25519-donna-c64 by Adam Langley (Google) and Daniel Bernstein. See <https://github.com/agl/curve25519-donna/blob/master/LICENSE.md>. *)", "square_code" : " uint128_t t[5]; limb r0,r1,r2,r3,r4,c; limb d0,d1,d2,d4,d419; r0 = in[0]; r1 = in[1]; r2 = in[2]; r3 = in[3]; r4 = in[4]; do { d0 = r0 * 2; d1 = r1 * 2; d2 = r2 * 2 * 19; d419 = r4 * 19; d4 = d419 * 2; t[0] = ((uint128_t) r0) * r0 + ((uint128_t) d4) * r1 + (((uint128_t) d2) * (r3 )); t[1] = ((uint128_t) d0) * r1 + ((uint128_t) d4) * r2 + (((uint128_t) r3) * (r3 * 19)); t[2] = ((uint128_t) d0) * r2 + ((uint128_t) r1) * r1 + (((uint128_t) d4) * (r3 )); t[3] = ((uint128_t) d0) * r3 + ((uint128_t) d1) * r2 + (((uint128_t) r4) * (d419 )); t[4] = ((uint128_t) d0) * r4 + ((uint128_t) d1) * r3 + (((uint128_t) r2) * (r2 )); " } ``` 3. The `src/Specific/CurveParameters/remake_curves.sh` script holds a list of curves to be made, what directories they should end up living in, and it invokes `src/Specific/Framework/make_curve.py` to transform these files into outputs. The Python script fills in a few defaults (such as computing `s` and `c` from the modulus, if you don't pass them explicitly), and does a lot of processing on the C code that is pasted verbatim from donna to get it to be in the right format for Coq. This Python script creates the files: - `CurveParameters.v` (the Coq-ified version of the json file, which instantiates an appropriate module type); - `Synthesis.v`, which instantiates a `MakeSynthesisTactics` with the curve parameter modules, invokes a tactic from the applied module functor to synthesize all of the relevant non-reflective bits (basically, what used to live in @jadephilipoom 's `ArithmeticSynthesisTest.v`), and then instantiates another module functor `PackageSynthesis` which defines notations via tactics in terms to access the names of the various fields defined by the synthesis tactic; - any other files you ask it for, such as `compiler.sh`, `femul.v`, `femulDisplay.v`. All of the `*Display.v` files are simple, and all the the operation synthesis files have a single `Definition` (with the appropriate type), and solve the definition by invoking a single tactic defined in `PackageSynthesis`, e.g., `synthesize_mul` or `synthesize_ladderstep`.
* Remove outdated json file, reorder remake_curves.shGravatar Jason Gross2017-10-17
|
* Add more json filesGravatar Jason Gross2017-10-16
|
* Don't print ".0" for integer bases in the json filesGravatar Jason Gross2017-10-16
|
* bugfixes from messy rebase; remade json filesGravatar jadep2017-10-16
|
* Fix base generationGravatar Jason Gross2017-10-16
|
* Add more json filesGravatar Jason Gross2017-10-16
|
* Don't error if we can't open a fileGravatar Jason Gross2017-10-16
|
* Regenerate json filesGravatar Jason Gross2017-10-16
|
* Prettier json file generationGravatar Jason Gross2017-10-14
|
* Add generated json files from generate_parameters.pyGravatar Jason Gross2017-10-14
|
* Add curve-specific json filesGravatar Jason Gross2017-10-14
There are `.json` files in `src/Specific/CurveParameters/` that specify curve characteristics. A simple example is `x2555_130.json`, which is: ```json { "modulus" : "2^255-5", "base" : "130", "a24" : "121665 (* XXX TODO(andreser) FIXME? Is this right for this curve? *)", "sz" : "3", "bitwidth" : "128", "carry_chains" : "default", "coef_div_modulus" : "2", "operations" : ["ladderstep"] } ``` A more complicated example is `x25519_c64.json`: ```json { "modulus" : "2^255-19", "base" : "51", "a24" : "121665", "sz" : "5", "bitwidth" : "64", "carry_chains" : "default", "coef_div_modulus" : "2", "operations" : ["femul", "fesquare", "freeze", "ladderstep"], "extra_files" : ["X25519_C64/scalarmult.c"], "compiler" : "gcc -march=native -mtune=native -std=gnu11 -O3 -flto -fomit-frame-pointer -fwrapv -Wno-attributes", "mul_header" : "(* Micro-optimized form from curve25519-donna-c64 by Adam Langley (Google) and Daniel Bernstein. See <https://github.com/agl/curve25519-donna/blob/master/LICENSE.md>. *)", "mul_code" : " uint128_t t[5]; limb r0,r1,r2,r3,r4,s0,s1,s2,s3,s4,c; r0 = in[0]; r1 = in[1]; r2 = in[2]; r3 = in[3]; r4 = in[4]; s0 = in2[0]; s1 = in2[1]; s2 = in2[2]; s3 = in2[3]; s4 = in2[4]; t[0] = ((uint128_t) r0) * s0; t[1] = ((uint128_t) r0) * s1 + ((uint128_t) r1) * s0; t[2] = ((uint128_t) r0) * s2 + ((uint128_t) r2) * s0 + ((uint128_t) r1) * s1; t[3] = ((uint128_t) r0) * s3 + ((uint128_t) r3) * s0 + ((uint128_t) r1) * s2 + ((uint128_t) r2) * s1; t[4] = ((uint128_t) r0) * s4 + ((uint128_t) r4) * s0 + ((uint128_t) r3) * s1 + ((uint128_t) r1) * s3 + ((uint128_t) r2) * s2; r4 *= 19; r1 *= 19; r2 *= 19; r3 *= 19; t[0] += ((uint128_t) r4) * s1 + ((uint128_t) r1) * s4 + ((uint128_t) r2) * s3 + ((uint128_t) r3) * s2; t[1] += ((uint128_t) r4) * s2 + ((uint128_t) r2) * s4 + ((uint128_t) r3) * s3; t[2] += ((uint128_t) r4) * s3 + ((uint128_t) r3) * s4; t[3] += ((uint128_t) r4) * s4; ", "square_header" : "(* Micro-optimized form from curve25519-donna-c64 by Adam Langley (Google) and Daniel Bernstein. See <https://github.com/agl/curve25519-donna/blob/master/LICENSE.md>. *)", "square_code" : " uint128_t t[5]; limb r0,r1,r2,r3,r4,c; limb d0,d1,d2,d4,d419; r0 = in[0]; r1 = in[1]; r2 = in[2]; r3 = in[3]; r4 = in[4]; do { d0 = r0 * 2; d1 = r1 * 2; d2 = r2 * 2 * 19; d419 = r4 * 19; d4 = d419 * 2; t[0] = ((uint128_t) r0) * r0 + ((uint128_t) d4) * r1 + (((uint128_t) d2) * (r3 )); t[1] = ((uint128_t) d0) * r1 + ((uint128_t) d4) * r2 + (((uint128_t) r3) * (r3 * 19)); t[2] = ((uint128_t) d0) * r2 + ((uint128_t) r1) * r1 + (((uint128_t) d4) * (r3 )); t[3] = ((uint128_t) d0) * r3 + ((uint128_t) d1) * r2 + (((uint128_t) r4) * (d419 )); t[4] = ((uint128_t) d0) * r4 + ((uint128_t) d1) * r3 + (((uint128_t) r2) * (r2 )); " } ```