613 Commits

Author SHA1 Message Date
wborgeaud
b65e792ff3 - Remove useless rotation gadgets
- rotate.rs -> select.rs
- Added `select()` and `select_ext`
- Optimize to use just one gate
2021-07-22 11:58:29 +02:00
wborgeaud
1d5cd4430e
Merge pull request #118 from mir-protocol/avoid_rotating
Avoid rotating in `compute_evaluation`
2021-07-22 11:23:45 +02:00
wborgeaud
be2e870aee PR feedback 2021-07-22 06:50:07 +02:00
Daniel Lubarov
01461ce388 Update a TODO 2021-07-21 21:25:52 -07:00
wborgeaud
db0121d74a Update comment 2021-07-21 20:38:23 +02: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
wborgeaud
2f46ddc4e5
Merge pull request #117 from mir-protocol/optimize_mul_many
Remove fixed multiplicand in `ArithmeticExtensionGate`
2021-07-21 19:24:07 +02:00
wborgeaud
6cc871d30c PR feedback 2021-07-21 19:23:26 +02:00
wborgeaud
59494ff8d1 Merge branch 'main' into optimize_mul_many
# Conflicts:
#	src/gates/arithmetic.rs
2021-07-21 17:47:38 +02:00
wborgeaud
6e305f0a3e Change {add|mul}_many and cube 2021-07-21 17:41:22 +02:00
wborgeaud
d870a36dee {add|mul}_three_extension 2021-07-21 17:29:05 +02: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
Daniel Lubarov
eb18c7ea33
Faster witness generation (#116)
Saves ~300ms in the test. The main change is to have generators return fixed-size `Vec`s instead of `HashMap`s, which have more overhead.
2021-07-21 08:26:34 -07:00
Daniel Lubarov
b8ce1d1967
Public inputs (#113)
With this approach, we don't need `Target::PublicInput`; any routable `Target` can be marked as a public input via `register_public_input`.  The circuit itself hashes these targets, and routes the hash output to the first four wires of a `PublicInputGate`, which is placed at an arbitrary location in the circuit.

All gates have direct access to the purported hash of public inputs. We could think of them as accessing `PI_hash_i(x)` (as in Plonk), but these are now (four) constant functions, so they effectively have direct access to the hash itself.

`PublicInputGate` checks that its first four wires match this purported public input hash. The other gates ignore the hash.

Resolves #64.
2021-07-21 08:26:19 -07:00
wborgeaud
b59d497964 Modify ArithmeticExtensionGate to support 32 wires 2021-07-21 17:20:08 +02:00
wborgeaud
8642a10fde Start of optimization 2021-07-21 15:58:15 +02:00
Daniel Lubarov
48f5c9347f
route -> assert (#112)
Doesn't really matter except that failure messages might be different if the copy-generator runs first.
2021-07-20 13:04:34 -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
Daniel Lubarov
dff950c502
No Copy on ReducingFactor (#110)
It feels a little dangerous; would be easy to "fork" one accidentally. We already clone explicitly, this just enforces that in the future.
2021-07-20 09:27:35 -07:00
Daniel Lubarov
0a59c738ea
Add a context for each gate evaluation (#108)
To give logs like

    [2021-07-20T15:29:29Z DEBUG plonky2::context_tree] | 2373 gates to evaluate the vanishing polynomial at our challenge point, zeta.
    [2021-07-20T15:29:29Z DEBUG plonky2::context_tree] | | 1284 gates to evaluate gate constraints
    [2021-07-20T15:29:29Z DEBUG plonky2::context_tree] | | | 79 gates to evaluate ArithmeticExtensionGate constraints
    [2021-07-20T15:29:29Z DEBUG plonky2::context_tree] | | | 1073 gates to evaluate <R=101> GMiMCGate {...} constraints
    [2021-07-20T15:29:29Z DEBUG plonky2::context_tree] | | | 4 gates to evaluate NoopGate constraints
    [2021-07-20T15:29:29Z DEBUG plonky2::context_tree] | | | 4 gates to evaluate ConstantGate constraints
2021-07-20 09:27:18 -07:00
wborgeaud
8a6d0fe06c
Merge pull request #107 from mir-protocol/precomputed_reduced_evals
Precompute reduced evaluations
2021-07-20 18:26:45 +02: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
a74fce0196 quick fix 2021-07-19 17:11:42 -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
d24ecb6dc3
Merge pull request #105 from mir-protocol/remove_wire_partition_indices
Remove `indices` in  `WirePartitions`
2021-07-19 20:03:50 +02:00
wborgeaud
72021a56fa Simplify 2021-07-19 19:42:39 +02:00
wborgeaud
b72d4d126b Remove indices in WirePartitions 2021-07-19 19:38:39 +02:00
Daniel Lubarov
a9e5f1e4e2
More routed wires for recursion (#104)
* More routed wires for recursion

For the insertion gate, which (with a FRI arity of 4) uses 1 wire for the insertion index, D for the elemnet to insert, 3D for the original list, and 4D for the output list.

* import
2021-07-19 08:52:10 -07:00
Nicholas Ward
4dc6a603a1
Merge pull request #90 from mir-protocol/insertion_gate
Insertion gate
2021-07-19 07:59:55 -07: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
661c6d0069
Merge pull request #102 from mir-protocol/trim_final_poly
Trim final polynomial and check total FRI arity
2021-07-19 16:54:59 +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
35c8643681 Tiny cleanup 2021-07-18 23:31:21 -07: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
Daniel Lubarov
0a5d46bfa9
Have prove return Result (#100)
* Have `prove` return `Result`

To address that TODO.

* PR feedback
2021-07-18 23:14:48 -07:00
Daniel Lubarov
9c17a00c00
Division related changes (#99)
* Division related changes

- Simplify `div_unsafe_extension` using virtual targets
- Add methods for inversion and safe division

As a followup I'll switch some calls to safe division.

* Test safe division also

* add_virtual_extension_target
2021-07-18 23:05:57 -07:00
wborgeaud
b937679292
Merge pull request #95 from mir-protocol/more_recursive_verifier
Recursive verifier
2021-07-19 07:11:57 +02:00
wborgeaud
b7d51db979 Fix merge problems 2021-07-19 07:11:40 +02: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
wborgeaud
097413479e PR feedback 2021-07-18 10:35:42 +02:00
Nicholas Ward
d8af0a9334 Merge main 2021-07-15 15:06:38 -07:00