Labels: medium-difficulty, yul, math, gasguard
Difficulty: Medium
Module: contracts/math/
🧠 Concept
Implement a low-level Yul library for modular arithmetic operations (mulmod, addmod) that avoids high-level Solidity math safety checks.
⚠️ Problem
Solidity's default math operations inject overflow checks before executing arithmetic, whereas native EVM opcodes MULMOD and ADDMOD handle arbitrary precision safely in hardware.
📁 Implementation Scope
contracts/math/FastModMath.sol
test/math/FastModMath.test.ts
🛠️ Requirements
- Implement
safeMulMod(uint256 x, uint256 y, uint256 m) returns (uint256 result) in Yul assembly.
- Execute native
mulmod(x, y, m) opcode directly with inline division-by-zero validation.
🎯 Acceptance Criteria
Labels:
medium-difficulty,yul,math,gasguardDifficulty: Medium
Module:
contracts/math/🧠 Concept
Implement a low-level Yul library for modular arithmetic operations (
mulmod,addmod) that avoids high-level Solidity math safety checks.Solidity's default math operations inject overflow checks before executing arithmetic, whereas native EVM opcodes
MULMODandADDMODhandle arbitrary precision safely in hardware.📁 Implementation Scope
contracts/math/FastModMath.soltest/math/FastModMath.test.ts🛠️ Requirements
safeMulMod(uint256 x, uint256 y, uint256 m) returns (uint256 result)in Yul assembly.mulmod(x, y, m)opcode directly with inline division-by-zero validation.🎯 Acceptance Criteria