Skip to content

Commit 29694c1

Browse files
Merge branch 'master' into 780-eip-7951-precompile-for-secp256r1-curve-support
2 parents 2fd0833 + 2a547ac commit 29694c1

File tree

11 files changed

+148
-331
lines changed

11 files changed

+148
-331
lines changed

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ ALU := alu/add/add.zkasm alu/ext alu/mod alu/mul
1212

1313
BIN := bin/bin.zkasm
1414

15-
BLAKE2f_MODEXP_DATA := blake2fmodexpdata
15+
BLAKE2f_MODEXP_DATA_LONDON := blake2fmodexpdata/london
16+
BLAKE2f_MODEXP_DATA_OSAKA := blake2fmodexpdata/osaka
1617

1718
# constraints used in prod for LINEA, with linea block gas limit
1819
BLOCKDATA_LONDON := blockdata/london
@@ -53,7 +54,8 @@ LOG_DATA := logdata
5354
LOG_INFO_LONDON := loginfo/london
5455
LOG_INFO_CANCUN := loginfo/cancun
5556

56-
MMU := mmu
57+
MMU_LONDON := mmu/london
58+
MMU_OSAKA := mmu/osaka
5759

5860
MMIO_LONDON := mmio/london
5961
MMIO_CANCUN := mmio/cancun
@@ -118,7 +120,6 @@ endef
118120
ZKEVM_MODULES_COMMON := ${CONSTANTS} \
119121
${ALU} \
120122
${BIN} \
121-
${BLAKE2f_MODEXP_DATA} \
122123
${BLOCKHASH} \
123124
${EUC} \
124125
${EXP} \
@@ -136,6 +137,7 @@ ZKEVM_MODULES_COMMON := ${CONSTANTS} \
136137
ZKEVM_MODULES_LONDON := ${ZKEVM_MODULES_COMMON} \
137138
${CONSTANTS_LONDON} \
138139
${TABLES_LONDON} \
140+
${BLAKE2f_MODEXP_DATA_LONDON} \
139141
${BLOCKDATA_LONDON} \
140142
${EC_DATA_LONDON} \
141143
${HUB_LONDON} \
@@ -155,6 +157,7 @@ ZKEVM_MODULES_LONDON := ${ZKEVM_MODULES_COMMON} \
155157
ZKEVM_MODULES_SHANGHAI := ${ZKEVM_MODULES_COMMON} \
156158
${CONSTANTS_LONDON} \
157159
${TABLES_LONDON} \
160+
${BLAKE2f_MODEXP_DATA_LONDON} \
158161
${BLOCKDATA_PARIS} \
159162
${EC_DATA_LONDON} \
160163
${HUB_SHANGHAI} \
@@ -169,8 +172,9 @@ ZKEVM_MODULES_SHANGHAI := ${ZKEVM_MODULES_COMMON} \
169172
${TXN_DATA_SHANGHAI}
170173

171174
ZKEVM_MODULES_CANCUN := ${ZKEVM_MODULES_COMMON} \
172-
${CONSTANTS_CANCUN} \
175+
${CONSTANTS_CANCUN} \
173176
${TABLES_CANCUN} \
177+
${BLAKE2f_MODEXP_DATA_LONDON} \
174178
${BLOCKDATA_CANCUN} \
175179
${BLS_CANCUN} \
176180
${EC_DATA_LONDON} \
@@ -189,6 +193,7 @@ ZKEVM_MODULES_CANCUN := ${ZKEVM_MODULES_COMMON} \
189193
ZKEVM_MODULES_PRAGUE := ${ZKEVM_MODULES_COMMON} \
190194
${CONSTANTS_PRAGUE} \
191195
${TABLES_PRAGUE} \
196+
${BLAKE2f_MODEXP_DATA_LONDON} \
192197
${BLOCKDATA_CANCUN} \
193198
${BLS_PRAGUE} \
194199
${EC_DATA_LONDON} \
@@ -207,6 +212,7 @@ ZKEVM_MODULES_PRAGUE := ${ZKEVM_MODULES_COMMON} \
207212
ZKEVM_MODULES_OSAKA := ${ZKEVM_MODULES_COMMON} \
208213
${CONSTANTS_OSAKA} \
209214
${TABLES_PRAGUE} \
215+
${BLAKE2f_MODEXP_DATA_OSAKA} \
210216
${BLOCKDATA_CANCUN} \
211217
${BLS_PRAGUE} \
212218
${EC_DATA_OSAKA} \
File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(module blake2fmodexpdata)
2+
3+
(defconst
4+
INDEX_MAX_MODEXP 31
5+
INDEX_MAX_MODEXP_BASE INDEX_MAX_MODEXP
6+
INDEX_MAX_MODEXP_EXPONENT INDEX_MAX_MODEXP
7+
INDEX_MAX_MODEXP_MODULUS INDEX_MAX_MODEXP
8+
INDEX_MAX_MODEXP_RESULT INDEX_MAX_MODEXP
9+
INDEX_MAX_BLAKE_DATA 12
10+
INDEX_MAX_BLAKE_PARAMS 1
11+
INDEX_MAX_BLAKE_RESULT 3)
12+
13+
File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(module blake2fmodexpdata)
2+
3+
(defcolumns
4+
(STAMP :i16)
5+
(ID :i32)
6+
(PHASE :byte)
7+
(INDEX :byte :display :dec)
8+
(INDEX_MAX :byte :display :dec)
9+
(LIMB :i128 :display :bytes)
10+
(IS_MODEXP_BASE :binary@prove)
11+
(IS_MODEXP_EXPONENT :binary@prove)
12+
(IS_MODEXP_MODULUS :binary@prove)
13+
(IS_MODEXP_RESULT :binary@prove)
14+
(IS_BLAKE_DATA :binary@prove)
15+
(IS_BLAKE_PARAMS :binary@prove)
16+
(IS_BLAKE_RESULT :binary@prove)
17+
)
18+
File renamed without changes.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
(module blake2fmodexpdata)
2+
3+
(defun (flag-sum)
4+
(+ IS_MODEXP_BASE
5+
IS_MODEXP_EXPONENT
6+
IS_MODEXP_MODULUS
7+
IS_MODEXP_RESULT
8+
IS_BLAKE_DATA
9+
IS_BLAKE_PARAMS
10+
IS_BLAKE_RESULT))
11+
12+
(defun (phase-sum)
13+
(+ (* PHASE_MODEXP_BASE IS_MODEXP_BASE)
14+
(* PHASE_MODEXP_EXPONENT IS_MODEXP_EXPONENT)
15+
(* PHASE_MODEXP_MODULUS IS_MODEXP_MODULUS)
16+
(* PHASE_MODEXP_RESULT IS_MODEXP_RESULT)
17+
(* PHASE_BLAKE_DATA IS_BLAKE_DATA)
18+
(* PHASE_BLAKE_PARAMS IS_BLAKE_PARAMS)
19+
(* PHASE_BLAKE_RESULT IS_BLAKE_RESULT)))
20+
21+
(defun (index-max-sum)
22+
(+ (* INDEX_MAX_MODEXP_BASE IS_MODEXP_BASE)
23+
(* INDEX_MAX_MODEXP_EXPONENT IS_MODEXP_EXPONENT)
24+
(* INDEX_MAX_MODEXP_MODULUS IS_MODEXP_MODULUS)
25+
(* INDEX_MAX_MODEXP_RESULT IS_MODEXP_RESULT)
26+
(* INDEX_MAX_BLAKE_DATA IS_BLAKE_DATA)
27+
(* INDEX_MAX_BLAKE_PARAMS IS_BLAKE_PARAMS)
28+
(* INDEX_MAX_BLAKE_RESULT IS_BLAKE_RESULT)))
29+
30+
(defconstraint no-stamp-no-flag ()
31+
(if-zero STAMP
32+
(vanishes! (flag-sum))
33+
(eq! (flag-sum) 1)))
34+
35+
(defconstraint set-phase-and-index ()
36+
(begin (eq! PHASE (phase-sum))
37+
(eq! INDEX_MAX (index-max-sum))))
38+
39+
(defconstraint stamp-constancies ()
40+
(stamp-constancy STAMP ID))
41+
42+
(defconstraint index-constancies (:guard INDEX)
43+
(remained-constant! (phase-sum)))
44+
45+
(defconstraint first-row (:domain {0})
46+
(vanishes! STAMP))
47+
48+
(defconstraint no-stamp-nothing ()
49+
(if-zero STAMP
50+
(begin (vanishes! ID)
51+
(vanishes! (next INDEX)))))
52+
53+
(defun (stamp-increment)
54+
(force-bin (+ (* (- 1 IS_MODEXP_BASE) (next IS_MODEXP_BASE))
55+
(* (- 1 IS_BLAKE_DATA) (next IS_BLAKE_DATA)))))
56+
57+
(defconstraint stamp-increases ()
58+
(will-inc! STAMP (stamp-increment)))
59+
60+
(defun (transition-bit)
61+
(force-bin (+ (* IS_MODEXP_BASE (next IS_MODEXP_EXPONENT))
62+
(* IS_MODEXP_EXPONENT (next IS_MODEXP_MODULUS))
63+
(* IS_MODEXP_MODULUS (next IS_MODEXP_RESULT))
64+
(* IS_MODEXP_RESULT
65+
(+ (next IS_MODEXP_BASE) (next IS_BLAKE_DATA)))
66+
(* IS_BLAKE_DATA (next IS_BLAKE_PARAMS))
67+
(* IS_BLAKE_PARAMS (next IS_BLAKE_RESULT))
68+
(* IS_BLAKE_RESULT
69+
(+ (next IS_MODEXP_BASE) (next IS_BLAKE_DATA))))))
70+
71+
(defconstraint heartbeat (:guard STAMP)
72+
(if-zero (- INDEX_MAX INDEX)
73+
(eq! (transition-bit) 1)
74+
(will-inc! INDEX 1)))
75+
76+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(defun (blake2fmodexpdata-into-wcp-oob-into-wcp-activation-flag)
2+
(force-bin (* (~ blake2fmodexpdata.STAMP)
3+
(- blake2fmodexpdata.STAMP (prev blake2fmodexpdata.STAMP)))))
4+
5+
(defclookup
6+
blake2fmodexpdata-into-wcp
7+
;; target colums (in WCP)
8+
(
9+
wcp.ARG_1_HI
10+
wcp.ARG_1_LO
11+
wcp.ARG_2_HI
12+
wcp.ARG_2_LO
13+
wcp.RES
14+
wcp.INST
15+
)
16+
;; source selector
17+
(blake2fmodexpdata-into-wcp-oob-into-wcp-activation-flag)
18+
;; source columns
19+
(
20+
0
21+
(prev blake2fmodexpdata.ID)
22+
0
23+
blake2fmodexpdata.ID
24+
1
25+
EVM_INST_LT
26+
))
27+
28+

0 commit comments

Comments
 (0)