1199 Commits

Author SHA1 Message Date
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
c9d884f740 Change tests for quartic extension 2021-09-15 09:55:38 +02:00
wborgeaud
1ca197840f Add a test_field_extension macro 2021-09-15 09:52:49 +02:00
wborgeaud
d9978b5897 Remove unused 2021-09-15 09:38:25 +02:00
wborgeaud
80af66c87b Test quadratic extensions of Crandall and Goldilocks 2021-09-15 09:36:56 +02:00
wborgeaud
dc4062cde7 Add quadratic and quartic extensions to Goldilocks 2021-09-15 09:10:18 +02:00
Jakub Nabaglo
a7cd1ef40b
Vectorize Poseidon constant layer with NEON (#245)
* Start work on Crandall arithmetic in NEON

* Poseidon constant layer in NEON

* its alive

Co-authored-by: Jakub Nabaglo <jakub@mirprotocol.org>
2021-09-14 21:37:07 -07:00
Jakub Nabaglo
b411a275f9
AVX2 vectorization of Poseidon S-box (#244)
* AVX2 vectorization of Poseidon S-box

* Minor doc

* Microoptimization
2021-09-14 19:26:31 -07:00
Jakub Nabaglo
2ae9e34993
AVX2 vectorization of Poseidon constant layer (#243)
* AVX2 vectorization of Poseidon constant layer

* Silence unused import warning + minor style

* Daniel comment
2021-09-13 21:18:18 -07:00
Jakub Nabaglo
b0f244f1ee
Vectorize Goldilocks with AVX2 (#241)
* Start work on vectorized Goldilocks

* Vectorized Goldilocks

* Unused import warning
2021-09-13 17:42:25 -07:00
Daniel Lubarov
b3008b9475
Some changes to generator_indices_by_watches (#234)
* Some changes to generator_indices_by_watches

- Index generators by the representatives (in disjoint-set forest terminology) of their watched targets, rather than the watched targets themselves.  Enqueuing generators based on their watch lists then works correctly, so we no longer need the step where we reenqueue all generators.
- In #195, it was pointed out that this slows down witness generation a bit. I moved the indexing code to preprocessing, so the prover is a bit faster (~7ms for me).

* Outdated comment

* Panic instead of infinite loop if we get stuck

* BTree

* fmt
2021-09-13 16:38:55 -07:00
Jakub Nabaglo
de1d5d0ad2
Minor: fix a few warnings (#239)
* Minor: fix a few warnings

* Lints
2021-09-13 15:42:59 -07:00
Jakub Nabaglo
9ef784a99d
Poseidon: vectorized MDS matrix multiplication (NEON) (#231)
* Port of AVX2 MDS impl

* Bugfixes

* Inline ASM to the rescue

* remove debug printsln + minor formatting

* Work around NEON intrinsic bug without inline ASM

* Minor error in doc

* Daniel comments

* More Daniel comments

Co-authored-by: Jakub Nabaglo <jakub@mirprotocol.org>
2021-09-13 12:36:06 -07:00
Jakub Nabaglo
6465e35e1f
Poseidon: vectorized MDS matrix multiplication (AVX2) (#229)
* Poseidon: vectorized MDS matrix multiplication

* Lints

* This is a bit cleaner

* More cleanup

* Width 12

* Replace the unaligned load trick with something nicer

* Simplify conversion between CrandallField and u64

* Make things more concise with const generics

* Minor documentation

* Minor: unused import

* Daniel comments + consistency with #230 + errors in docs

* Remove dependence on feature(stdsimd)

* Daniel comments
2021-09-13 11:46:36 -07:00
Daniel Lubarov
91f7b4e300
Replace CrandallQuarticField with a more generic QuarticExtension (#232)
* Replace `CrandallQuarticField` with a more generic `QuarticExtension`

And likewise for `CrandallQuadraticField`.

There are a few parameters which we can't automatically derive (in const Rust), so I specified them in a `AutoExtendable` trait.

This would make it fairly easy to add extension fields for `GoldilocksField` and any future fields.

* Attempt to derive 2-adicity, see Hamish's feedback

* Simplify TWO_ADICITY based on chat with Hamish

* PR feedback

* Merge AutoExtendable into Extendable (#235)
2021-09-13 11:45:17 -07:00
Daniel Lubarov
c76eb9ddeb
Prepare for the switch to Poseidon (#228)
* Prepare for the switch to Poseidon

Everything will now select a permutation based on the `PERMUTATION_FAMILY` const.

The `Poseidon` variant won't work quite yet since the gate isn't in place; I left that as a `todo!()`

* fix
2021-09-13 10:22:25 -07:00
Daniel Lubarov
7ffeba3ae4 Delete my old MDS code, now obsolete 2021-09-12 18:29:07 -07:00
Jakub Nabaglo
a8d08aa153
Vectorized FFT (#223)
* Vectorized FFT

* Cleanup

* Use updated FieldPacking

* Use to_vec/from_slice (+ typo)

* Cleanup + Daniel's comments
2021-09-12 16:54:25 -07:00
Jakub Nabaglo
bdd86a306f
Crandall squaring in AVX2 (#233) 2021-09-11 17:47:17 -07:00
Jakub Nabaglo
c0e8edb899
Non-vector Poseidon speedups (#230) 2021-09-11 11:25:20 -07:00
Daniel Lubarov
ba8b40f0e6
Goldilocks field (#227)
* Goldilocks field

Based on Hamish's old branch, but I updated it with a few missing things like generators.

Pulled the inversion code into a shared helper method to avoid redundancy.

Just the base field for now. We can add a quartic extension field later.

* typo

* PR feedback

* More overflowing -> wrapping

* fmt

* cleanup
2021-09-10 10:39:27 -07:00
Jakub Nabaglo
e50d79a347 Tweaks to CrandallField::product 2021-09-08 17:15:56 -07:00
Jakub Nabaglo
3674ceb571 Lints 2021-09-08 12:15:25 -07:00
Jakub Nabaglo
db3171bb81 Conversion to/from statically-sized arrays 2021-09-08 12:15:25 -07:00
Jakub Nabaglo
5d69d85d42 Daniel PR comments + delete throughput figures 2021-09-08 12:15:25 -07:00
Jakub Nabaglo
87f5201e6f Style (incl. Daniel PR comments) 2021-09-08 12:15:25 -07:00
Jakub Nabaglo
7ee7d8bf8a Crandall arithmetic in AVX2 2021-09-08 12:15:25 -07: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
Nicholas Ward
50274883c7
Merge pull request #217 from mir-protocol/permutation
Permutation network code
2021-09-06 21:39:10 -07:00
Nicholas Ward
effcc967d0 fmt 2021-09-06 21:39:00 -07:00
Nicholas Ward
c07f99ac81 merge 2021-09-06 21:38:52 -07:00
Daniel Lubarov
676c244de7 Unused field 2021-09-06 17:01:15 -07:00
Nicholas Ward
1818e69ce3 addressed comments 2021-09-06 08:38:47 -07:00
Daniel Lubarov
a42bec0354 cargo fix 2021-09-05 22:36:10 -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
Nicholas Ward
0e24719908 fixes 2021-09-04 22:31:12 -07:00
Nicholas Ward
6f885db677 fixes 2021-09-04 16:44:49 -07:00
Nicholas Ward
1fb7eeb03e variable-sized tests 2021-09-04 16:29:33 -07:00
Nicholas Ward
4c3f3cda39 6x6 test 2021-09-04 16:29:33 -07:00
Nicholas Ward
4f7a587bfa fix for non-2x2 permutation case 2021-09-04 16:29:32 -07:00
Nicholas Ward
f01d373d1e made switch_bool wires routeable 2021-09-04 16:28:10 -07:00
Nicholas Ward
7acdf976c1 fixed fill_switch_gates 2021-09-04 16:28:07 -07:00
Daniel Lubarov
f89f49249a wip 2021-09-04 16:27:40 -07:00
Daniel Lubarov
ba4b03e487
Unroll a couple loops in Poseidon code (#215)
* Unroll a couple loops in Poseidon code (super hacky)

* Comments
2021-09-03 21:42:40 -07:00
Nicholas Ward
d1fea5cfd3 witnessgenerator 2021-09-03 18:07:51 -07:00
Nicholas Ward
10d016a92c chunk size as field 2021-09-03 18:07:21 -07:00
Nicholas Ward
3ad0365967 fixed infinite loop 2021-09-03 18:07:21 -07:00
Nicholas Ward
3494839227 removed more to_vec calls (within maps) 2021-09-03 18:07:21 -07:00