198 Commits

Author SHA1 Message Date
Daniel Lubarov
2b4bb13ab0
Remove total_constraints (#372)
It's out of date, and unused now anyway.
2021-11-18 23:00:56 -08:00
Daniel Lubarov
9b55ff9e81
edition = 2021 (#370)
* edition = 2021

Doesn't affect anything for us as far as I've noticed.

* imports
2021-11-17 14:43:54 -08:00
Daniel Lubarov
8772073b36
Update size-optimized proof test (#368)
The 2^12 change made this outdated. We no longer need to shrink degree (since normal recursive proofs are 2^12), so we can simplify a bit. We just boost the rate, then do a size-optimized proof. (Without doing the rate boost first, the final proof would be over 2^12.)

Configured for 93 bits security for now, but the PoW settings are low so that'll be easy to increase.

~45kb with current settings.
2021-11-17 08:13:20 -08:00
Daniel Lubarov
eb15837acb tweak logs 2021-11-16 22:53:08 -08:00
Daniel Lubarov
eb27a2d2b2 warnings 2021-11-16 22:52:01 -08:00
Daniel Lubarov
8b71075154
Reduce constant_gate_size to 5 (#366)
This results in 8 constant polynomials, which means our Merkle tree containing preprocessed polynomials has leaves of size 80 + 8 = 88. A multiple of 8 is efficient in terms of how many gates it takes to hash a leaf. Saves 17 gates.
2021-11-16 09:29:22 -08:00
Hamish Ivey-Law
909a5c2392
Fix all lint warnings (#353)
* Suppress warnings about use of unstable compiler features.

* Remove unused functions.

* Refactor and remove PolynomialCoeffs::new_padded(); fix degree_padded.

Note that this fixes a minor mistake in the FFT testing code, where
`degree_padded` value was log2 of what it should have been, preventing
a testing loop from executing.

* Remove divide_by_z_h() and related test functions.

* Only compile check_{consistency,test_vectors} when testing.

* Move verify() to test module.

* Remove unused functions.

NB: Changed the config in the gadgets/arithmetic_extension.rs::tests
module which may change the test's meaning?

* Remove unused import.

* Mark GMiMC option as allowed 'dead code'.

* Fix missing feature.

* Remove unused functions.

* cargo fmt

* Mark variable as unused.

* Revert "Remove unused functions."

This reverts commit 99d2357f1c967fd9fd6cac63e1216d929888be72.

* Make config functions public.

* Mark 'reduce_nonnative()' as dead code for now.

* Revert "Move verify() to test module." Refactor to `verify_compressed`.

This reverts commit b426e810d033c642f54e25ebc4a8114491df5076.

* cargo fmt

* Reinstate `verify()` fn on `CompressedProofWithPublicInputs`.
2021-11-16 21:18:27 +11:00
Daniel Lubarov
694b3d3dd5
Recursion in 2^12 gates (#364)
For now, we can do shrinking recursion with 93 bits of security. It's not quite as high as we want, but it's close, and I think it makes sense to merge this and treat the 2^12 circuit as our main benchmark, as we continue working to improve security.
2021-11-15 13:59:49 -08:00
Daniel Lubarov
8ea6c4d392
Different implementation of RandomAccessGate (#360)
The previous code used an equality test for each index. This variant uses a "MUX tree" instead. If we imagine the items as being the leaves of a binary tree, we can compute the `i`th item by splitting `i` into bits, then performing a "select" operation for each node. The bit used in each select is based on the height of the associated node.

This uses fewer wires and is cheaper to evaluate, saving 31 wires in the recursion circuit.

A potential disadvantage is that this uses higher-degree constraints (degree 4 with our params), but I don't think this is much of a concern for us since we use a degree-9 constraint system.
2021-11-15 10:15:55 -08:00
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