Skip to content

Commit

Permalink
chore: remove default values from contract
Browse files Browse the repository at this point in the history
  • Loading branch information
saleel committed Nov 4, 2023
1 parent 1a9a69b commit 87d7470
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 46 deletions.
49 changes: 4 additions & 45 deletions packages/contracts/DKIMRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,11 @@ contract DKIMRegistry is IDKIMRegistry, Ownable {
event DKIMPublicKeyHashRevoked(bytes32 publicKeyHash);

// Mapping from domain name to DKIM public key hash
mapping(string => bytes32[]) public dkimPublicKeyHashes;
mapping(string => mapping(bytes32 => bool)) public dkimPublicKeyHashes;

// DKIM public that are revoked (eg: in case of private key compromise)
mapping(bytes32 => bool) public revokedDKIMPublicKeyHashes;

constructor() {
// Set values for popular domains
dkimPublicKeyHashes["gmail.com"] = [
bytes32(
uint256(
21238126716164910617487233347059218993958564577330259377744533585136010170208
)
)
];
dkimPublicKeyHashes["hotmail.com"] = [
bytes32(
uint256(
2431254542644577945126644490189743659677343436440304264654087065353925216026
)
)
];
dkimPublicKeyHashes["twitter.com"] = [
bytes32(
uint256(
5857406240302475676709141738935898448223932090884766940073913110146444539372
)
)
];
dkimPublicKeyHashes["ethereum.org"] = [
bytes32(
uint256(
1064717399289379939765004128465682276424933518837235377976999291216925329691
)
)
];
dkimPublicKeyHashes["skiff.com"] = [
bytes32(
uint256(
7901875575997183258695482461141301358756276811120772965768802311294654527542
)
)
];
}

function _stringEq(
string memory a,
string memory b
Expand All @@ -76,10 +37,8 @@ contract DKIMRegistry is IDKIMRegistry, Ownable {
return false;
}

for (uint256 i = 0; i < dkimPublicKeyHashes[domainName].length; ++i) {
if (dkimPublicKeyHashes[domainName][i] == publicKeyHash) {
return true;
}
if (dkimPublicKeyHashes[domainName][publicKeyHash]) {
return true;
}

return false;
Expand All @@ -94,7 +53,7 @@ contract DKIMRegistry is IDKIMRegistry, Ownable {
"cannot set revoked pubkey"
);

dkimPublicKeyHashes[domainName].push(publicKeyHash);
dkimPublicKeyHashes[domainName][publicKeyHash] = true;

emit DKIMPublicKeyHashRegistered(domainName, publicKeyHash);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zk-email/contracts",
"version": "4.0.0",
"version": "4.0.1",
"scripts": {
"build": "forge build",
"publish": "yarn npm publish --access=public"
Expand Down

0 comments on commit 87d7470

Please sign in to comment.