1// SPDX-License-Identifier: UNLICENSED2pragma solidity 0.8.13;3import { IPuzzle } from "./lib/IPuzzle.sol";4
5struct service {6 function(uint32, uint256) internal helper;7}8
9enum Mode {10 Normal,11 Development,12 Maintenance13}14
15contract Challenge is IPuzzle {16 mapping(address => service) private serv;17 mapping(address => Mode) public mode;18 mapping(address => uint256) public victim;19 mapping(address => uint16) value;20
21 // For the solver check.22 mapping(address => uint256) public solved;23
24
25 function name() external pure returns (string memory){26 return "The Fundamental";27 }28
29 function generate(address _seed) public returns (uint256){30 return uint256(keccak256(abi.encode("Are you a fundamentals enjoyooor?", _seed))) >> 3;31 }32
33 function verify(uint256 _start, uint256 _solution) external returns (bool) {34 address addr = address(uint160(_solution));35
36 require(generate(addr) == _start, "Expected correct message");37 return solved[addr] == _start;38 }39
40 function setSlot(uint256 ptr, uint16 val) public {41 victim[msg.sender] = ptr;42 value[msg.sender] = val;43 }44
45 function applySlot() external {46 uint256 ptr = victim[msg.sender];47 uint32 val = value[msg.sender];48
49 assembly {50 sstore(ptr, val)51 }52 }53
54 function solve(uint32 key, uint256 key2) external {55 // Wow you are zero address!56 if(msg.sender == address(0)) {57 uint256 start = generate(msg.sender);58 solved[msg.sender] = start;59 return;60 }61
62 require(mode[msg.sender] == Mode.Maintenance, "Cannot call with current mode");63 serv[msg.sender].helper(key, key2);64
65 revert("Nice Try!");66 }67}
Time Left
Solve locally (WIP)
- Clone GitHub repo + install deps
git clone https://github.com/waterfall-mkt/curta-puzzles.git && cd curta-puzzles && forge install
- Set
RPC_URL_MAINNET
in.env
.env
RPC_URL_MAINNET=""
- Write solution + run script
forge script <PATH_TO_PUZZLE> -f mainnet -vvv
This is still WIP.