From 74ab1ebd1a607eb0eb697ae017fc40f3bc521de6 Mon Sep 17 00:00:00 2001 From: Thomas Piellard Date: Wed, 19 Jun 2024 16:03:19 +0200 Subject: [PATCH] fix: fixed L-05 --- backend/plonk/bn254/solidity.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/plonk/bn254/solidity.go b/backend/plonk/bn254/solidity.go index 08d0b47113..e5e0f73c00 100644 --- a/backend/plonk/bn254/solidity.go +++ b/backend/plonk/bn254/solidity.go @@ -222,6 +222,17 @@ contract PlonkVerifier { revert(ptError, 0x64) } + /// Called when an operation on Bn254 fails + /// @dev for instance when calling EcMul on a point not on Bn254. + function error_mod_exp() { + let ptError := mload(0x40) + mstore(ptError, ERROR_STRING_ID) // selector for function Error(string) + mstore(add(ptError, 0x4), 0x20) + mstore(add(ptError, 0x24), 0xc) + mstore(add(ptError, 0x44), "error mod exp") + revert(ptError, 0x64) + } + /// Called when an operation on Bn254 fails /// @dev for instance when calling EcMul on a point not on Bn254. function error_ec_op() { @@ -1325,7 +1336,7 @@ contract PlonkVerifier { mstore(add(mPtr, 0xa0), R_MOD) let check_staticcall := staticcall(gas(),MOD_EXP,mPtr,0xc0,mPtr,0x20) if eq(check_staticcall, 0) { - + error_mod_exp() } res := mload(mPtr) }