From 503c5714cf62b6a4909cc3a58ef96082be1a287f Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Wed, 20 Sep 2023 01:41:55 +0700 Subject: [PATCH] Fix MODEXP precompile success validation --- contracts/BN256G2.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/BN256G2.sol b/contracts/BN256G2.sol index a08ffa5..f4418e9 100644 --- a/contracts/BN256G2.sol +++ b/contracts/BN256G2.sol @@ -370,7 +370,8 @@ library BN256G2 { mstore(add(freemem,0x60), a) mstore(add(freemem,0x80), sub(n, 2)) mstore(add(freemem,0xA0), n) - success := staticcall(sub(gas(), 2000), 5, freemem, 0xC0, freemem, 0x20) + pop(staticcall(sub(gas(), 2000), 5, freemem, 0xC0, freemem, 0x20)) + success := eq(returndatasize(), 0x20) result := mload(freemem) } require(success, "error calculating the modular inverse");