diff --git a/main/load-tx-rlp.zkasm b/main/load-tx-rlp.zkasm index 1a34172b..a7056bd7 100644 --- a/main/load-tx-rlp.zkasm +++ b/main/load-tx-rlp.zkasm @@ -52,7 +52,7 @@ endList: :CALL(divARITH) $ => B :MLOAD(arithRes1) $ => D :MLOAD(cntKeccakPreProcess) - %MAX_CNT_KECCAK_F - CNT_KECCAK_F - B - D - 1:JMPN(outOfCountersKeccak) + %MAX_CNT_KECCAK_F - CNT_KECCAK_F - B - D - 1:JMPN(handleOOCatRLP) ;; Read RLP 'nonce' ; 64 bits max @@ -322,18 +322,17 @@ vREADTx: ;; increase number of transaction to process $ => A :MLOAD(pendingTxs) A + 1 => A :MSTORE(pendingTxs) -;; check signature +;; compute signature $ => A :HASHKDIGEST(E) - $ => B :MLOAD(txR) - $ => C :MLOAD(txS) - $ => D :MLOAD(txV) - :CALL(ecrecover) - A :MSTORE(txSrcAddr) + A :MSTORE(txHash) :JMP(txLoopRLP) ;;;;;;;;; ;; E - Handler error RLP fields ;;;;;;;;; +handleOOCatRLP: + ${eventLog(onError, OOCK)} + $ => SR :MLOAD(batchSR) invalidTxRLP: ;; Append all missing 'batchL2Data' to 'batchDataHash' bytes diff --git a/main/process-tx.zkasm b/main/process-tx.zkasm index ffb45e29..373f8022 100644 --- a/main/process-tx.zkasm +++ b/main/process-tx.zkasm @@ -32,9 +32,16 @@ processTx: ; Minimum of 100000 steps left to process a tx %MAX_CNT_STEPS - STEP - 100000 :JMPN(outOfCountersStep) - ; check from address + $ => A :MLOAD(txHash) + ; Check the signature + $ => B :MLOAD(txR) + $ => C :MLOAD(txS) + $ => D :MLOAD(txV) + :CALL(ecrecover) + ; Check result is non-zero +checkAndSaveFrom: 0 => B - $ => A :MLOAD(txSrcAddr) + A :MSTORE(txSrcAddr) A :MSTORE(txSrcOriginAddr) $ :EQ,JMPC(invalidIntrinsicTxSignature) diff --git a/main/vars.zkasm b/main/vars.zkasm index b3b78dee..919e8a24 100644 --- a/main/vars.zkasm +++ b/main/vars.zkasm @@ -60,6 +60,7 @@ VAR CTX txS ; transaction parameter: ecdsa signature S VAR CTX txR ; transaction parameter: ecdsa signature R VAR CTX txV ; transaction parameter: ecdsa signature V VAR CTX txSrcAddr ; address that sends a transaction 'message.sender' +VAR CTX txHash ; signed tx hash VAR CTX txCalldataLen ; calldata length VAR CTX isCreateContract ; flag to determine if a transaction will create a new contract VAR CTX createContractAddress ; address computed of a new contract