Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address additional comments on #712 #726

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions aggregator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ and `batch_pi_hash` matches public input.
3. batch_data_hash and chunk[i].pi_hash use a same chunk[i].data_hash when chunk[i] is not padded

```
for i in 1 ... __n__
for i in 1 ... n
chunk_pi_hash := keccak(chain_id || prev_state_root || post_state_root || withdraw_root || chunk_data_hash)
```

This is done by compute the RLCs of chunk[i]'s data_hash for `i=0..k`, and then check the RLC matches the one from the keccak table.

4. chunks are continuous when they are not padded: they are linked via the state roots.

for i in 1 ... __k-1__
```
c_i.post_state_root == c_{i+1}.prev_state_root
for i in 1 ... k-1
c_i.post_state_root == c_{i+1}.prev_state_root
```

5. All the chunks use a same chain id. __Static__.
```
for i in 1 ... __n__
for i in 1 ... n
batch.chain_id == chunk[i].chain_id
```

Expand All @@ -131,7 +131,7 @@ This is done via comparing the `data_rlc` of `chunk_{i-1}` and ` chunk_{i}`.
![Dynamic_inputs](./figures/hash_table.jpg)


Our keccak table uses `2^19` rows. Each keccak round takes `300` rows. When the number of round is is less than $2^19/300$, the cell manager will fill in the rest of the rows with dummy hashes.
Our keccak table uses $2^{19}$ rows. Each keccak round takes `300` rows. When the number of round is is less than $2^{19}/300$, the cell manager will fill in the rest of the rows with dummy hashes.

The only hash that uses dynamic number of rounds is the last hash.
Suppose we target for `MAX_AGG_SNARK = 10`. Then, the last hash function will take no more than `32 * 10 /136 = 3` rounds.
Expand Down
Binary file modified aggregator/figures/architecture.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion aggregator/src/aggregation/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl Circuit<Fr> for AggregationCircuit {
);

region.constrain_equal(
// in the keccak table, the input and output date have different
// in the keccak table, the input and output data have different
// endianess
chunk_pi_hash_digests[i][j * 8 + k].cell(),
snark_inputs[i * DIGEST_LEN + (3 - j) * 8 + k].cell(),
Expand Down
11 changes: 3 additions & 8 deletions aggregator/src/aggregation/rlc/gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@ impl RlcConfig {
region.assign_fixed(|| "const two", self.fixed, 2, || Value::known(Fr::from(2)))?;
region.assign_fixed(|| "const four", self.fixed, 3, || Value::known(Fr::from(4)))?;
region.assign_fixed(|| "const nine", self.fixed, 4, || Value::known(Fr::from(9)))?;
region.assign_fixed(|| "const 32", self.fixed, 5, || Value::known(Fr::from(32)))?;
region.assign_fixed(
|| "const thirty two",
self.fixed,
5,
|| Value::known(Fr::from(32)),
)?;
region.assign_fixed(
|| "const one hundred and thirty six",
|| "const 136",
self.fixed,
6,
|| Value::known(Fr::from(136)),
)?;
region.assign_fixed(
|| "const two to thirty two",
|| "const 2^32",
self.fixed,
7,
|| Value::known(Fr::from(1 << 32)),
Expand Down