Closed jayden-sudo closed 1 year ago
- Inlining is important inside of a loop, when it is only a single call, the benefit is negligible and will render audit much complicated compared to gain.
- It is hard to read the PR because of the indentation changes, there is a linter in the makefile in WebAuthn_forge: make lint-write (i might have forgotten to use it, will check and will PR a lint only change, separating linting from code modification)
Yes, thank you for the response. I completely agree with your suggestion. So, I just submitted a version that aligns with your advice: #18
With the code equivalent, executing
FCL_Elliptic_ZZ.ecdsa_verify
reduced gas cost by 3249 gas:Gas Optimization Records for ecdsa_verify:
Changed from calling ModExp to staticcall ModExp, reducing the number of parameters.
view
.Changed the
call ModExp gas
fromnot(0)
to a constantmax_uint256
, reducing opcode calls.Replaced
uint256[6] memory pointer
withpointer := mload(0x40)
, reducing calls likeMSTORE(0x40)
.Performed assembly optimizations.
Add
ecAff_add_affinepoint
:ecAff_add(gx, gy, Q0, Q1)
->ecAff_add_affinepoint(Q0, Q1)
Calldata cache, avoid frequent call of calldataload
inline point on curve check
Inline FCL_nModInv(s)