1721 Commits

Author SHA1 Message Date
wborgeaud
79ba85eb08 Compiles 2022-02-21 10:52:04 +01:00
wborgeaud
f4a29a0249 Merge branch 'main' into stark_permutation_checks 2022-02-21 10:19:12 +01:00
wborgeaud
d52fabaf26 First pass 2022-02-21 10:18:05 +01:00
Daniel Lubarov
6072fab077
Implement a mul-add circuit in the ALU (#495)
* Implement a mul-add circuit in the ALU

The inputs are assumed to be `u32`s, while the output is encoded as four `u16 limbs`. Each output limb is range-checked.

So, our basic mul-add constraint looks like

    out_0 + 2^16 out_1 + 2^32 out_2 + 2^48 out_3 = in_1 * in_2 + in_3

The right hand side will never overflow, since `u32::MAX * u32::MAX + u32::MAX < |F|`. However, the left hand side could overflow, even though we know each limb is less than `2^16`.

For example, an operation like `0 * 0 + 0` could have two possible outputs, 0 and `|F|`, both of which would satisfy the constraint above. To prevent these non-canonical outputs, we need a comparison to enforce that `out < |F|`.

Thankfully, `F::MAX` has all zeros in its low 32 bits, so `x <= F::MAX` is equivalent to `x_lo == 0 || x_hi != u32::MAX`. `x_hi != u32::MAX` can be checked by showing that `u32::MAX - x_hi` has an inverse. If `x_hi != u32::MAX`, the prover provides this (purported) inverse in an advice column.

See @bobbinth's [post](https://hackmd.io/NC-yRmmtRQSvToTHb96e8Q#Checking-element-validity) for details. That post calls the purported inverse column `m`; I named it `canonical_inv` in this code.

* fix

* PR feedback

* naming
2022-02-21 00:39:04 -08:00
Daniel Lubarov
bc3685587c
Rename constraint methods (#497)
Most of our constraints apply to all rows, and it seems safest to make that the "default".
2022-02-20 16:48:31 -08:00
Daniel Lubarov
bedd2aa711
Rename arithmetic unit to ALU (#496) 2022-02-19 17:32:11 -08:00
wborgeaud
9516e14c3e
Merge pull request #491 from mir-protocol/fix_reduction_strategy
Fix reduction strategy
2022-02-18 17:07:03 +01:00
Jakub Nabaglo
a736aa8e70
Update MDS matrix and round consts in Poseidon; disable vectorization (#493) 2022-02-17 22:01:07 -08:00
wborgeaud
67cb5dfd58 PR feedback 2022-02-17 08:26:23 +01:00
Daniel Lubarov
431faccbdb
Change compute_permutation_z_polys to batch permutation checks (#492)
* Change `compute_permutation_z_polys` to batch permutation checks

* feedback
2022-02-16 23:37:20 -07:00
wborgeaud
56336e396d Fix 2022-02-16 14:17:14 +01:00
wborgeaud
ea9006f52e Add rate_bits 2022-02-16 13:51:10 +01:00
wborgeaud
c9185d92bb Merge branch 'main' into fix_reduction_strategy
# Conflicts:
#	starky/src/prover.rs
2022-02-16 13:38:54 +01:00
wborgeaud
b28cd55326 Fix reduction strategy 2022-02-16 13:37:01 +01:00
Daniel Lubarov
72d13d0ded
Prover code for permutation argument (#485)
* Batch multiple perm args into one Z and compute Z columnwise

It's slightly complex because we batch `constraint_degree - 1` permutation arguments into a single `Z` polynomial. This is a slight generalization of the [technique](https://zcash.github.io/halo2/design/proving-system/lookup.html) described in the Halo2 book.

Without this batching, we would simply have `num_challenges` random challenges (betas and gammas). With this batching, however, we need to use different randomness for each permutation argument within the same batch. Hence we end up generating `batch_size * num_challenges` challenges for all permutation arguments.

* Feedback + updates for recursion code
2022-02-16 01:33:59 -08:00
wborgeaud
c6f80ba59a
Merge pull request #490 from mir-protocol/batchable
Simplify batched gate code
2022-02-16 09:36:47 +01:00
wborgeaud
f8dfc3986b PR feedback 2022-02-16 09:26:16 +01:00
wborgeaud
08e255a2bb Remove params in GateInstance 2022-02-16 09:02:21 +01:00
wborgeaud
661a6b44ef Delete GMiMC files 2022-02-16 08:33:52 +01:00
Hamish Ivey-Law
f4ef692aad
Quintic extension fields (#489)
* Initial implementation of quintic extensions.

* Update to/from_biguint() methods.

* cargo fmt

* Fix call to test suite.

* Small optimisation in try_inverse().

* Replace multiplicative group generator and document requirement.
2022-02-16 10:38:24 +11:00
wborgeaud
3fd5258191 Comments 2022-02-15 18:00:53 +01:00
wborgeaud
2d4d2d21a0 Simplification 2022-02-15 17:35:12 +01:00
wborgeaud
3f7cefbc6b
Merge pull request #486 from mir-protocol/recursive_starks
Recursive STARK verifier
2022-02-15 17:24:34 +01:00
wborgeaud
d0da2fe1ad Remove debug info 2022-02-15 17:01:16 +01:00
wborgeaud
c74b0c91c8 Progress towards using generators 2022-02-15 16:59:17 +01:00
wborgeaud
0aefe92b8c Merge MultiOpsGate into Gate 2022-02-15 15:30:34 +01:00
wborgeaud
5e3177520b Fixes 2022-02-15 15:08:53 +01:00
wborgeaud
6d2c9b11a6 Merge branch 'main' into batchable
# Conflicts:
#	plonky2/src/gates/gmimc.rs
#	plonky2/src/hash/gmimc.rs
#	plonky2/src/plonk/circuit_builder.rs
2022-02-15 14:43:12 +01:00
wborgeaud
42d6532120 PR feedback 2022-02-15 08:35:57 +01:00
wborgeaud
acd62f1221 Changes after #481 2022-02-15 08:17:07 +01:00
wborgeaud
14d8cf2ceb Merge branch 'main' into recursive_starks 2022-02-15 08:13:50 +01:00
wborgeaud
f4640bb5a1
Merge pull request #481 from mir-protocol/fix_hash_or_noop_merkle_proof
Use `hash_or_noop` for Merkle tree leaves
2022-02-15 08:12:36 +01:00
Daniel Lubarov
8d699edf21
Move some methods outside impl System (#484)
I didn't really have a good reason for putting there; seems more idiomatic to make them global since they don't need `self`/`Self`.
2022-02-14 13:47:33 -08:00
Nicholas Ward
96c9a2385b
Merge pull request #488 from mir-protocol/ecdsa_pub_hash
Impled `Hash` for `AffinePoint`
2022-02-14 11:57:22 -08:00
BGluth
1467732616 Impled Hash for AffinePoint 2022-02-14 12:41:24 -07:00
wborgeaud
b104dfce2a Working 2022-02-14 19:37:24 +01:00
Nicholas Ward
983c066b80
Merge pull request #487 from mir-protocol/ecdsa_more_derive
Derived more traits for ecdsa types
2022-02-14 10:36:21 -08:00
BGluth
c9171517a4 Derived more traits for ecdsa types 2022-02-14 10:55:11 -07:00
wborgeaud
7820ba965c Minor 2022-02-14 10:23:26 +01:00
wborgeaud
1686cb021f verify_stark_proof -> recursively_verify_stark_proof 2022-02-14 10:20:59 +01:00
wborgeaud
6dca4e26af Unused 2022-02-14 10:16:02 +01:00
wborgeaud
83701096c4 More visibility changes 2022-02-14 10:14:31 +01:00
wborgeaud
cff39c5550 Change visibility 2022-02-14 10:12:24 +01:00
wborgeaud
3db9c775b4 Add set_fri_openings 2022-02-14 10:09:08 +01:00
wborgeaud
80e3c928bb Clippy 2022-02-14 10:00:37 +01:00
wborgeaud
b0de3328c1 Working 2022-02-14 09:53:33 +01:00
wborgeaud
2e008eac23 Change Merkle tree lead hashing (to change back when #481 lands) 2022-02-14 09:35:08 +01:00
Daniel Lubarov
55ca718a77 Test no longer ignored 2022-02-13 10:51:27 -08:00
wborgeaud
7af2d05828 Save allocation and add const generic bound 2022-02-13 15:04:40 +01:00
wborgeaud
736b65b0a7 PR feedback 2022-02-12 15:18:20 +01:00