Skip to content
Open
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
3 changes: 1 addition & 2 deletions main/load-tx-rlp.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ nonce0:
0 => A :MSTORE(lengthNonce), JMP(endNonce)

shortNonce:
A - 0x80 => D
D :MSTORE(lengthNonce),CALL(addHashTx)
A - 0x80 => D :MSTORE(lengthNonce),CALL(addHashTx)
:CALL(checkShortRLP)
:CALL(checkNonLeadingZeros)

Expand Down
29 changes: 19 additions & 10 deletions main/opcodes/arithmetic.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,28 @@ zeroOneAddMod:
*/
opMULMOD:
; checks zk-counters
%MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep)
%MAX_CNT_STEPS - STEP - 15 :JMPN(outOfCountersStep)
%MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith)
; check stack underflow
SP - 3 :JMPN(stackUnderflow)
SP - 3 :JMPN(stackUnderflow)
; check out-of-gas
GAS - %GAS_MID_STEP => GAS :JMPN(outOfGas)
GAS - %GAS_MID_STEP => GAS :JMPN(outOfGas)
SP - 1 => SP

$ => A :MLOAD(SP--); [a => A]
$ => B :MLOAD(SP--); [b => B]
$ => C :MLOAD(SP); [N => C]
zkPC+1 => RR :JMP(utilMULMOD); in: [A, B, C] out: [C: (A * B) % C]
C :MSTORE(SP++), JMP(readCode); [C => SP]
$ => C :MLOAD(SP--); [a => A]
$ => E :MLOAD(SP--); [b => B]
$ => A, D :MLOAD(SP); [N => C]
; Check mod is zero, arith would fail otherwise
0 => B
$ :EQ, JMPC(opMULMODZero)
C => A
E => B
0 => C
; compute ARITH_MOD => A*B+C= op (mod D)
${(A*B) % D} => E :ARITH_MOD
E :MSTORE(SP++), JMP(readCode); [C => SP]
opMULMODZero:
0 :MSTORE(SP++), JMP(readCode); [C => SP]

/**
* @link [https://www.evm.codes/#0A?fork=berlin]
Expand All @@ -299,8 +309,7 @@ opEXP:
GAS - %GAS_SLOW_STEP - %EXP_BYTE_GAS * A => GAS :JMPN(outOfGas)

; compute exponentiation
C => A
zkPC+1 => RR :JMP(expAD) ; in: [A, D] out: [A: A ** D]
C => A :CALL(expAD) ; in: [A, D] out: [A: A ** D]
A :MSTORE(SP++), JMP(readCode) ; [a ** exp => SP]

/**
Expand Down
Loading