1352 Commits

Author SHA1 Message Date
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
Daniel Lubarov
26a222bbdf
Fewer wires in PoseidonGate (#356)
Closes #345.
2021-11-14 11:57:36 -08:00
Nicholas Ward
ad42104e65
Merge pull request #354 from mir-protocol/smaller_tests
Reduced test sizes
2021-11-12 12:32:37 -08:00
Nicholas Ward
4a5123de81 reduced test sizes 2021-11-12 12:12:58 -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
72ef58c19d Add ReducingExtGate 2021-11-12 18:24:08 +01: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
137c6d341c
Merge pull request #281 from mir-protocol/nonnative
Non-native field arithmetic
2021-11-10 12:46:13 -08:00
Nicholas Ward
f2ec2cadf4 new fmt 2021-11-10 12:14:23 -08:00
Nicholas Ward
bd427cd629 fixed failing tests 2021-11-10 12:10:32 -08:00
Nicholas Ward
dd945ef5b7 addressed comments 2021-11-10 11:19:06 -08:00
Nicholas Ward
9043a47e1b more fixes 2021-11-10 11:15:00 -08:00
Nicholas Ward
ea4f950d6e fixes and fmt 2021-11-10 10:54:35 -08:00
Nicholas Ward
270521a17d addressed comments 2021-11-10 09:58:16 -08:00
Nicholas Ward
7336aa0917 fmt 2021-11-10 09:58:16 -08:00
Nicholas Ward
3f619c704c made test_list_le random 2021-11-10 09:58:16 -08:00
Nicholas Ward
6164796898 rename 2021-11-10 09:58:16 -08:00
Nicholas Ward
db31b9f662 sub_nonnative fix 2021-11-10 09:58:16 -08:00
Nicholas Ward
656f052b79 addressed nits 2021-11-10 09:58:16 -08:00
Nicholas Ward
cf3b6df0e4 addressed nits 2021-11-10 09:58:16 -08:00
Nicholas Ward
c861c10a5b nonnative neg 2021-11-10 09:58:16 -08:00
Nicholas Ward
e838096940 use map; and TODOs 2021-11-10 09:58:16 -08:00
Nicholas Ward
1d4bb3950d FFTarget uses BigUintTarget 2021-11-10 09:58:16 -08:00
Nicholas Ward
6ab01e51f3 u32 arithmetic check for special cases 2021-11-10 09:58:16 -08:00
Nicholas Ward
237a1fad1d addressed comments 2021-11-10 09:58:16 -08:00
Nicholas Ward
bd0164c7ef fmt 2021-11-10 09:58:16 -08:00
Nicholas Ward
a3d957fa42 addressed comment: more tests for multiple_comparison 2021-11-10 09:58:16 -08:00