456 Commits

Author SHA1 Message Date
Daniel Lubarov
92974aa105 A few more cyclic recursion changes
In preparation for adding the zkEVM aggregation circuit. Mainly,

- Adds a `WitnessWrite` trait, a sub-trait of `Witness`, and move the write methods to it. `GeneratedValues` impls `WitnessWrite`, which lets generators like `DummyProofGenerator` access all our write methods like `set_proof_with_pis_target`. Also removes some duplication.

- Remove `set_cyclic_recursion_data_target` - now that dummy proof data is automatically populated, all that remains is populating `condition` and the cyclic proof + VK. I think it's easy enough for callers to do this; the steps are the same as with `conditionally_verify_proof`. This way there's no cyclic-recursion-specific API to learn about.

- Split `cyclic_recursion` into two variants, one which checks the current circuit or a dummy, and a more general one which checks the current circuit or some other circuit. We can use the latter to build a more efficient aggregation circuit, where we check another aggregation proof or an EVM proof, with no dummy proofs involved.
2022-12-11 22:43:26 -08:00
Nicholas Ward
f0e144bb9b removed confusing grammatical exclamation point from factorial example 2022-12-09 17:29:09 -08:00
Daniel Lubarov
fbb26546dd Jemalloc for EVM
Also update the version used elsewhere.
2022-12-04 10:15:28 -08:00
Daniel Lubarov
05ab3d7933 Fixes 2022-12-01 16:23:39 -08:00
Daniel Lubarov
73de231e34
Merge pull request #827 from mir-protocol/cyclic_recursion_tweaks
Cyclic recursion tweaks
2022-11-29 13:19:18 -08:00
Daniel Lubarov
3515fbddac fix 2022-11-29 12:39:53 -08:00
Daniel Lubarov
ad58dcbc0e fix 2022-11-29 12:39:17 -08:00
Daniel Lubarov
c3ae52f5b0 fix 2022-11-29 12:19:40 -08:00
Daniel Lubarov
b23193ba8d use hashmap 2022-11-29 12:17:33 -08:00
Daniel Lubarov
319d9b5a52 Feedback 2022-11-29 12:02:54 -08:00
Daniel Lubarov
644a8a2336 Make proof_with_pis a reference 2022-11-28 22:18:42 -08:00
Daniel Lubarov
c528da4e66 Cyclic recursion tweaks
- Have the caller to `cyclic_recursion` create and pass in the virtual proof
- Split `dummy_proof` into preprocessing and proving, so that we don't need to redo the preprocessing work in each `set_cyclic_recursion_data_target` call
- Have the caller update `num_public_inputs` instead of doing it in `cyclic_recursion`. This is a little less convenient but I think it's best not to modify the caller's config (principle of least surprise)
- Have `set_cyclic_recursion_data_target` take a sparse set of public inputs. Taking some PIs with the lowest indices didn't seem very general. I still have some reservations about this part of the API - I think it would seem cleaner if PIs of a proof which wasn't selected for verification were simply ignored - but perhaps there are some optimization reasons to keep using them.
2022-11-28 21:02:41 -08:00
Daniel Lubarov
964d2bc373 Fix test 2022-11-22 22:33:41 -08:00
Daniel Lubarov
4048107892 Cyclic recursion tweaks 2022-11-22 20:09:10 -08:00
Daniel Lubarov
7ec14029c6 Fix comment 2022-11-22 08:04:01 -08:00
Daniel Lubarov
af1b6680e8 Switch to Vec 2022-11-22 08:02:22 -08:00
Daniel Lubarov
108cb83621 Domain separator option 2022-11-21 13:24:46 -08:00
Daniel Lubarov
05f4d2be4e Remove conversion 2022-11-20 09:43:16 -08:00
Daniel Lubarov
b0be6d7e8a Serialization refactor
Followup to #806.

A few goals here
- Zero dependencies on std. (Previously deserialization depended on std for `Cursor`.)
- Provide a single (memory buffering) impl of `Write` to make sure there's no confusion. (Previously `Buffer` and `Vec<u8>` both implemented it.)
- Move closer to the `std::io` APIs. Hopefully they will be available without std at some point (there have been some discussions...).

More specifically, this
- Changes `Buffer` to not use std's `Cursor`.
- Removes `impl Write` for `Buffer`, since it's implemented for `Vec<u8>`.
- Adds a concrete I/O error type to mimic `std::io`'s.
- Combines `Position` and `Size` into `Remaining`.
2022-11-20 09:37:18 -08:00
Daniel Lubarov
9a43084f94 Merge branch 'feat/no-std-support' of https://github.com/openzklib/plonky2 into openzklib-feat/no-std-support 2022-11-17 12:17:22 -08:00
Daniel Lubarov
1732399f05 Remove comment 2022-11-17 12:08:33 -08:00
Daniel Lubarov
e22da77b34 Include the FRI prover's PoW witness in the transcript
We don't think this is required for soundness, but just to remove any doubt.

Old protocol:
```
...
P sends final_poly
V samples random r
P sends pow_witness (not in transcript)
V computes pow_response = H(r, pow_witness)
V asserts pow_response has N leading 0s
...
```

New protocol:
```
...
P sends final_poly
P sends pow_witness
V samples random pow_response
V asserts pow_response has N leading 0s
...
```
2022-11-17 12:08:11 -08:00
Brandon H. Gomes
65d106bc31
chore: remove derivative dependency as non-crucial
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-15 16:26:43 -05:00
Brandon H. Gomes
2520bd62c6
chore: match hashbrown ahash dependency
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-15 16:14:07 -05:00
Brandon H. Gomes
812a5d468a
chore: merge branch main
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-15 01:54:30 -05:00
Brandon H. Gomes
289498e854
fix: address review comments
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-15 01:52:27 -05:00
Brandon H. Gomes
14c2a6dd1f
Fork Update (#3)
* Use static `KERNEL` in tests

* Print opcode count

* Update criterion

* Combine all syscalls into one flag (#802)

* Combine all syscalls into one flag

* Minor: typo

* Daniel PR comments

* Check that `le_sum` won't overflow

* security notes

* Test reverse_index_bits

Thanks to Least Authority for this

* clippy

* EVM shift left/right operations (#801)

* First parts of shift implementation.

* Disable range check errors.

* Tidy up ASM.

* Update comments; fix some .sum() expressions.

* First full draft of shift left/right.

* Missed a +1.

* Clippy.

* Address Jacqui's comments.

* Add comment.

* Fix missing filter.

* Address second round of comments from Jacqui.

* Remove signed operation placeholders from arithmetic table. (#812)

Co-authored-by: wborgeaud <williamborgeaud@gmail.com>
Co-authored-by: Daniel Lubarov <daniel@lubarov.com>
Co-authored-by: Jacqueline Nabaglo <jakub@mirprotocol.org>
Co-authored-by: Hamish Ivey-Law <426294+unzvfu@users.noreply.github.com>
2022-11-15 01:51:29 -05:00
Daniel Lubarov
7eb0c74166 Randomize unused wires of PublicInputGate 2022-11-14 14:53:06 -08:00
Daniel Lubarov
cab6c18ed6 Check that le_sum won't overflow 2022-11-08 11:55:02 -08:00
Daniel Lubarov
3dcc0c257e Update criterion 2022-11-07 11:28:24 -08:00
Brandon H. Gomes
9431fd7448
chore: add missing documentation in serialization trait
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-05 10:59:46 -07:00
Brandon H. Gomes
7e432bd6cc
feat: add serialization documentation
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-04 16:47:02 -07:00
Brandon H. Gomes
fc3f63398d
wip: start moving starky to no-std
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-03 12:17:03 -07:00
Brandon H. Gomes
38e467f1c0
chore: fix serde-cbor and run cargo-sort
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-03 11:41:12 -07:00
Brandon H. Gomes
703d2c3c95
wip: start plonky2_u32 and plonky2_ecdsa no-std impl
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-03 10:58:55 -07:00
Brandon H. Gomes
e2cdd5a954
feat: upgrade Sampling APIs
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-03 08:26:03 -07:00
Brandon H. Gomes
4aaf57e9a9
feat: separate reading and writing to get infallible writers
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-02 21:07:51 -07:00
Brandon H. Gomes
7a81c5d46a
feat: move to alloc for Vec/String/Box
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-02 19:59:12 -07:00
Brandon H. Gomes
6fd0da216a
fix: remove unstable features from plonky2
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-02 17:50:31 -07:00
Brandon H. Gomes
11600b93c0
fix: do a first round of a core replacement
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-02 16:54:41 -07:00
wborgeaud
c47f767fc5 PR feedback 2022-10-27 15:45:14 +02:00
wborgeaud
8a60fe19ea Cyclic recursion gadget doesn't move circuit builder 2022-10-26 15:04:47 +02:00
wborgeaud
73e9e6119b CyclicPublicInputs is just VerifierOnlyCircuitData 2022-10-26 11:02:45 +02:00
wborgeaud
341e1ebeec Working 2022-10-26 10:58:38 +02:00
wborgeaud
7afbddb0b6 Add goal_common_data to CircuitBuilder 2022-10-25 22:57:36 +02:00
wborgeaud
e8fd8bd1d8 Add type hints 2022-10-25 22:51:24 +02:00
wborgeaud
a0eca98c81 Merge branch 'main' into cyclic_recursion
# Conflicts:
#	plonky2/src/plonk/circuit_data.rs
2022-10-25 22:45:47 +02:00
wborgeaud
b97ec3bda1 New clippy lint 2022-10-25 10:50:40 +02:00
wborgeaud
0e58efdcc1 Remove Config from CommonCircuitData 2022-10-25 10:08:21 +02:00
wborgeaud
f28ff42fe3 PR feedback 2022-10-24 13:35:16 +02:00