72 Commits

Author SHA1 Message Date
wborgeaud
9503bb22f4 Take config by reference to avoid clone 2021-10-18 11:11:48 +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
Nicholas Ward
c07f99ac81 merge 2021-09-06 21:38:52 -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
b0a855a9c3 progress on permutation 2021-09-03 18:07:20 -07:00
wborgeaud
69a945547a route, assert_equal -> connect 2021-08-24 08:25:11 +02:00
Daniel Lubarov
69193a8dc2
Remove *_three methods (#182)
* Remove *_three methods

Since there's no longer a performance reason for them, and I think the *_many methods are about as short etc.

* PR feedback
2021-08-17 00:38:41 -07:00
wborgeaud
b366482866 The mother of all arithmetic optimizations 2021-08-16 10:18:10 +02:00
Daniel Lubarov
f3bfd66657
Add a BoolTarget (#179)
It's just a wrapper around `Target`, which signifies that the wrapped `Target` has already been range checked. Should make it easier to audit code that expects bools.
2021-08-14 08:53:39 -07:00
Daniel Lubarov
090cf79787
Replace some old division code (#171)
- Delete unsafe methods
- Have related methods call the new div_add_extension method to simplify
2021-08-10 11:48:53 -07:00
wborgeaud
417e6055ae Optimize coset in compute_evaluation 2021-08-09 13:21:42 +02:00
Daniel Lubarov
7b20f342df
More eval_unfiltered_recursively tweaks (#156) 2021-08-05 08:03:49 -07:00
Daniel Lubarov
079baff718
Optimize some exp methods to use ExponentiationGate (#151) 2021-08-04 09:55:29 -07:00
wborgeaud
fc9d64defe Small nits for the exponentiation gate 2021-08-02 13:12:50 +02:00
Daniel Lubarov
50b07f2ceb
Special cases for extension field arithmetic (#138)
We previously checked for special cases, like arithmetic on constant Targets, in `arithmetic`. We can handle those cases without actually adding an `ArithmeticGate`.

Now that `arithmetic` just calls `arithmetic_extension`, it makes more sense to check for special cases in the latter method, so it applies to both base and extension field arithmetic.

Reduces gate count from 16149 to 15689.
2021-07-30 09:03:11 -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
Nicholas Ward
8440a4cbdf fix 2021-07-29 15:15:40 -07:00
Nicholas Ward
cfda56e3d3 Merge branch 'main' into exp_gate_config 2021-07-29 14:19:24 -07:00
Nicholas Ward
a111fc3164 fixes 2021-07-29 14:18:18 -07:00
Nicholas Ward
95503ff7fa Merge branch 'main' into exp_gate_config 2021-07-29 14:10:35 -07:00
Nicholas Ward
e46bd08f00 exponention gate takes only bits 2021-07-29 12:59:11 -07:00
Nicholas Ward
56b62f1964 new exp gate takes in CircuitConfig and determines num_bits 2021-07-29 10:26:46 -07:00
Nicholas Ward
fa06cc5509 fix 2021-07-28 17:37:26 -07:00
Nicholas Ward
17217f1143 addressed nit 2021-07-28 17:34:41 -07:00
Nicholas Ward
2fd9ce2114 fixes to exp functions 2021-07-28 13:38:41 -07:00
Nicholas Ward
247fa39386 exponentiation gadget 2021-07-28 10:56:12 -07:00
wborgeaud
f325586beb Replace exp_from_complement_bits with simpler method 2021-07-23 14:58:41 +02:00
wborgeaud
6f8053cc37 Forgot to exponentiate from bits in computation of subgroup_x. Saves 80 gates. 2021-07-23 08:53:00 +02:00
wborgeaud
a70e97befc Fix merge issues 2021-07-23 08:21:55 +02:00
wborgeaud
9a1c289f8e Merge branch 'main' into remove_acc_in_gmimc
# Conflicts:
#	src/gadgets/arithmetic.rs
2021-07-23 08:16:23 +02:00
wborgeaud
47b9936487 PR feedback 2021-07-23 08:15:13 +02:00
wborgeaud
0541956942 Remove useless clone 2021-07-22 16:22:23 +02:00
wborgeaud
1d92191227 Make exp_complement_bits take an iterator to avoid cloning. 2021-07-22 16:18:13 +02:00
wborgeaud
b65e792ff3 - Remove useless rotation gadgets
- rotate.rs -> select.rs
- Added `select()` and `select_ext`
- Optimize to use just one gate
2021-07-22 11:58:29 +02:00
wborgeaud
be2e870aee PR feedback 2021-07-22 06:50:07 +02:00
wborgeaud
db0121d74a Update comment 2021-07-21 20:38:23 +02:00
wborgeaud
a54a4e5830 Merge branch 'main' into avoid_rotating 2021-07-21 20:02:22 +02:00
wborgeaud
59494ff8d1 Merge branch 'main' into optimize_mul_many
# Conflicts:
#	src/gates/arithmetic.rs
2021-07-21 17:47:38 +02:00
wborgeaud
6e305f0a3e Change {add|mul}_many and cube 2021-07-21 17:41:22 +02:00
Daniel Lubarov
ac1872a8c8
FRI tweaks (#111)
- Call `exp_power_of_2` instead of manual squaring
- Replace `evaluations[i]` with `evals`
2021-07-20 12:49:02 -07:00
wborgeaud
925c0bcb5c Replace rotation with exp in compute_evaluation 2021-07-20 15:25:03 +02:00
Daniel Lubarov
9c17a00c00
Division related changes (#99)
* Division related changes

- Simplify `div_unsafe_extension` using virtual targets
- Add methods for inversion and safe division

As a followup I'll switch some calls to safe division.

* Test safe division also

* add_virtual_extension_target
2021-07-18 23:05:57 -07:00
Daniel Lubarov
519533d4b7
Benchmark tweaks (#83)
- Configure FRI with a list of arities that's more appropriate for a 2^14 instance. The previous config resulted in a huge final polynomial.
- Log the blinding factors, and other logging tweaks.
2021-07-01 10:53:42 -07:00
wborgeaud
2f06a78cb1 Simplify exp_u64 2021-06-25 16:53:11 +02:00
wborgeaud
42db0a31c1 Clippy 2021-06-25 16:49:29 +02:00
wborgeaud
fc4738869d Rearrange files 2021-06-25 16:45:02 +02:00
wborgeaud
b62c2e6990 Supplant ArithmeticGate with ArithmeticExtensionGate 2021-06-25 16:31:10 +02:00
wborgeaud
8a119f035d Working ReducingFactorTarget 2021-06-25 16:27:20 +02:00
wborgeaud
beadce72fc Add ZeroOutGenerator 2021-06-25 15:11:49 +02:00
wborgeaud
6652b38b99 Remove ArithmeticGate 2021-06-25 13:53:14 +02:00