mstore(0, msg.value);
hash = sha3(0, 0x20); // hash that msg.value
if (hash >> 0xF8 == 0xA8) {
jump(0x16);
}
The condition hash >> 0xF8 == 0xA8 means the MSB of hash is 0xA8. In other words, in this challenge our task is to find an integer x such that hash(x) begins with 0xA8.
Write a simple Bash script to brute-force msg.value:
#!/bin/bash
COUNTER=1
while [ $COUNTER -lt 1024 ]
do
echo "msg.value: $COUNTER"
printf "$COUNTER\n\n" | npx hardhat play | grep "Puzzle solved!"
COUNTER=$[$COUNTER +1]
rm -f solutions/solution_9.json
done