Skip to content

Commit f27b9d9

Browse files
committed
spec/keccak: update core chip
1 parent d621096 commit f27b9d9

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

spec/keccak.typ

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
#show: book-page(chip.name)
1616
#let keccak = raw(chip.name)
1717

18-
The #keccak chip applies the keccak permutation.
18+
The #keccak chip applies the keccak permutation $kappa$ to a given memory range.
19+
20+
This permutation $kappa: FF_2^1600 -> FF_2^1600$ operates on 1600 bits and is composed of 24 applications of round-permutation $Lambda: FF_2^1600 times NN -> FF_2^1600$, where the additional parameter is the round constant.
21+
$Lambda$ is defined as the composition $iota compose chi compose pi compose rho compose theta$, where only $iota$ depends on the round constant.
22+
#footnote("More details on the KECCAK permutation: FIPS 202, NIST, " + link("https://csrc.nist.gov/pubs/fips/202/final"))
23+
24+
The keccak accelerator comprises two chips: a core chip that interacts with the memory, and a round chip that applies the round permutation.
25+
1926

2027
= Core chip
2128
== Columns
@@ -25,27 +32,21 @@ The #keccak chip applies the keccak permutation.
2532
The #keccak chip is comprised of #nr_variables variables that are expressed using #nr_columns columns:
2633
#render_chip_variable_table(chip, config)
2734

28-
== Assumptions
29-
30-
// #render_chip_assumptions(chip, config)
31-
3235
== Constraints
3336
In this VM, we assign syscall number -2 to the #keccak accelerator.
3437
The chip therefore contributes the following interaction to the lookup-argument:
3538
#render_constraint_table(chip, config, groups: "output")
3639

37-
The address containing the state to be permuted are passed in as argument `A0 = x10`.
38-
This address is read into `addr`, from which `state_ptr` --- the collection of pointers to all lanes of the state --- is derived.
39-
The state is then read into `input_state`, while the `output_state` is written back to the indicated address.
40+
The address containing the state to be permuted is passed in as argument `A0 = x10`.
41+
The following constraints describe that this address is read into `addr` (@keccak:c:read_addr), from which `state_ptr` --- the collection of pointers to all lanes of the state --- is derived (@keccak:c:state_ptr).
42+
The state is then read into `input_state`, while the `output_state` is written back to the indicated address (@keccack:c:load_store_state).
4043
#render_constraint_table(chip, config, groups: "mem")
4144

42-
Lastly, the input state is pushed to the Keccak-round function, while the output after 24 rounds is taken off the bus.
45+
Lastly, the input state is pushed to the Keccak-round function, while the output after 24 rounds is taken off the bus:
4346
#render_constraint_table(chip, config, groups: "round")
4447

4548
== Padding
46-
47-
The table can be padded to the next power of two with the following value assignments:
48-
49+
The #keccak table can be padded to the next power of two with the following value assignments:
4950
#render_chip_padding_table(chip, config)
5051

5152
= Round chip

spec/src/keccak.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ tag = "MEMW"
6060
input = [1, ["cast", ["*", 2, 10], "DWordWL"], "addr", "timestamp", 1, 0, 0]
6161
output = "addr"
6262
multiplicity = "μ"
63+
ref = "keccak:c:read_addr"
6364

6465
[[constraints.mem]]
6566
kind = "template"
6667
tag = "ADD"
6768
input = [["cast", "addr", "DWordWL"], ["cast", ["*", 8, ["+", ["*", 5, "x"], "y"]], "DWordWL"]]
6869
output = ["cast", ["idx", ["idx", "state_ptr", "x"], "y"], "DWordWL"]
6970
iters = [["x", 0, 4], ["y", 0, 4]]
71+
ref = "keccak:c:state_ptr"
7072

7173
[[constraints.mem]]
7274
kind = "interaction"
@@ -82,6 +84,7 @@ input = [0, ["cast", ["idx", ["idx", "state_ptr", "x"], "y"], "DWordWL"], ["idx"
8284
output = ["idx", ["idx", "input_state", "x"], "y"]
8385
iters = [["x", 0, 4], ["y", 0, 4]]
8486
multiplicity = "μ"
87+
ref = "keccack:c:load_store_state"
8588

8689
[[constraint_groups]]
8790
name = "round"

0 commit comments

Comments
 (0)