Puzzle #6
Uncertainty Principle
Author
1// SPDX-License-Identifier: Unlicense2pragma solidity ^0.8.17;3
4import {IPuzzle} from "./interfaces/IPuzzle.sol";5
6/**7 * @title Touring-Heisenberg Uncertainty Principle8 * @author wei3erHase9 */10contract EventHorizon is IPuzzle {11 12 /// @inheritdoc IPuzzle13 string constant public name = "Uncertainty Principle";14
15 uint256 constant PLANK_CONSTANT = 0x111; // 1 in XYZ16 uint256 constant PLANK_LENGTH = 0xF;17 uint256 constant PHISICAL_SPHERE = type(uint32).max;18
19 /// @inheritdoc IPuzzle20 function generate(address _seed) external view returns (uint256) {21 return _gammaFn(uint256(uint160(_seed))) | PLANK_CONSTANT;22 }23
24 /// @inheritdoc IPuzzle25 function verify(uint256 _start, uint256 _solution) external view returns (bool) {26 uint256 _axis;27 uint256 _momentum;28 uint256 _position;29
30 unchecked {31 while (_start & PHISICAL_SPHERE > 0) {32 _position = _axis++ * 4;33 _momentum = _gammaFn(_solution) & PLANK_LENGTH << _position;34 for (uint256 _i; _i < _momentum >> _position; _i++) {35 continue;36 }37 _start -= _momentum;38 }39 }40
41 return true;42 }43
44 function _gammaFn(uint256 _xyz) internal view returns (uint256) {45 /// @notice gasleft() has a directional preference (as entropy)46 return uint256(keccak256(abi.encodePacked(_xyz, gasleft())));47 }48}49
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.