1364 Commits

Author SHA1 Message Date
Nicholas Ward
bdfe124b0c multiple comparison 2021-11-10 09:53:29 -08:00
Nicholas Ward
6dd14eb27a comparison gate should also be <= 2021-11-10 09:53:29 -08:00
Nicholas Ward
26959d11c9 range-check the bits 2021-11-10 09:53:28 -08:00
Nicholas Ward
0ff6e6e0a0 fmt 2021-11-10 09:53:28 -08:00
Nicholas Ward
7e8c021b46 comparison gate 2021-11-10 09:53:28 -08:00
Nicholas Ward
912204d685 merge 2021-11-10 09:53:27 -08:00
Nicholas Ward
ebcfde1d81 updates 2021-11-10 09:53:12 -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
wborgeaud
ff943138f3
Apply suggestions from code review
Co-authored-by: Daniel Lubarov <daniel@lubarov.com>
2021-11-10 09:38:47 +01:00
Nicholas Ward
6b294c1d97 fmt 2021-11-09 18:10:52 -08:00
Nicholas Ward
34eacdada6 progress 2021-11-09 18:10:52 -08:00
Nicholas Ward
f71adac40b fix 2021-11-09 18:10:52 -08:00
Nicholas Ward
e48e0a4a58 fmt 2021-11-09 18:10:52 -08:00
Nicholas Ward
ffb544e4a5 initial non-native add 2021-11-09 18:10:52 -08:00
Nicholas Ward
d334a924b4 merge new circuit builder stuff 2021-11-09 18:10:47 -08:00
Nicholas Ward
7054fcdaf9 initial 2021-11-09 18:09:39 -08:00
Jakub Nabaglo
9711127599
Use Jemalloc (#347) 2021-11-09 15:14:41 -08:00
Jakub Nabaglo
168f572804
Fix rustfmt failures on main (#348) 2021-11-09 14:52:05 -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
abc706ee26 Fix partial product test 2021-11-09 17:18:15 +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
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
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