40 Commits

Author SHA1 Message Date
wborgeaud
301edf3ab5 Move clippy::eq_ip 2021-11-30 18:18:56 +01:00
wborgeaud
2c06309cf7 Fix all clippy lints 2021-11-30 17:12:13 +01:00
Jakub Nabaglo
549ce0d8e9
Interleaved batched multiplicative inverse (#371)
* Interleaved batched multiplicative inverse

* Minor: typo
2021-11-23 21:36:12 -08:00
Hamish Ivey-Law
8f59381c87
Faster modular inverse (#292)
* Working "faster" inverse algo, using u128s.

* Faster inverse_2exp for large exp.

* More inverse tests.

* Make f, g u64.

* Comments.

* Unroll first two iterations.

* Fix bug and re-unroll first two iterations.

* Simplify loop.

* Refactoring and documentation.

* Clean up testing.

* Move inverse code to inversion.rs; use in GoldilocksField.

* Bench quartic Goldilocks extension too.

* cargo fmt

* Add more documentation.

* Address Jakub's comments.
2021-10-10 10:39:02 +11:00
Nicholas Ward
f79419cca3 add check to primitive_root_order field arithmetic test 2021-10-06 09:50:02 -07:00
wborgeaud
c14673863a Add submodule for field extension tests 2021-09-15 18:22:26 +02:00
wborgeaud
5048a3f31d Minor 2021-09-15 10:05:41 +02:00
wborgeaud
1ca197840f Add a test_field_extension macro 2021-09-15 09:52:49 +02:00
Daniel Lubarov
3bc34c59d8
Refactor GMiMC code (#224)
* Refactor GMiMC code

Adds a sub-trait of `Field` called `GMiMCInterface`, which is similar to `PoseidonInterface`.

This lets us have different fields with different GMiMC constants in a type-safe way.

* Remove `Interface`

* Const generic for width
2021-09-07 18:28:28 -07:00
Daniel Lubarov
a2eaaceb34
Rework the field test code a bit (#225)
- Split it into two files, one for general `Field` tests and one for `PrimeField` tests.
- Replace most uses of `BigUint` in tests with `u64`. These uses were only applicable for `PrimeField`s, which are 64-bit fields anyway. This lets us delete the `BigUInt` conversion methods.
- Simplify `test_inputs`, which was originally written for large prime fields. Now that it's only used for 64-bit fields, I think interesting inputs are just the smallest and largest elements, and those close to 2^32 etc.
2021-09-07 14:17:15 -07:00
Daniel Lubarov
236a143abf
Move some Field members to a Field64 subtrait (#213)
* Move some Field members to a Field64 subtrait

I.e. move anything specific to 64-bit fields.

Also, relatedly,
- Tweak a bunch of prover code to require `Field64`, since 64-bit stuff is used in a couple places, like the FRI proof-of-work
- Remove `bits()`, which was unused and assumed a 64-bit field
- Rename a couple methods to reflect that they're u64 variants

There are no functional changes.

* Field64 -> PrimeField

* Remove `exp_u32`, `kth_root_u32`

* PrimeField: PrimeField

* Move `to_canonical_biguint` as well

* Add back from_noncanonical_u128
2021-09-05 10:27:11 -07:00
Jakub Nabaglo
a71966f6f5
Bugfix: Crandall field addition occasionally returns incorrect results (#203)
* Fix bug that causes Crandall field addition to yield incorrect results in rare circumstances

* Minor proof correction

* Daniel PR comment
2021-08-26 12:24:18 -07:00
Daniel Lubarov
018fb005f8
Move stuff around (#135)
No functional changes here. The biggest change was moving certain files into new directories like `plonk` and `iop` (for things like `Challenger` that could be used in STARKs or other IOPs). I also split a few files, renames, etc, but again nothing functional, so I don't think a careful review is necessary (just a sanity check).
2021-07-29 22:00:29 -07:00
Daniel Lubarov
e382decc9f Import fixes 2021-07-29 11:45:58 -07:00
Nicholas Ward
ff055b6466 cargo fmt 2021-07-22 13:27:40 -07:00
Nicholas Ward
3425bd0078 replaced some clones with refs 2021-07-22 13:26:38 -07:00
Nicholas Ward
57da32fb82 fixes to use references 2021-07-22 13:16:12 -07:00
Nicholas Ward
ffc90e902b exp_biguint test 2021-07-22 13:08:14 -07:00
Nicholas Ward
b6e74b8244 cargo fmt 2021-07-22 10:57:08 -07:00
Nicholas Ward
5d30124101 moved specific tests to prime_field_arithmetic 2021-07-22 10:56:20 -07:00
Nicholas Ward
292a28e6e3 fixed tests 2021-07-21 14:34:01 -07:00
Nicholas Ward
b17dabefeb more fixes 2021-07-21 14:27:30 -07:00
Nicholas Ward
ff56486189 compiles 2021-07-21 13:28:11 -07:00
Nicholas Ward
164bb7f5ca fixes 2021-07-21 13:23:50 -07:00
Nicholas Ward
7f92a33964 cargo fmt 2021-07-21 13:05:40 -07:00
Nicholas Ward
1dd850b0e5 fixes 2021-07-21 13:05:32 -07:00
Nicholas Ward
b103c0774f progress 2021-07-20 15:42:27 -07:00
Nicholas Ward
8de59c2a84 cargo fmt 2021-06-30 21:59:18 -07:00
Hamish Ivey-Law
574a3d4847
FFT improvements (#81)
* Use built-in `reverse_bits`; remove duplicate `reverse_index_bits`.

* Reduce precomputation time/space complexity from quadratic to linear.

* Several working cache-friendly FFTs.

* Fix to allow FFT of constant polynomial.

* Simplify FFT strategy choice.

* Add PrimeField and CHARACTERISTIC properties to Fields.

* Add faster method for inverse of 2^m.

* Pre-compute some of the roots; tidy up loop iteration.

* Precomputation for both FFT variants.

* Refactor precomputation; add optional parameters; rename some things.

* Unrolled version with zero tail.

* Iterative version of Unrolled precomputation.

* Test zero tail algo.

* Restore default degree.

* Address comments from @dlubarov and @wborgeaud.
2021-07-01 14:55:41 +10:00
Daniel Lubarov
f929f94626
Have rustfmt group imports (#60)
* Have rustfmt group imports

See `rustfmt.toml`; the rest is automated changes.

* fmt
2021-06-10 14:10:35 -07:00
wborgeaud
78f71672a3 Change Field::exp to using a u64 power. 2021-05-19 12:17:43 +02:00
wborgeaud
20dae028d8 fix subtraction 2021-05-04 17:57:59 +02:00
Daniel Lubarov
110a7bc6d9 Fill in a few missing field methods 2021-04-25 18:09:43 -07:00
Daniel Lubarov
84a71c9ca5 A few more tests, ported (with some adaptations) from plonky1 2021-04-22 21:51:40 -07:00
wborgeaud
6b407e45ef Progress on FRI 2021-04-21 22:31:45 +02:00
Daniel Lubarov
5fe8d633b6 Split main into multiple binaries
... and other minor refactoring.

`bench_recursion` will be the default bin run by `cargo run`; the otheres can be selected with the `--bin` flag.

We could probably delete some of the other binaries later. E.g. `field_search` might not be useful any more. `bench_fft` should maybe be converted to a benchmark (although there are some pros and cons, e.g. the bench framework has a minimum number of runs, and isn't helpful in testing multi-core performance).
2021-04-06 13:23:47 -07:00
Daniel Lubarov
facbe117fb Move some stuff into Field 2021-04-02 19:04:26 -07:00
Daniel Lubarov
78860cc3db Final fixes 2021-04-02 18:29:33 -07:00
Daniel Lubarov
285ec16599 Fix neg 2021-04-02 18:12:44 -07:00
Daniel Lubarov
c25c689ef0 More tests, ported from plonky1 2021-04-02 17:49:57 -07:00