Closed jayden-sudo closed 9 months ago
FCL_Elliptic_ZZ.ecdsa_verify
cd solidity/tests/WebAuthn_forge forge test --ffi --match-test test_webauthn_Base64URL_checkSignature --gas-report
Changed from calling ModExp to staticcall ModExp, reducing the number of parameters.
view
Replaced uint256[6] memory pointer with pointer := mload(0x40), reducing calls like MSTORE(0x40).
uint256[6] memory pointer
pointer := mload(0x40)
MSTORE(0x40)
Performed assembly optimizations.
// before eq(x, 0) // after iszero(x) ```
Calldata cache, avoid frequent call of calldataload
function f(uint256[2] calldata rs) returns (bool success){ // before if (rs[0] == 0 || rs[0] >= n || rs[1] == 0 || rs[1] >= n){ return false; } // after uint256 r = rs[0]; uint256 s = rs[1]; } ```
With the code equivalent, executing
FCL_Elliptic_ZZ.ecdsa_verify
reduced gas cost by 2600 gas:Gas Optimization Records for ecdsa_verify:
Changed from calling ModExp to staticcall ModExp, reducing the number of parameters.
view
.Replaced
uint256[6] memory pointer
withpointer := mload(0x40)
, reducing calls likeMSTORE(0x40)
.Performed assembly optimizations.
Calldata cache, avoid frequent call of calldataload