408 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
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
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
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
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
e39af10a6b
More wires for ConstantGate (#332)
* More wires for ConstantGate

* fix

* fix
2021-11-02 14:41:12 -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
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
806641d13f
Small optimizations (#319)
* Small optimizations

* Small optimizations

* feedback

* inline

* feedback

* fix unused import
2021-10-22 19:11:05 -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
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
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
wborgeaud
019ccf537b
Merge pull request #309 from mir-protocol/use_quadratic_extension
Generalize `RandomAccessGate` to allow using quadratic field extensions
2021-10-18 22:00:04 +02:00
wborgeaud
e24285c3b0 Separate random access generators 2021-10-18 21:48:40 +02:00
wborgeaud
5f4a244240 PR feedback 2021-10-18 21:38:57 +02:00
wborgeaud
c7674b24ba Unused imports 2021-10-18 17:27:22 +02:00
wborgeaud
dda14011c5 Forgot a random access check 2021-10-18 17:23:39 +02:00
wborgeaud
5b81006e9a Fill random access gates to make sure all generators are run 2021-10-18 17:11:59 +02:00
wborgeaud
3f0b5ab9d3 Keep track of the last used RAM gate 2021-10-18 16:48:21 +02:00
wborgeaud
a35cd98b03 New random access gadget 2021-10-18 15:45:52 +02:00
wborgeaud
104fd08e72 Working RAM gate 2021-10-18 15:19:09 +02:00
wborgeaud
9503bb22f4 Take config by reference to avoid clone 2021-10-18 11:11:48 +02:00
wborgeaud
00ce9d9f25 Add num_copies to RAM gate 2021-10-18 11:07:18 +02:00
Daniel Lubarov
5098c2a386
Have ArithmeticExtensionGate adapt based on available wires (#287) 2021-10-05 23:28:29 -07:00
Daniel Lubarov
b922def48e
Better errors for insufficient (routed) wires for FRI (#288)
For examlpe, if I change a test to use `ConstantArityBits(4, 5)`, I get

    To efficiently perform FRI checks with an arity of 16, at least 152 wires are needed. Consider reducing arity.
2021-10-05 23:28:04 -07:00
wborgeaud
242ee26b6f Generalize to fields with less than 64 bits 2021-10-05 17:50:38 +02:00
wborgeaud
6d601c6113 Overflow fixes 2021-10-05 14:27:30 +02:00
Daniel Lubarov
9d8b32c355 fmt 2021-10-03 22:59:10 -07:00
Daniel Lubarov
734a5cef27 Snake case warning 2021-10-03 22:25:07 -07:00
Daniel Lubarov
dadc1b2add cargo fix 2021-10-03 22:22:10 -07:00
Nicholas Ward
04aaa172b2
Merge pull request #275 from mir-protocol/arithmetic_u32
U32ArithmeticGate
2021-09-30 14:44:24 -07:00
Nicholas Ward
094f29a1a7 set 0 limb targets 2021-09-30 14:37:23 -07:00
Nicholas Ward
1af224d895 Horner's method 2021-09-30 10:17:51 -07:00
Nicholas Ward
ffd069c6ce fmt 2021-09-30 10:13:33 -07:00
Nicholas Ward
6e21528ad0 constraints test, and fixes 2021-09-30 10:13:28 -07:00
Nicholas Ward
3d207464f5 combine halves separately 2021-09-29 20:04:42 -07:00
Nicholas Ward
862eee8e70 fix 2021-09-29 16:33:34 -07:00
Nicholas Ward
455bc4d553 only 3 copies :( 2021-09-29 15:35:36 -07:00
Nicholas Ward
0811279fb7 range check outputs, and addressed comments 2021-09-29 14:45:14 -07:00
Daniel Lubarov
3f22663296
Split up PartitionWitness data (#273)
* Split up `PartitionWitness` data

This addresses two minor inefficiencies:
- Some preprocessed forest data was being cloned during proving.
- Some of the `ForestNode` data (like node sizes) is only needed in preprocessing, not proving. It was taking up cache space during proving because it was interleaved with data that is used during proving (parents, values).

Now `Forest` contains the disjoint-set forest. `PartitionWitness` is now mainly a Vec of target values; it also holds a reference to the (preprocessed) representative map.

On my laptop, this speeds up witness generation ~12%, resulting in an overall ~0.5% speedup.

* Feedback

* No size data (#278)

* No size data

* feedback
2021-09-28 22:31:20 -07:00
Nicholas Ward
932cc812ab U32ArithmeticGate 2021-09-28 17:03:35 -07:00
Daniel Lubarov
bd38ada0d1 Change case to get rid of warning 2021-09-27 22:39:42 -07:00
wborgeaud
1a508d0c19
Merge pull request #270 from mir-protocol/poseidon_8
Use `SPONGE_WIDTH` instead of hardcoded values in various places
2021-09-27 12:55:46 +02:00