189 Commits

Author SHA1 Message Date
Daniel Lubarov
9aafa447f8
Fix stack overflows due to recursion in Forest::find (#358) 2021-11-15 10:11:16 -08:00
Daniel Lubarov
640997639a
Rename z_gz -> z_gx (#359)
Elsewhere we refer to the point we're evaluating at as `x`
2021-11-15 10:10:19 -08:00
Daniel Lubarov
07d03465b1
Verify that non-canonical splits are OK (#357)
The effect on soundness error is negligible for our current field, but this introduces an assertion that could fail if we changed to a field with more elements in the "ambiguous" range.
2021-11-15 10:03:13 -08:00
Daniel Lubarov
efab3177ce
Have le_sum use arithmetic ops if it's cheaper (#362)
* Have le_sum use arithmetic ops if it's cheaper

* fmt
2021-11-15 09:55:06 -08:00
Daniel Lubarov
7185c2d7d2
Fix & cleanup partial products (#355)
My previous change introduced a bug -- when `num_routed_wires` was a multiple of 8, the partial products "consumed" all `num_routed_wires` terms, whereas we actually want to leave 8 terms for the final product.

This also changes `check_partial_products` to include the final product constraint, and merges `vanishing_v_shift_terms` into `vanishing_partial_products_terms`. I think this is natural since `Z(x)`, partial products, and `Z(g x)` are all part of the product accumulator chain.
2021-11-14 11:58:44 -08:00
Daniel Lubarov
26a222bbdf
Fewer wires in PoseidonGate (#356)
Closes #345.
2021-11-14 11:57:36 -08:00
Daniel Lubarov
857b74bac5
Bring back the base field arithmetic gate (#343)
* Bring back the base field arithmetic gate

* fix
2021-11-12 09:48:27 -08:00
wborgeaud
a48eb2f81d
Merge pull request #346 from mir-protocol/partial_product_chain
Use chain structure to compute partial products
2021-11-12 09:39:17 +01:00
wborgeaud
21d3b127e3 Cargo fmt 2021-11-12 09:15:37 +01:00
Daniel Lubarov
9139d1350a
Minor refactor of partial product code (#351) 2021-11-11 07:16:16 -08:00
Nicholas Ward
bd427cd629 fixed failing tests 2021-11-10 12:10:32 -08:00
Nicholas Ward
ea4f950d6e fixes and fmt 2021-11-10 10:54:35 -08:00
Nicholas Ward
cf3b6df0e4 addressed nits 2021-11-10 09:58:16 -08:00
Nicholas Ward
2d9f8d9719 fix 2021-11-10 09:58:16 -08:00
Nicholas Ward
90178b2b0a many fixes 2021-11-10 09:58:15 -08:00
Nicholas Ward
1402791139 merge 2021-11-10 09:58:14 -08:00
Nicholas Ward
b567cf9baf some more BigUint arithmetic 2021-11-10 09:57:32 -08:00
Nicholas Ward
b2b7cb3931 merge 2021-11-10 09:57:32 -08:00
Nicholas Ward
97f66b58f5 merge 2021-11-10 09:56:42 -08:00
Nicholas Ward
18567e570b merge 2021-11-10 09:56:21 -08:00
Nicholas Ward
912204d685 merge 2021-11-10 09:53:27 -08:00
Nicholas Ward
8440a0f5cb merge 2021-11-10 09:53:09 -08:00
wborgeaud
3084367133 Start accumulator at Z(x) 2021-11-10 18:36:35 +01:00
wborgeaud
32f09ac2df Remove quotients and work directly with numerators and denominators in partial products check 2021-11-10 18:13:27 +01:00
Nicholas Ward
d334a924b4 merge new circuit builder stuff 2021-11-09 18:10:47 -08:00
wborgeaud
3717ff701e Minor 2021-11-09 17:33:14 +01:00
wborgeaud
067f81e24f Comments and cleaning 2021-11-09 17:25:22 +01:00
wborgeaud
7cf965ded5 All tests pass 2021-11-09 15:18:43 +01:00
wborgeaud
9617c22173 Increase degree 2021-11-09 14:24:04 +01:00
wborgeaud
bd1672cbf2 Working 2021-11-09 13:56:19 +01:00
wborgeaud
4e361726d0 Use partial product chain 2021-11-08 15:50:33 +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
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
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
bc57a561e6 Delete CrandallField 2021-11-02 12:29:26 -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
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
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
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
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
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
wborgeaud
5f4a244240 PR feedback 2021-10-18 21:38:57 +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