1247 Commits

Author SHA1 Message Date
wborgeaud
0f06a01ac1 Merge conflicts 2021-11-08 10:49:14 +01:00
wborgeaud
c406432814 Merge branch 'main' into generic_configuration
# Conflicts:
#	src/gadgets/arithmetic.rs
#	src/gadgets/interpolation.rs
#	src/gates/interpolation.rs
2021-11-08 10:35:29 +01:00
wborgeaud
5f7992f0ea Minor 2021-11-08 10:30:08 +01:00
Daniel Lubarov
b2264752de
Optimize combination of gate constraints in recursive circuit (#342)
Just passing the "combined constraints" buffer into `eval_filtered_recursively`, so that we can combine a mul by the filter with an add into the buffer. Saves 56 wires.
2021-11-07 11:29:15 -08:00
Daniel Lubarov
e9ae9a045f import 2021-11-05 21:36:33 -07:00
Daniel Lubarov
671bb9be2e
Specialize InterpolationGate (#339)
* Specialize `InterpolationGate`

To cosets of subgroups of roots of unity. This way
- `InterpolationGate` needs fewer routed wires, bringing our minimum routed wires down from 28 to 25.
- The recursive `compute_evaluation` avoids some multiplications, saving 100~200 gates depending on `num_routed_wires`.

* Update test

* feedback
2021-11-05 09:29:08 -07:00
Daniel Lubarov
75fe5686a2
Better fixed-base exponentiation and exp_power_of_2 (#340)
Saves 84 gates with `num_routed_wires: 48`.
2021-11-05 09:10:46 -07:00
wborgeaud
c78d7611ed Unused imports 2021-11-05 16:47:29 +01:00
wborgeaud
7482e7b613 Remove RichField 2021-11-05 15:43:58 +01:00
wborgeaud
3d74abba8a [skip-ci]Clippy 2021-11-05 15:31:24 +01:00
wborgeaud
b83f29cca2 Comments and cleaning 2021-11-05 15:22:52 +01:00
wborgeaud
d4c8caa208 Use generic hasher in Challenger 2021-11-05 12:02:33 +01:00
wborgeaud
943e1f4b0f Minor 2021-11-05 11:40:38 +01:00
wborgeaud
fb18232efd Generic config 2021-11-05 10:56:23 +01:00
Daniel Lubarov
1450ffb29c
Small recursion optimizations (#338)
* Small recursion optimizations

Main thing is memoizing arithmetic operations. Overall savings is ~50 gates.

* feedback
2021-11-04 16:23:01 -07:00
Daniel Lubarov
fdce382af3
Standard configs (#337)
`large_config` was similar to `standard_recursion_config`; let's standardize on the latter.
2021-11-03 14:30:32 -07:00
Daniel Lubarov
fb3f5e7db8
Shrink further with another couple layers of recursion (#335)
* More wires for ConstantGate

* fix

* fix

* Optimize recursive Poseidon constraint evaluation

- Avoid `ArithmeticGate`s with unique constants; use `ConstantGate` wires instead
- Avoid an unnecessary squaring in exponentiations

Brings Poseidon evaluation down to a reasonable 273 gates when `num_routed_wires = 48`.

* Shrink further with another couple layers of recursion

To keep it reasonably fast, we shrink to degree 2^12 before we start using a really high rate. Each layer is reasonably quick this way; overall time is ~20s for me.

Final proof is now 52-54kb. It can go down to ~51kb if we add one more layer with `num_routed_wires: 28` (vs 32), but I feel like I may be overcomplicating this already...
2021-11-02 14:43:07 -07:00
Daniel Lubarov
c8e043a53f
Optimize recursive Poseidon constraint evaluation (#333)
* More wires for ConstantGate

* fix

* fix

* Optimize recursive Poseidon constraint evaluation

- Avoid `ArithmeticGate`s with unique constants; use `ConstantGate` wires instead
- Avoid an unnecessary squaring in exponentiations

Brings Poseidon evaluation down to a reasonable 273 gates when `num_routed_wires = 48`.
2021-11-02 14:42:30 -07:00
Daniel Lubarov
e39af10a6b
More wires for ConstantGate (#332)
* More wires for ConstantGate

* fix

* fix
2021-11-02 14:41:12 -07:00
Daniel Lubarov
bae26e09c2
D=2 in recursion test (#336) 2021-11-02 12:38:46 -07:00
Jakub Nabaglo
184f73c604
Expose optimized Poseidon routines to the Poseidon gate (ARM) (#331)
* Expose optimized Poseidon routines to the Poseidon gate

* Daniel PR comments
2021-11-02 12:38:30 -07:00
Jakub Nabaglo
bc57a561e6 Delete CrandallField 2021-11-02 12:29:26 -07:00
Daniel Lubarov
c6f91148d5
PoseidonMdsGate (#330)
PoseidonGate's recursive evaluations were using a lot of gates, and the MDS layer was the main culprit.

The other issue is that `constant_layer_recursive` creates a bunch of `ArithmeticGate`s with unique constants. We could either change `ArithmeticGate` to support different constants per operation, or wire in constants from `ConstantGate`, and change `ConstantGate` to support several constants per gate.

This won't really help anything near term since we're still between 2^12 and 2^13, but could have some benefits later, depending on what recursion arities and security settings we end up using.

`PoseidonMdsGate` needs `2 * D * WIDTH = 48` routed wires, and the combination of adding a gate and increasing routed wires slows down the prover a bit. So for now, I kept it at 28 wires, and the old code path is still used.
2021-11-02 08:16:28 -07:00
Daniel Lubarov
caf95ae9dc fmt 2021-11-01 21:50:42 -07:00
Daniel Lubarov
eb76bc5f67 cargo fix 2021-11-01 21:42:29 -07:00
Jakub Nabaglo
31fda351c1
Expose vectorized Poseidon layers for use in gate evaluation (#329) 2021-11-01 16:20:29 -07:00
Jakub Nabaglo
2bc745946b
Docs (minor): ARM Poseidon explanation fixes (#328) 2021-11-01 12:34:11 -07:00
Jakub Nabaglo
9bbbcf783a
Static asserts: check ARM Poseidon constants (#327) 2021-11-01 12:34:03 -07:00
Jakub Nabaglo
06e48d0b61
ARM-optimized Goldilocks Poseidon (#294)
* Optimized Poseidon for ARM

* Hamish comments

* Unused things
2021-10-30 14:32:39 -07:00
Jakub Nabaglo
8a5419d461
Static asserts in x86 Poseidon (#325)
* Static asserts in x86 Poseidon

* Minor style
2021-10-30 13:10:59 -07:00
Jakub Nabaglo
f286925eaa
Add .DS_Store to .gitignore (#324) 2021-10-27 10:44:36 -07:00
Jakub Nabaglo
7d39074e61
Minor optimizations to addition (#323) 2021-10-26 18:05:52 -07:00
Jakub Nabaglo
bf421314f9
Batched eval_vanishing_poly_base (#317)
* Batched eval_vanishing_poly_base

* Reduce the number of allocations

* Lints

* Delete unused things

* Minor: fix a debug_assert

* Daniel PR comments

* Lints

* Daniel PR comments
2021-10-25 13:23:05 -07:00
Daniel Lubarov
f616d6436d
Print overall gate counts (#322) 2021-10-25 09:12:42 -07:00
Jakub Nabaglo
7a8e12b8f4
Profile-guided optimization script (#321) 2021-10-23 11:55:49 -07:00
Daniel Lubarov
806641d13f
Small optimizations (#319)
* Small optimizations

* Small optimizations

* feedback

* inline

* feedback

* fix unused import
2021-10-22 19:11:05 -07:00
Jakub Nabaglo
db23416b04
Goldilocks: better constant propagation through add_with_wraparound (#320) 2021-10-22 15:02:22 -07:00
Hamish Ivey-Law
c406f464b8
Faster squaring in extension fields (#318)
* Faster squaring for extension fields; use in cube().

* Add squaring to arithmetic benchmark.

* Rename variable to remove warning; adjust comment.

* Inline always (improves latency measurements a lot).
2021-10-22 16:05:00 +11:00
Jakub Nabaglo
001c979599
AVX2: Fold the constant layer into MDS matrix multiplication (#302)
* Fuse constant layer with MDS matrix multiplication

* Warnings and lints

* Minor documentation
2021-10-21 16:51:06 -07:00
Daniel Lubarov
7d45c80c03
Have eval_unfiltered_base call the normal Poseidon methods (#316)
* Have eval_unfiltered_base call the normal Poseidon methods

* fmt
2021-10-21 14:28:07 -07:00
Daniel Lubarov
b0b2a10da0
Only log timing for the final proof in recursion tests (#315)
* Only log timing for the final proof in recursion tests

Just to reduce noise; the performance of the final proof is most meaningful

* fmt
2021-10-21 14:22:22 -07:00
wborgeaud
6463e4f4e7
Merge pull request #314 from mir-protocol/remove_basesum_gates
Ensure only one `BaseSumGate` is instantiated
2021-10-21 16:51:26 +02:00
wborgeaud
1f1827dae7 Clippy 2021-10-21 14:36:36 +02:00
wborgeaud
318185d1c0 Use only one BaseSumGate 2021-10-21 12:56:02 +02:00
wborgeaud
bf6d0266d5
Merge pull request #313 from mir-protocol/arithmetic_params_order
Change parameters order in `CircuitBuilder::arithmetic`
2021-10-21 09:41:53 +02:00
wborgeaud
1d2ae77eea Change parameters order in CircuitBuilder::arithmetic 2021-10-21 08:56:30 +02:00
Daniel Lubarov
22ce2da9e1
Add add_const, mul_const, mul_const_add methods (#312)
* Add mul_const, mul_const_add methods

To replace some arithmetic calls; I think it's easier to read.

* One more

* Couple more

* tweak

* tweak
2021-10-20 23:43:52 -07:00
Daniel Lubarov
0b75b24c09
Have split_low_high use range_check (#311) 2021-10-20 23:43:35 -07:00
Daniel Lubarov
cd13a3be65 Update bimap 2021-10-19 19:35:10 -07:00
Daniel Lubarov
64cd2e5686
2 challenges, 28 routed wires (#310)
* 2 challenges, 28 routed wires

2 challenges gives certain checks approximately (field_bits - degree_bits) * 2 bits of security, so we maintain our target of 100 bits for circuits with 2^14 gates or fewer.

28 routed wires is the min for `InterpolationGate`. A lower number helps reduce proof sizes. We can go back to a high number if there's any strong reason to reduce our gate count (e.g. if we were trying to hit 2^12).

* Check FRI conjectured security

* Fix
2021-10-19 12:38:20 -07:00