Labels: medium-difficulty, yul, math, gasguard
Difficulty: Medium
Module: contracts/utils/
🧠 Concept
Develop a Yul utility to reverse endianness (byte-swap) for 256-bit words (bytes32 or uint256) using optimized bit shift masks.
⚠️ Problem
Reversing byte order in high-level Solidity using loops requires multiple allocations and memory shifts, creating excessive loop overhead.
📁 Implementation Scope
contracts/utils/YulByteSwapper.sol
test/utils/YulByteSwapper.test.ts
🛠️ Requirements
- Implement endianness reversal logic using inline Yul assembly with optimized bitwise operations (
SHR, SHL, AND, OR).
- Support full 32-byte word endianness conversion without memory buffer allocation.
🎯 Acceptance Criteria
Labels:
medium-difficulty,yul,math,gasguardDifficulty: Medium
Module:
contracts/utils/🧠 Concept
Develop a Yul utility to reverse endianness (byte-swap) for 256-bit words (
bytes32oruint256) using optimized bit shift masks.Reversing byte order in high-level Solidity using loops requires multiple allocations and memory shifts, creating excessive loop overhead.
📁 Implementation Scope
contracts/utils/YulByteSwapper.soltest/utils/YulByteSwapper.test.ts🛠️ Requirements
SHR,SHL,AND,OR).🎯 Acceptance Criteria