1856 Commits

Author SHA1 Message Date
wborgeaud
5c1173379e Compiles 2022-02-21 16:05:24 +01:00
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
Nicholas Ward
20fc5e2da5 merge fixes 2022-02-16 11:36:51 -08:00
Nicholas Ward
74cf5da8e0 clippy 2022-02-16 11:31:45 -08:00
Nicholas Ward
25555c15e0 fixed native GLV; fixed precompute window; other fixes 2022-02-16 11:31:43 -08:00
Nicholas Ward
8ad193db17 use windowed mul in GLV 2022-02-16 11:31:29 -08:00
Nicholas Ward
1e3743f46c fmt 2022-02-16 11:31:29 -08:00
Nicholas Ward
0140f7a3cf fixes 2022-02-16 11:31:29 -08:00
Nicholas Ward
e88564ce5e correct point subtraction 2022-02-16 11:31:29 -08:00
Nicholas Ward
f77192ef66 fmt 2022-02-16 11:31:29 -08:00
Nicholas Ward
f6f7e55191 windowed mul fixes...... 2022-02-16 11:31:26 -08:00
Nicholas Ward
a89b306cf8 fmt 2022-02-16 11:30:39 -08:00
Nicholas Ward
12d5239be6 fix 2022-02-16 11:30:39 -08:00
Nicholas Ward
f67e12ee64 fmt 2022-02-16 11:30:39 -08:00
Nicholas Ward
ad1aa4ae10 fixed is_equal 2022-02-16 11:30:39 -08:00
Nicholas Ward
3787f3be22 conditional add 2022-02-16 11:30:39 -08:00
Nicholas Ward
84edb55b63 fmt 2022-02-16 11:30:39 -08:00
Nicholas Ward
134a04220d is_equal function 2022-02-16 11:30:39 -08:00
Nicholas Ward
978e2ee974 conditional add (doesn't work yet) 2022-02-16 11:30:39 -08:00
Nicholas Ward
8bab62b83d fix 2022-02-16 11:30:39 -08:00
Nicholas Ward
23cfe91079 fix 2022-02-16 11:30:39 -08:00
Nicholas Ward
64a09616e2 fmt 2022-02-16 11:30:39 -08:00
Nicholas Ward
294a738dc9 moved to new file, and curve random access test 2022-02-16 11:30:39 -08:00
Nicholas Ward
5603816f3b fix 2022-02-16 11:30:39 -08:00
Nicholas Ward
58492a0ace fmt 2022-02-16 11:30:39 -08:00
Nicholas Ward
67b7193e82 test for split nonnative, and fixes 2022-02-16 11:30:39 -08:00
Nicholas Ward
53a2a92258 windowed multiplication in circuit 2022-02-16 11:30:32 -08:00
Nicholas Ward
dc44baa592 simpler test 2022-02-16 11:29:13 -08:00
Nicholas Ward
140f0590bc fmt 2022-02-16 11:29:13 -08:00
Nicholas Ward
5aaa5710a8 test for GLV gadget 2022-02-16 11:29:13 -08:00
Nicholas Ward
5917a09cee split out glv_mul function 2022-02-16 11:29:13 -08:00
Nicholas Ward
e92d4c25be fixed clippy 2022-02-16 11:29:13 -08:00
Nicholas Ward
c3126796c0 GLV in circuit 2022-02-16 11:29:13 -08:00
Nicholas Ward
c279c779a3 fixed clippy 2022-02-16 11:29:13 -08:00
Nicholas Ward
fd7abb35da GLV mul 2022-02-16 11:29:13 -08:00
Nicholas Ward
2f4da9b49d added native GLV compose 2022-02-16 11:29:13 -08: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