48 Commits

Author SHA1 Message Date
wborgeaud
164aa0947e Use cap_height: 0 in size-optimized proof 2021-10-12 21:36:20 +02:00
Jakub Nabaglo
c55181a4ea
Fix logging in tests (#293)
* Fix logging in tests

* lint
2021-10-08 17:07:03 -07:00
Daniel Lubarov
a407e5e1a0 Fix 2021-10-05 16:33:08 -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
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
d9634e075e
Merge pull request #279 from mir-protocol/duplicate_indices
Remove duplicate query indices in FRI proofs
2021-10-04 10:40:18 +02:00
Daniel Lubarov
9d8b32c355 fmt 2021-10-03 22:59:10 -07:00
Daniel Lubarov
dadc1b2add cargo fix 2021-10-03 22:22:10 -07:00
wborgeaud
fbefaa4768 Unused import 2021-10-02 14:01:08 +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
8f212d31ef Working custom (de)serializer 2021-10-01 14:59:16 +02:00
Daniel Lubarov
3d39925973
Couple tweaks for Goldilocks (#274)
- impl `RichField`
- Fix missing imports (easy to miss since they're conditionally compiled)
- Have the benchmarks use Goldilocks
2021-09-28 10:03:19 -07: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
wborgeaud
36e4d3608d Working (de)compression for FRI proofs 2021-09-20 17:34:52 +02:00
wborgeaud
f83c587cc5 Comments 2021-09-17 13:47:08 +02:00
wborgeaud
b63d83aacf Add Poseidon gadget 2021-09-16 21:18:08 +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
d01d206524 Remove named connects 2021-08-24 18:20:47 +02:00
wborgeaud
71f64329c7 Minor 2021-08-24 08:30:34 +02:00
wborgeaud
a90ea6ec79 PartialWitness back to HashMap 2021-08-20 11:56:57 +02:00
wborgeaud
a44bf9ffd8 Added witness trait 2021-08-20 09:50:07 +02:00
Daniel Lubarov
aae2c9d16f Reduce PoW bits
The PoW search was taking significant time sometimes.
2021-08-17 23:55:16 -07:00
wborgeaud
5a9c5b295c Minor 2021-08-16 10:41:12 +02:00
wborgeaud
3d83d9ff42 Minor 2021-08-16 10:28:08 +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
08f0e0ff55 Remove unnecessary checks
They're out of date, and checked elsewhere
2021-08-13 19:36:21 -07:00
wborgeaud
630b7f2281 Smaller parameters 2021-08-13 22:42:22 +02:00
wborgeaud
ceae6b9588 Cleaning 2021-08-13 20:12:20 +02:00
wborgeaud
237ef4d0ec Change FRI params to get below 2^13 2021-08-13 18:24:46 +02:00
wborgeaud
7da4412de5 working 2021-08-13 15:22:03 +02:00
wborgeaud
75ad055f40 First try 2021-08-13 14:28:05 +02:00
wborgeaud
21669be246 Some arithm optims 2021-08-13 10:40:31 +02:00
wborgeaud
e73c1d7769 Cleaning / Renaming 2021-08-10 15:53:27 +02:00
wborgeaud
ad8428f38f 12604 gates, 318637 bytes 2021-08-10 15:28:41 +02:00
wborgeaud
f2c423ee61 save 13 gates 2021-08-10 14:19:12 +02:00
wborgeaud
ce71b536bf First pass 2021-08-10 13:33:44 +02:00
wborgeaud
dd076e5c73 Auto resize partial witness 2021-08-09 09:58:09 +02:00
wborgeaud
4f4839dcbe Merge branch 'main' into partial_witness_vec 2021-08-09 09:23:17 +02:00
Daniel Lubarov
97c2b6b9a2
Bit of refactoring in FRI code (#162)
* Bit of refactoring in FRI code

- Inline `OpeningSet[Target]` and their `verify` methods, as they had become fairly trivial wrappers
- Have the challenger observe the openings and generate alpha inside `verify_fri_proof`. Conceptually I think of it as part of the batch-FRI protocol, and it minimizes redundancy.

* Fix tests
2021-08-08 09:14:07 -07:00
wborgeaud
db236e4824 Fix tests 2021-08-06 15:14:38 +02:00
wborgeaud
7d11d0f8a1 Change PartialWitness to use Vecs 2021-08-06 14:58:39 +02:00
Daniel Lubarov
018fb005f8
Move stuff around (#135)
No functional changes here. The biggest change was moving certain files into new directories like `plonk` and `iop` (for things like `Challenger` that could be used in STARKs or other IOPs). I also split a few files, renames, etc, but again nothing functional, so I don't think a careful review is necessary (just a sanity check).
2021-07-29 22:00:29 -07:00