Skip to content
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ ALU := alu/add/add.zkasm alu/ext alu/mod alu/mul

BIN := bin/bin.zkasm

BLAKE2f_MODEXP_DATA := blake2fmodexpdata
BLAKE2f_MODEXP_DATA_LONDON := blake2fmodexpdata/london
BLAKE2f_MODEXP_DATA_OSAKA := blake2fmodexpdata/osaka

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

MMU := mmu
MMU_LONDON := mmu/london
MMU_OSAKA := mmu/osaka

MMIO_LONDON := mmio/london
MMIO_CANCUN := mmio/cancun
Expand Down Expand Up @@ -118,7 +120,6 @@ endef
ZKEVM_MODULES_COMMON := ${CONSTANTS} \
${ALU} \
${BIN} \
${BLAKE2f_MODEXP_DATA} \
${BLOCKHASH} \
${EUC} \
${EXP} \
Expand All @@ -136,6 +137,7 @@ ZKEVM_MODULES_COMMON := ${CONSTANTS} \
ZKEVM_MODULES_LONDON := ${ZKEVM_MODULES_COMMON} \
${CONSTANTS_LONDON} \
${TABLES_LONDON} \
${BLAKE2f_MODEXP_DATA_LONDON} \
${BLOCKDATA_LONDON} \
${EC_DATA_LONDON} \
${HUB_LONDON} \
Expand All @@ -155,6 +157,7 @@ ZKEVM_MODULES_LONDON := ${ZKEVM_MODULES_COMMON} \
ZKEVM_MODULES_SHANGHAI := ${ZKEVM_MODULES_COMMON} \
${CONSTANTS_LONDON} \
${TABLES_LONDON} \
${BLAKE2f_MODEXP_DATA_LONDON} \
${BLOCKDATA_PARIS} \
${EC_DATA_LONDON} \
${HUB_SHANGHAI} \
Expand All @@ -169,8 +172,9 @@ ZKEVM_MODULES_SHANGHAI := ${ZKEVM_MODULES_COMMON} \
${TXN_DATA_SHANGHAI}

ZKEVM_MODULES_CANCUN := ${ZKEVM_MODULES_COMMON} \
${CONSTANTS_CANCUN} \
${CONSTANTS_CANCUN} \
${TABLES_CANCUN} \
${BLAKE2f_MODEXP_DATA_LONDON} \
${BLOCKDATA_CANCUN} \
${BLS_CANCUN} \
${EC_DATA_LONDON} \
Expand All @@ -189,6 +193,7 @@ ZKEVM_MODULES_CANCUN := ${ZKEVM_MODULES_COMMON} \
ZKEVM_MODULES_PRAGUE := ${ZKEVM_MODULES_COMMON} \
${CONSTANTS_PRAGUE} \
${TABLES_PRAGUE} \
${BLAKE2f_MODEXP_DATA_LONDON} \
${BLOCKDATA_CANCUN} \
${BLS_PRAGUE} \
${EC_DATA_LONDON} \
Expand All @@ -207,6 +212,7 @@ ZKEVM_MODULES_PRAGUE := ${ZKEVM_MODULES_COMMON} \
ZKEVM_MODULES_OSAKA := ${ZKEVM_MODULES_COMMON} \
${CONSTANTS_OSAKA} \
${TABLES_PRAGUE} \
${BLAKE2f_MODEXP_DATA_OSAKA} \
${BLOCKDATA_CANCUN} \
${BLS_PRAGUE} \
${EC_DATA_OSAKA} \
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions blake2fmodexpdata/osaka/columns.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(module blake2fmodexpdata)

(defcolumns
(STAMP :i16)
(ID :i32)
(PHASE :byte)
(INDEX :byte :display :dec)
(INDEX_MAX :byte :display :dec)
(LIMB :i128 :display :bytes)
(IS_MODEXP_BASE :binary@prove)
(IS_MODEXP_EXPONENT :binary@prove)
(IS_MODEXP_MODULUS :binary@prove)
(IS_MODEXP_RESULT :binary@prove)
(IS_BLAKE_DATA :binary@prove)
(IS_BLAKE_PARAMS :binary@prove)
(IS_BLAKE_RESULT :binary@prove)
)

13 changes: 13 additions & 0 deletions blake2fmodexpdata/osaka/constants.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(module blake2fmodexpdata)

(defconst
INDEX_MAX_MODEXP 63
INDEX_MAX_MODEXP_BASE INDEX_MAX_MODEXP
INDEX_MAX_MODEXP_EXPONENT INDEX_MAX_MODEXP
INDEX_MAX_MODEXP_MODULUS INDEX_MAX_MODEXP
INDEX_MAX_MODEXP_RESULT INDEX_MAX_MODEXP
INDEX_MAX_BLAKE_DATA 12
INDEX_MAX_BLAKE_PARAMS 1
INDEX_MAX_BLAKE_RESULT 3)


76 changes: 76 additions & 0 deletions blake2fmodexpdata/osaka/constraints.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
(module blake2fmodexpdata)

(defun (flag-sum)
(+ IS_MODEXP_BASE
IS_MODEXP_EXPONENT
IS_MODEXP_MODULUS
IS_MODEXP_RESULT
IS_BLAKE_DATA
IS_BLAKE_PARAMS
IS_BLAKE_RESULT))

(defun (phase-sum)
(+ (* PHASE_MODEXP_BASE IS_MODEXP_BASE)
(* PHASE_MODEXP_EXPONENT IS_MODEXP_EXPONENT)
(* PHASE_MODEXP_MODULUS IS_MODEXP_MODULUS)
(* PHASE_MODEXP_RESULT IS_MODEXP_RESULT)
(* PHASE_BLAKE_DATA IS_BLAKE_DATA)
(* PHASE_BLAKE_PARAMS IS_BLAKE_PARAMS)
(* PHASE_BLAKE_RESULT IS_BLAKE_RESULT)))

(defun (index-max-sum)
(+ (* INDEX_MAX_MODEXP_BASE IS_MODEXP_BASE)
(* INDEX_MAX_MODEXP_EXPONENT IS_MODEXP_EXPONENT)
(* INDEX_MAX_MODEXP_MODULUS IS_MODEXP_MODULUS)
(* INDEX_MAX_MODEXP_RESULT IS_MODEXP_RESULT)
(* INDEX_MAX_BLAKE_DATA IS_BLAKE_DATA)
(* INDEX_MAX_BLAKE_PARAMS IS_BLAKE_PARAMS)
(* INDEX_MAX_BLAKE_RESULT IS_BLAKE_RESULT)))

(defconstraint no-stamp-no-flag ()
(if-zero STAMP
(vanishes! (flag-sum))
(eq! (flag-sum) 1)))

(defconstraint set-phase-and-index ()
(begin (eq! PHASE (phase-sum))
(eq! INDEX_MAX (index-max-sum))))

(defconstraint stamp-constancies ()
(stamp-constancy STAMP ID))

(defconstraint index-constancies (:guard INDEX)
(remained-constant! (phase-sum)))

(defconstraint first-row (:domain {0})
(vanishes! STAMP))

(defconstraint no-stamp-nothing ()
(if-zero STAMP
(begin (vanishes! ID)
(vanishes! (next INDEX)))))

(defun (stamp-increment)
(force-bin (+ (* (- 1 IS_MODEXP_BASE) (next IS_MODEXP_BASE))
(* (- 1 IS_BLAKE_DATA) (next IS_BLAKE_DATA)))))

(defconstraint stamp-increases ()
(will-inc! STAMP (stamp-increment)))

(defun (transition-bit)
(force-bin (+ (* IS_MODEXP_BASE (next IS_MODEXP_EXPONENT))
(* IS_MODEXP_EXPONENT (next IS_MODEXP_MODULUS))
(* IS_MODEXP_MODULUS (next IS_MODEXP_RESULT))
(* IS_MODEXP_RESULT
(+ (next IS_MODEXP_BASE) (next IS_BLAKE_DATA)))
(* IS_BLAKE_DATA (next IS_BLAKE_PARAMS))
(* IS_BLAKE_PARAMS (next IS_BLAKE_RESULT))
(* IS_BLAKE_RESULT
(+ (next IS_MODEXP_BASE) (next IS_BLAKE_DATA))))))

(defconstraint heartbeat (:guard STAMP)
(if-zero (- INDEX_MAX INDEX)
(eq! (transition-bit) 1)
(will-inc! INDEX 1)))


28 changes: 28 additions & 0 deletions blake2fmodexpdata/osaka/lookups/blakemodexp_into_wcp.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(defun (blake2fmodexpdata-into-wcp-oob-into-wcp-activation-flag)
(force-bin (* (~ blake2fmodexpdata.STAMP)
(- blake2fmodexpdata.STAMP (prev blake2fmodexpdata.STAMP)))))

(defclookup
blake2fmodexpdata-into-wcp
;; target colums (in WCP)
(
wcp.ARG_1_HI
wcp.ARG_1_LO
wcp.ARG_2_HI
wcp.ARG_2_LO
wcp.RES
wcp.INST
)
;; source selector
(blake2fmodexpdata-into-wcp-oob-into-wcp-activation-flag)
;; source columns
(
0
(prev blake2fmodexpdata.ID)
0
blake2fmodexpdata.ID
1
EVM_INST_LT
))


2 changes: 2 additions & 0 deletions constants/constants.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
GAS_CONST_IDENTITY 15
GAS_CONST_IDENTITY_WORD 3
GAS_CONST_MODEXP 200
GAS_CONST_MODEXP_EIP_7823 500
GAS_CONST_ECADD 150
GAS_CONST_ECMUL 6000
GAS_CONST_ECPAIRING 45000
Expand Down Expand Up @@ -270,6 +271,7 @@
HISTORY_STORAGE_ADDRESS_HI 0x0000f908
HISTORY_STORAGE_ADDRESS_LO 0x27f1c53a10cb7a02335b175320002935
EIP_7825_TRANSACTION_GAS_LIMIT_CAP 0x1000000 ;; 2^24 == 16777216 appears in OSAKA
EIP_7823_MODEXP_UPPER_BYTE_SIZE_BOUND 1024
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LINEA MISC ;;
Expand Down
4 changes: 2 additions & 2 deletions hub/osaka/columns/miscellaneous.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

;; EXP columns (DONE)
( EXP_INST :i16 )
( EXP_DATA :array [5] :i128 )
( EXP_DATA :array [5] :i128 ) ;;""

;; MMU columns (DONE)
( MMU_INST :i16 :display :hex)
Expand Down Expand Up @@ -52,7 +52,7 @@

;; OOB columns
(OOB_INST :i16 )
(OOB_DATA :array[1:10] :i128 )
(OOB_DATA :array[1:10] :i128 ) ;;""

;; STP columns
( STP_INSTRUCTION :byte )
Expand Down
Loading
Loading