1380 Commits

Author SHA1 Message Date
wborgeaud
2c06309cf7 Fix all clippy lints 2021-11-30 17:12:13 +01:00
Jakub Nabaglo
549ce0d8e9
Interleaved batched multiplicative inverse (#371)
* Interleaved batched multiplicative inverse

* Minor: typo
2021-11-23 21:36:12 -08:00
wborgeaud
1fed718a70
Merge pull request #374 from mir-protocol/arity4
Low-degree interpolation gate and log-arity of 4 in recursive benchmark + 2^12 shrinking recursion with 100 security bits
2021-11-22 23:01:45 +01:00
wborgeaud
3235a21d2b 2^12 shrinking recursion with 100 bits of security 2021-11-22 22:38:37 +01:00
wborgeaud
e26eb5f4ab Merge branch 'main' into arity4
# Conflicts:
#	src/gates/mod.rs
2021-11-22 22:32:37 +01:00
wborgeaud
9cafe97731 Remove specific impls of InterpolationGate 2021-11-22 22:30:32 +01:00
wborgeaud
9bd5ac00c1
Merge pull request #373 from mir-protocol/mul_gate
Multiplication gate
2021-11-22 22:25:54 +01:00
wborgeaud
15b41ea8fb PR feedback 2021-11-22 22:13:24 +01:00
wborgeaud
172fdd3d89 Comments 2021-11-22 21:20:44 +01:00
wborgeaud
fa29db1dcb Clean low-degree interpolation gate 2021-11-22 17:54:58 +01:00
wborgeaud
5ea632f2a8 Fix size optimized test 2021-11-22 17:30:13 +01:00
wborgeaud
b7cb7e234f Minor 2021-11-22 17:06:40 +01:00
wborgeaud
e06ce5aa2f Fix proof compression test 2021-11-22 16:41:33 +01:00
wborgeaud
6aaea002ed Choose between high- and low-degree interpolation gate depending on the arity 2021-11-22 16:10:14 +01:00
wborgeaud
8522026c36 Change file structure 2021-11-22 11:39:56 +01:00
wborgeaud
442c8560b0 Under 2^12 with 27 query rounds 2021-11-22 11:16:58 +01:00
wborgeaud
0d5ba7e755 Working recursive test 2021-11-22 10:44:19 +01:00
wborgeaud
aec88a8528 First try 2021-11-19 18:11:14 +01:00
wborgeaud
22f4c18083 Comments 2021-11-19 11:48:42 +01:00
wborgeaud
4f11713c49 Remove useless test 2021-11-19 11:29:51 +01:00
wborgeaud
90a6ffd775 Use fold1 in mul_many 2021-11-19 11:24:43 +01:00
wborgeaud
939acfed96 Fix mul_many 2021-11-19 11:14:03 +01:00
wborgeaud
0de408c40f MulExtensionGate 2021-11-19 09:31:06 +01:00
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
Daniel Lubarov
eb5a60bef1
Allow one BaseSumGate to handle 64 bits (#365) 2021-11-16 09:29:14 -08:00
Daniel Lubarov
1e66cb9aee
Route in constants from a ConstantGate (#367)
Rather than creating arithmetic gates with potentially unique constants.

Should be strictly cheaper, though it only seems to save one gate in practice.
2021-11-16 09:28:58 -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
4769efa4dd rename 2021-11-15 19:33:03 -08: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
wborgeaud
beb13af5ee
Merge pull request #363 from mir-protocol/reducing_ext_gate
Add `ReducingExtensionGate`
2021-11-15 20:47:03 +01:00
wborgeaud
799ff26e71 Avoid underflow when checking the length of terms 2021-11-15 19:46:28 +01: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
239c795a9d
Address some more arithmetic gates that have unique constants (#361)
Saves 131 gates, though only when not using `PoseidonMdsGate`, so not relevant for the 2^12 branch.
2021-11-15 10:10:37 -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
wborgeaud
49e4307820 Comments + test for reducing 100 extension elements 2021-11-15 13:35:21 +01:00
wborgeaud
3efe2068bc Minor 2021-11-15 11:59:54 +01:00
wborgeaud
f787c5385f Simplify 2021-11-15 11:50:41 +01:00
wborgeaud
a54db66f68 Use arithmetic gate for small reductions 2021-11-15 11:39:24 +01:00
wborgeaud
66719b0cfc Remove comments 2021-11-15 10:33:27 +01:00
wborgeaud
d44cb96744 Merge branch 'main' into reducing_ext_gate 2021-11-15 09:22:35 +01: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
fe1e67165a
256 bit salts (#352)
I believe I was mistaken earlier, and hash-based commitments actually call for `r = 2*security_bits` bits of randomness.

I.e. I believe breaking a particular commitment requires `O(2^r)` work (more if the committed value adds entropy, but assume it doesn't), but breaking one of `n` commitments requires less work.

It seems like this should be a well-known thing, but I can't find much in the literature. The IOP paper does mention using `2*security_bits` of randomness though.
2021-11-14 11:58:14 -08:00