| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | AD | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Accumulator for Permutation Argument | |||||||||||||||||||||||||||||
2 | ||||||||||||||||||||||||||||||
3 | A permutation argument is a method of showing that one vector is a permutation of another. | |||||||||||||||||||||||||||||
4 | This sheet shows an example of a permutation argument, to demonstrate the technique behind memory consistency checks in RISC Zero. | |||||||||||||||||||||||||||||
5 | ||||||||||||||||||||||||||||||
6 | Step 1: Prover commits to two sortings of the same data. | |||||||||||||||||||||||||||||
7 | Time-Sorted Execution Trace | Address-Sorted Execution Trace | ||||||||||||||||||||||||||||
8 | Clock Cycle | Address | Value | Read=0; Write=1 | Clock Cycle | Address | Value | Read=0; Write=1 | ||||||||||||||||||||||
9 | 0 | 3 | 17 | 1 | 0 | 3 | 17 | 1 | ||||||||||||||||||||||
10 | 1 | 7 | 3 | 1 | 2 | 3 | 17 | 0 | ||||||||||||||||||||||
11 | 2 | 3 | 17 | 0 | 5 | 3 | 17 | 0 | ||||||||||||||||||||||
12 | 3 | 7 | 9 | 1 | 1 | 7 | 3 | 1 | ||||||||||||||||||||||
13 | 4 | 7 | 9 | 0 | 3 | 7 | 9 | 1 | ||||||||||||||||||||||
14 | 5 | 3 | 17 | 0 | 4 | 7 | 9 | 0 | ||||||||||||||||||||||
15 | ||||||||||||||||||||||||||||||
16 | To enable efficient memory checking, the witness for zkVM proofs include duplicate commitments for memory operations: memory operations are included both in a time-sorted fashion and in an address-sorted fashion. | |||||||||||||||||||||||||||||
17 | To prove correctness, we must both: | |||||||||||||||||||||||||||||
18 | (1) enforce correctness of the memory operations in the address-sorted trace | |||||||||||||||||||||||||||||
19 | (2) enforce correctness of the sorting | |||||||||||||||||||||||||||||
20 | The logic in the black-box labelled "Verifier Requirements" accomplishes (1). The permutation argument accomplishes (2). | |||||||||||||||||||||||||||||
21 | For more on (1), see Jeremy's explanation at zk7. | |||||||||||||||||||||||||||||
22 | ||||||||||||||||||||||||||||||
23 | Step 2: Generate randomness (from Verifier or Fiat-Shamir) | |||||||||||||||||||||||||||||
24 | Random PLONK Mixing Parameters | |||||||||||||||||||||||||||||
25 | a | b | c | d | ||||||||||||||||||||||||||
26 | 14 | 80 | 60 | 43 | ||||||||||||||||||||||||||
27 | ||||||||||||||||||||||||||||||
28 | Step 3: Use randomness to generate accumulators. | |||||||||||||||||||||||||||||
29 | Accumulators for Time-Sorted Trace | |||||||||||||||||||||||||||||
30 | Clock Cycle | Accumulated Value | Accumulation Calculation | Clock Cycle | Accumulated Value | Accumulation Calculation | ||||||||||||||||||||||||
31 | 0 | 1304 | 1+0a+3b+17c+1d | 0 | 1304 | 1+0a+3b+17c+1d | ||||||||||||||||||||||||
32 | 1 | 798 | 1+1a+7b+3c+1d | 1 | 1289 | 1+2a+3b+17c+0d | ||||||||||||||||||||||||
33 | 2 | 1289 | 1+2a+3b+17c+0d | 2 | 1331 | 1+5a+3b+17c+0d | ||||||||||||||||||||||||
34 | 3 | 1186 | 1+3a+7b+9c+1d | 3 | 798 | 1+1a+7b+3c+1d | ||||||||||||||||||||||||
35 | 4 | 1157 | 1+4a+7b+9c+0d | 4 | 1186 | 1+3a+7b+9c+1d | ||||||||||||||||||||||||
36 | 5 | 1331 | 1+5a+3b+17c+0d | 5 | 1157 | 1+4a+7b+9c+0d | ||||||||||||||||||||||||
37 | Time-Sorted Accumulation | 2.44979E+18 | Address-Sorted Accumulation | 2.44979E+18 | ||||||||||||||||||||||||||
38 | ||||||||||||||||||||||||||||||
39 | Key Idea | |||||||||||||||||||||||||||||
40 | If the Address-Sorted Execution Trace is not a permutation of the rows of the Time-Sorted Execution Trace, the accumulators are highly unlikely to match. | |||||||||||||||||||||||||||||
41 | ||||||||||||||||||||||||||||||
42 | Step 4: Use various constraints to check details. | |||||||||||||||||||||||||||||
43 | Details include: | |||||||||||||||||||||||||||||
44 | - Making sure accumulators match | |||||||||||||||||||||||||||||
45 | - Making sure accumulators were constructed correctly | |||||||||||||||||||||||||||||
46 | - Enforcing memory correctness on address-sorted trace, as described above | |||||||||||||||||||||||||||||
47 | ||||||||||||||||||||||||||||||
48 | ||||||||||||||||||||||||||||||
49 | ||||||||||||||||||||||||||||||
50 | ||||||||||||||||||||||||||||||
51 | ||||||||||||||||||||||||||||||
52 | ||||||||||||||||||||||||||||||
53 | ||||||||||||||||||||||||||||||
54 | ||||||||||||||||||||||||||||||
55 | ||||||||||||||||||||||||||||||
56 | ||||||||||||||||||||||||||||||
57 | ||||||||||||||||||||||||||||||
58 | ||||||||||||||||||||||||||||||
59 | ||||||||||||||||||||||||||||||
60 | ||||||||||||||||||||||||||||||
61 | ||||||||||||||||||||||||||||||
62 | ||||||||||||||||||||||||||||||
63 | ||||||||||||||||||||||||||||||
64 | ||||||||||||||||||||||||||||||
65 | ||||||||||||||||||||||||||||||
66 | ||||||||||||||||||||||||||||||
67 | ||||||||||||||||||||||||||||||
68 | ||||||||||||||||||||||||||||||
69 | ||||||||||||||||||||||||||||||
70 | ||||||||||||||||||||||||||||||
71 | ||||||||||||||||||||||||||||||
72 | ||||||||||||||||||||||||||||||
73 | ||||||||||||||||||||||||||||||
74 | ||||||||||||||||||||||||||||||
75 | ||||||||||||||||||||||||||||||
76 | ||||||||||||||||||||||||||||||
77 | ||||||||||||||||||||||||||||||
78 | ||||||||||||||||||||||||||||||
79 | ||||||||||||||||||||||||||||||
80 | ||||||||||||||||||||||||||||||
81 | ||||||||||||||||||||||||||||||
82 | ||||||||||||||||||||||||||||||
83 | ||||||||||||||||||||||||||||||
84 | ||||||||||||||||||||||||||||||
85 | ||||||||||||||||||||||||||||||
86 | ||||||||||||||||||||||||||||||
87 | ||||||||||||||||||||||||||||||
88 | ||||||||||||||||||||||||||||||
89 | ||||||||||||||||||||||||||||||
90 | ||||||||||||||||||||||||||||||
91 | ||||||||||||||||||||||||||||||
92 | ||||||||||||||||||||||||||||||
93 | ||||||||||||||||||||||||||||||
94 | ||||||||||||||||||||||||||||||
95 | ||||||||||||||||||||||||||||||
96 | ||||||||||||||||||||||||||||||
97 | ||||||||||||||||||||||||||||||
98 | ||||||||||||||||||||||||||||||
99 | ||||||||||||||||||||||||||||||
100 | ||||||||||||||||||||||||||||||