# Fuzzy Public Key
This contract authenticates anyone whose public key contains 0xc0ffee
!
You know, in ECDSA (opens new window),
it takes short time to create a new private key (no time) and its public key?
You might want to use this web3.eth.accounts.create()
in
web3js (opens new window).
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
contract FuzzyPublicKey {
address public player;
bool public completed;
constructor(address _player) {
player = _player;
completed = false;
}
function authenticateMe() external {
bytes20 addr = bytes20(msg.sender);
bytes20 id = hex"0000000000000000000000000000000000c0ffee";
bytes20 mask = hex"0000000000000000000000000000000000ffffff";
for (uint256 i = 0; i < 40-6+1; i++) {
if (addr & mask == id) {
completed = true;
return;
}
mask <<= 4;
id <<= 4;
}
completed = false;
}
}