124 Commits

Author SHA1 Message Date
Daniel Lubarov
3eacd53b30
PolynomialBatchCommitment tweaks (#164)
Very minor things:
- A few renames
- Instead of having two constructors call a third constructor, just have one constructor call the other.
- Invoke FFT with the option that specifies the inputs are mostly zero, as a (minor) optimization
- Remove unused field
2021-08-09 10:11:35 -07:00
Daniel Lubarov
a02ab2853a Remove a TODO
We have a ticket for it
2021-08-08 19:43:16 -07: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
Daniel Lubarov
2d9891983f
Add a reduce_polys_base (#149)
* Add a reduce_polys_base

Reducing the polynomials in `open_plonk` was taking ~100ms on my machine. It was converting BF polynomials to the EF early on; by doing more work in the BF we can reduce it to ~20ms.

* PR feedback
2021-08-03 13:00:50 -07:00
Daniel Lubarov
b1633dc48d
More par_iter (#150) 2021-08-03 07:39:36 -07:00
Daniel Lubarov
f150f7ec09
More timing code for FRI prover (#146) 2021-08-02 15:49:06 -07:00
Daniel Lubarov
1229d90fae
Add a tree of scopes for proving times (#141)
* Add a tree of scopes for proving times

To replace the old `timed!` macro, which had no hierarchy.

It's similar to `ContextTree`, which tracks gate counts of circuit operations.

This gives a more organized output, with indentation levels based on scope depth, parent durations listed before child durations, etc.

* PR feedback
2021-08-02 10:38:09 -07: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
Daniel Lubarov
df03c22c48 Fix order 2021-07-29 09:12:24 -07:00
Daniel Lubarov
5f79b9630e
Update division calls (#132)
We have two division methods: one "unsafe" one, which permits 0/0 = anything, and one "safe" one, for which 0/0 results in an unsatisfiable instance. The latter is slightly more expensive.

I switched a few calls over to safe division, where unsafe division didn't seem sound (or at least it wasn't obvious). For calls where unsafe division did seem sound, I added comments explaining why.

Closes #97.
2021-07-28 18:06:32 -07:00
Daniel Lubarov
9081ae7337
Reduce noise in FRI logging (#129)
* Reduce noise in FRI logging

Previously, all logs related to gate counts were at the `Debug` log level. This PR gives us more flexibility to adjust the log levels of particular scopes.

In particular, our circuit checks 40 FRI queries, and we log a bunch of steps for each query, creating a lot of noise. With this change, we log just a single FRI query at the `Debug` level, and demote others to the `Trace` level.

With `RUST_LOG=debug`, our logs now look like

```
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] 17631 gates to root
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | 8 gates to observe proof and generates challenges
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | 4150 gates to evaluate the vanishing polynomial at our challenge point, zeta.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | 3184 gates to evaluate gate constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 227 gates to evaluate InterpolationGate { num_points: 4, _phantom: PhantomData }<D=4> constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 867 gates to evaluate <R=101> GMiMCGate { ... } constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 576 gates to evaluate BaseSumGate { num_limbs: 63 } + Base: 2 constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 78 gates to evaluate ArithmeticExtensionGate constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 288 gates to evaluate BaseSumGate { num_limbs: 31 } + Base: 2 constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 115 gates to evaluate InsertionGate { vec_size: 3, _phantom: PhantomData }<D=4> constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 26 gates to evaluate BaseSumGate { num_limbs: 2 } + Base: 2 constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 633 gates to evaluate ReducingGate { num_coeffs: 21 } constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 4 gates to evaluate ConstantGate constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 11 gates to evaluate PublicInputGate constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 2 gates to evaluate NoopGate constraints
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | 16 gates to check vanishing and quotient polynomials.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | 13336 gates to verify FRI proof
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | 6 gates to recover the random betas used in the FRI reductions.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | 4 gates to check PoW
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | 104 gates to precompute reduced evaluations
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | 330 gates to verify one (of 40) query rounds
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 95 gates to check FRI initial proof
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | | 22 gates to verify 0'th initial Merkle proof
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | | 33 gates to verify 1'th initial Merkle proof
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | | 20 gates to verify 2'th initial Merkle proof
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | | 20 gates to verify 3'th initial Merkle proof
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 34 gates to compute x from its index
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 32 gates to combine initial oracles
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 17 gates to verify FRI round Merkle proof.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 10 gates to infer evaluation using interpolation
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 15 gates to verify FRI round Merkle proof.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 10 gates to infer evaluation using interpolation
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 13 gates to verify FRI round Merkle proof.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 10 gates to infer evaluation using interpolation
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 11 gates to verify FRI round Merkle proof.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 10 gates to infer evaluation using interpolation
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 9 gates to verify FRI round Merkle proof.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 10 gates to infer evaluation using interpolation
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 7 gates to verify FRI round Merkle proof.
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 10 gates to infer final evaluation using interpolation
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | | 8 gates to evaluate final polynomial
```

This bit corresponds to the single FRI query being shown:

```
[2021-07-26T21:07:45Z DEBUG plonky2::context_tree] | | 330 gates to verify one (of 40) query rounds
```

* Minor cleanup

* Address feedback
2021-07-26 16:21:14 -07:00
wborgeaud
1e5a503a14
Merge pull request #127 from mir-protocol/reducing_gate
Add `ReducingGate` to compute reductions by `alpha` of base field elements
2021-07-25 18:14:40 +02:00
wborgeaud
c16d93ab33 scaling.rs -> reducing.rs 2021-07-23 17:31:00 +02:00
wborgeaud
ca540a8475 Working fri_combine_initial 2021-07-23 17:29:31 +02:00
wborgeaud
19140e39b2 Update comment 2021-07-23 15:01:45 +02:00
wborgeaud
f325586beb Replace exp_from_complement_bits with simpler method 2021-07-23 14:58:41 +02:00
wborgeaud
6f8053cc37 Forgot to exponentiate from bits in computation of subgroup_x. Saves 80 gates. 2021-07-23 08:53:00 +02:00
wborgeaud
9a1c289f8e Merge branch 'main' into remove_acc_in_gmimc
# Conflicts:
#	src/gadgets/arithmetic.rs
2021-07-23 08:16:23 +02:00
Nicholas Ward
3612b9f05e Merge branch 'main' into order_bigint 2021-07-22 13:28:48 -07:00
wborgeaud
e87aa2c90b Renaming 2021-07-22 16:25:47 +02:00
wborgeaud
1d92191227 Make exp_complement_bits take an iterator to avoid cloning. 2021-07-22 16:18:13 +02:00
wborgeaud
c729a3c235 Remove all non-bits indices in the FRI verifier 2021-07-22 16:07:07 +02:00
wborgeaud
22fcc3bc06 Pass bits around 2021-07-22 15:10:55 +02:00
wborgeaud
be2e870aee PR feedback 2021-07-22 06:50:07 +02:00
Nicholas Ward
7f92a33964 cargo fmt 2021-07-21 13:05:40 -07:00
Nicholas Ward
1dd850b0e5 fixes 2021-07-21 13:05:32 -07:00
wborgeaud
6fff9363c6 Use mul_many 2021-07-21 20:06:29 +02:00
wborgeaud
a54a4e5830 Merge branch 'main' into avoid_rotating 2021-07-21 20:02:22 +02:00
wborgeaud
7c1c082a39 Comments 2021-07-21 19:53:32 +02:00
Nicholas Ward
5062029d3f fixes 2021-07-21 09:32:18 -07:00
Daniel Lubarov
80b696a3a2
Avoid a clone (#114) 2021-07-21 08:26:56 -07:00
Daniel Lubarov
7d8bac7169
Change FFT methods to accept references (#115) 2021-07-21 08:26:41 -07:00
Nicholas Ward
906a0c00f4 Merge branch 'main' into order_bigint 2021-07-20 15:42:51 -07:00
Nicholas Ward
b103c0774f progress 2021-07-20 15:42:27 -07:00
Daniel Lubarov
ac1872a8c8
FRI tweaks (#111)
- Call `exp_power_of_2` instead of manual squaring
- Replace `evaluations[i]` with `evals`
2021-07-20 12:49:02 -07:00
wborgeaud
925c0bcb5c Replace rotation with exp in compute_evaluation 2021-07-20 15:25:03 +02:00
wborgeaud
0d233505d7 Merge branch 'main' into precomputed_reduced_evals
# Conflicts:
#	src/fri/recursive_verifier.rs
2021-07-20 11:08:53 +02:00
wborgeaud
fbeedd47d3 Minor 2021-07-20 11:02:22 +02:00
wborgeaud
38f4cca3f5 Target version 2021-07-20 10:57:20 +02:00
wborgeaud
97c4cfff7a Fixed bug 2021-07-20 10:44:58 +02:00
Nicholas Ward
8a51e6a323 started 2021-07-19 17:11:22 -07:00
Daniel Lubarov
8438d23937
Tree of scopes (#106)
* Tree of scopes

This is an extension of the context concept.

Earlier I was planning to store a simple stack of contexts, but I ended up storing the whole history, in a tree structure. This gives us more control over the output, i.e. we can print the gate count of a parent scope before those of its child scopes, which seems more user-friendly.

Sample gate count output:

    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] 27829 gates to root
    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] | 2373 gates to evaluate the vanishing polynomial at our challenge point, zeta.
    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] | | 1284 gates to evaluate gate constraints
    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] | 25312 gates to verify FRI proof
    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] | | 650 gates to verify 0'th FRI query
    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] | | | 96 gates to check FRI initial proof
    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] | | | 65 gates to compute x from its index
    [2021-07-19T18:09:24Z INFO  plonky2::circuit_builder] | | | 233 gates to combine initial oracles
    ...

Sample copy constraint failure:

    Error: Copy constraint 'root > verify FRI proof > verify 0'th FRI query > check FRI initial proof > verify 0'th initial Merkle proof > check Merkle root: 0-th hash element' between wire 12 of gate #2550 [...] and wire 0 of gate #0 [...] is not satisfied. Got values of 6861386743364621393 and 0 respectively.

* No min

* info -> debug

* Move to its own file
2021-07-19 12:22:18 -07:00
wborgeaud
69dc14f88a Added PrecomputedReducedEvals struct 2021-07-19 20:46:18 +02:00
wborgeaud
8868378fda
Merge pull request #103 from mir-protocol/remove_frobenius_opening
Remove openings at the Frobenius of zeta
2021-07-19 16:57:19 +02:00
wborgeaud
52cc7c79f5 Remove openings at the Frobenius of zeta 2021-07-19 16:45:38 +02:00
wborgeaud
9baea1ae26 Trim final poly and check FRI arity 2021-07-19 16:24:21 +02:00
Daniel Lubarov
d11bcd1928
Optional zk (#101)
* Make ZK optional

* Remove rate from FriConfig

Seems redundant, and we've had some tests break due to the two fields not matching.

* zero_knowledge: false in bench
2021-07-18 23:24:33 -07:00
wborgeaud
461f24a57e Merge branch 'main' into more_recursive_verifier
# Conflicts:
#	src/polynomial/commitment.rs
#	src/proof.rs
2021-07-19 07:08:06 +02:00
Daniel Lubarov
573badc96f
Parallel proof-of-work search (#92) 2021-07-15 07:40:41 -07:00
wborgeaud
4bc06deed8 zs_root -> zs_partial_products_root 2021-07-15 10:59:53 +02:00