196 Commits

Author SHA1 Message Date
wborgeaud
104fd08e72 Working RAM gate 2021-10-18 15:19:09 +02:00
wborgeaud
cdb2892969 Move inferred elements to a new struct 2021-10-12 08:38:43 +02:00
wborgeaud
ddac8026f2 Comments 2021-10-11 17:24:06 +02:00
wborgeaud
acadd64371 Clippy 2021-10-11 16:51:30 +02:00
wborgeaud
ea69a87338 Working 2021-10-11 16:40:31 +02:00
wborgeaud
d2a5e67980 Somewhat working 2021-10-07 19:30:39 +02:00
Daniel Lubarov
b922def48e
Better errors for insufficient (routed) wires for FRI (#288)
For examlpe, if I change a test to use `ConstantArityBits(4, 5)`, I get

    To efficiently perform FRI checks with an arity of 16, at least 152 wires are needed. Consider reducing arity.
2021-10-05 23:28:04 -07:00
Daniel Lubarov
2148085725
Give MinSize a max arity option (#284)
* Give MinSize a max arity option

* Add Fixed option

* Fix
2021-10-05 16:18:00 -07:00
Daniel Lubarov
cb129fb095
Refactor recursion tests (#285)
* Refactor recursion tests

E.g. the main part of `test_recursive_recursive_verifier` is now

```rust
let (proof, vd, cd) = dummy_proof::<F, D>(&config, 8_000)?;
let (proof, vd, cd) = recursive_proof(proof, vd, cd, &config, &config, false)?;
let (proof, _vd, cd) = recursive_proof(proof, vd, cd, &config, &config, true)?;
```

Also adds a new `test_size_optimized_recursion` to see how small we can make the final proof in a recursion chain. The final proof is ~74kb (depending on compression luck) and takes ~20s to prove on my M1 (depending on PoW luck).

* Refactor serialization

* Don't log timestamps
2021-10-05 08:36:24 -07:00
Daniel Lubarov
73f9a0be6b
Allow zero FRI reductions (#283)
In this case we're basically sending the witness. As @wborgeaud mentioned it might make sense for small circuits.
2021-10-04 14:11:53 -07:00
Daniel Lubarov
898cac1709
Automatically select FRI reduction arities (#282)
* Automatically select FRI reduction arities

This way when a proof's degree changes, we won't need to manually update the `FriConfig`s of any recursive proofs on top of it.

For now I've added two methods of selecting arities. The first, `ConstantArityBits`, just applies a fixed reduciton arity until the degree has shrunk below a certain threshold. The second, `MinSize`, searches for the sequence of arities that minimizes proof size.

Note that this optimization is approximate -- e.g. it doesn't account for the effect of compression, and doesn't count some minor contributions to proof size, like the Merkle roots from the commit phase. It also assumes we're not using Merkle caps in serialized proofs, and that we're inferring one of the evaluations, even though we haven't made those changes yet.

I think we should generally use `ConstantArityBits` for proofs that we will recurse on, since using a single arity tends to be more recursion-friendly. We could use `MinSize` for generating final bridge proofs, since we won't do further recursion on top of those.

* Fix tests

* Feedback
2021-10-04 13:52:05 -07:00
wborgeaud
84d1a1586f Merge branch 'duplicate_indices' into custom_serializer 2021-10-04 10:21:53 +02:00
wborgeaud
bce3256c96 PR feedback 2021-10-04 10:21:35 +02:00
wborgeaud
b4614991f7 Useless mut 2021-10-04 10:09:17 +02:00
wborgeaud
bbeb54c910 Remove pruning 2021-10-04 10:03:00 +02:00
wborgeaud
e3b2416025 Merge branch 'duplicate_indices' into custom_serializer 2021-10-02 13:56:46 +02:00
wborgeaud
3859ca2090 PR comments 2021-10-02 10:46:02 +02:00
wborgeaud
76d3f488bd Fixes 2021-10-02 09:53:31 +02:00
wborgeaud
fb585064a9 (De)Serializer for CompressedProof 2021-10-01 16:54:14 +02:00
wborgeaud
28eca4bfdd Clippy 2021-09-30 19:09:27 +02:00
wborgeaud
dd68971609 Cleaning 2021-09-30 18:58:36 +02:00
wborgeaud
f92ce1a80c Add CompressedProof type 2021-09-30 06:56:32 +02:00
wborgeaud
a97b9a7112 Add compressed FRI proof type using a HashMap 2021-09-29 21:01:15 +02:00
Daniel Lubarov
f382289896
Derive challenges from other proof fields (#262)
* Derive challenges from other proof fields

* Delete failing test

Seems really hard to get the challenges right with the new model.

* Move PoW check

* Other feedback
2021-09-25 19:41:48 -07:00
Jakub Nabaglo
7360391515
Cache FFT roots (#261) 2021-09-22 10:56:09 -07:00
Jakub Nabaglo
46cc27571d
Delete unrolled FFT (#258) 2021-09-21 17:32:38 -07:00
wborgeaud
391759479e PR feedback 2021-09-21 08:37:23 +02:00
wborgeaud
1f42916bfc Comments 2021-09-20 17:58:25 +02:00
wborgeaud
36e4d3608d Working (de)compression for FRI proofs 2021-09-20 17:34:52 +02:00
Daniel Lubarov
3bc34c59d8
Refactor GMiMC code (#224)
* Refactor GMiMC code

Adds a sub-trait of `Field` called `GMiMCInterface`, which is similar to `PoseidonInterface`.

This lets us have different fields with different GMiMC constants in a type-safe way.

* Remove `Interface`

* Const generic for width
2021-09-07 18:28:28 -07:00
Daniel Lubarov
236a143abf
Move some Field members to a Field64 subtrait (#213)
* Move some Field members to a Field64 subtrait

I.e. move anything specific to 64-bit fields.

Also, relatedly,
- Tweak a bunch of prover code to require `Field64`, since 64-bit stuff is used in a couple places, like the FRI proof-of-work
- Remove `bits()`, which was unused and assumed a 64-bit field
- Rename a couple methods to reflect that they're u64 variants

There are no functional changes.

* Field64 -> PrimeField

* Remove `exp_u32`, `kth_root_u32`

* PrimeField: PrimeField

* Move `to_canonical_biguint` as well

* Add back from_noncanonical_u128
2021-09-05 10:27:11 -07:00
wborgeaud
71f64329c7 Minor 2021-08-24 08:30:34 +02:00
wborgeaud
bc3eb856f2 Remove remaining reverse_bits 2021-08-23 11:57:35 +02:00
wborgeaud
4dde45917b
Merge pull request #189 from mir-protocol/remove_reverse_bits
Remove reverse bits
2021-08-18 17:37:24 +02:00
Daniel Lubarov
c31c06d227
FFT/LDE benches (#188)
And expose FftStrategy so we can bench both
2021-08-18 08:36:40 -07:00
wborgeaud
01d745b627 Minor 2021-08-18 14:36:43 +02:00
wborgeaud
291e67bec5 Remove reverse_bits flag in Merkle trees 2021-08-18 14:32:24 +02:00
Daniel Lubarov
f2ed563da9
Try PoW seeds up to p (#186)
No point in going higher.
2021-08-18 00:53:20 -07:00
wborgeaud
d9b0778eef Change zip order 2021-08-17 08:47:52 +02:00
wborgeaud
9a54540116 Minor 2021-08-16 11:08:26 +02:00
wborgeaud
5a9c5b295c Minor 2021-08-16 10:41:12 +02:00
wborgeaud
b366482866 The mother of all arithmetic optimizations 2021-08-16 10:18:10 +02:00
wborgeaud
6ba6201b94 Merge branch 'main' into push_to_8192
# Conflicts:
#	src/fri/recursive_verifier.rs
#	src/plonk/circuit_data.rs
#	src/plonk/recursive_verifier.rs
#	src/util/reducing.rs
2021-08-16 08:49:49 +02:00
Daniel Lubarov
e4cbee2b57
Disable ZK in large_config (#180)
* Disable ZK in large_config

Speeds up the tests from ~6m to ~1m (debug mode). `large_config` is crate-private so I don't think we need to worry about real users forgetting ZK, and I don't think ZK seems important in these tests, though we should probably have ZK enabled for a couple tests.

A couple tests need ZK or they fail; I added a TODO to look later.

This led to a few other changes:
- Fixed a bug where `trim` could truncate the final poly to a non-power-of-two length. This was improbable when ZK is on due to randomization.
- Gave a few methods access to the whole `CircuitConfig` vs `FriConfig` -- sort of necessary for the above fix, and I don't think there's much downside.
- Remove `cap_height` from `FriConfig` -- didn't really need it any more after giving more methods access to `CircuitConfig`, and having a single copy of the param feels cleaner/safer to me.

* PR feedback
2021-08-14 10:01:10 -07:00
Daniel Lubarov
f3bfd66657
Add a BoolTarget (#179)
It's just a wrapper around `Target`, which signifies that the wrapped `Target` has already been range checked. Should make it easier to audit code that expects bools.
2021-08-14 08:53:39 -07:00
Daniel Lubarov
9c42fef997
Little refactor (#178) 2021-08-14 08:47:03 -07:00
wborgeaud
8aaa9401ac Add comment for slope 2021-08-14 11:48:13 +02:00
wborgeaud
43641174cb Comments 2021-08-13 18:00:40 +02:00
wborgeaud
68af28e9a2 Fix tests 2021-08-13 17:41:26 +02:00
wborgeaud
d0aae8c2a7 clean 2021-08-13 16:39:26 +02:00