Conversation
| bytes32 publicKeyHash; // Hash of the DKIM public key used in email/proof | ||
| uint timestamp; // Timestamp of the email | ||
| string maskedCommand; // Masked command of the email | ||
| bytes32 emailNullifier; // Nullifier of the email to prevent its reuse. |
There was a problem hiding this comment.
| bytes32 emailNullifier; // Nullifier of the email to prevent its reuse. | |
| bytes32 jwtNullifier; // Nullifier of the jwt to prevent its reuse. |
There was a problem hiding this comment.
@shreyas-londhe I've not dared to make any changes here in order to be compatible with EmailProof already in use.
If this change is made, it will not be possible to use the existing Verifier and JwtVerifier in the same interface with IVerifier used in ether-email-auth. cc: @SoraSuegami
| import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
| import { strings } from "solidity-stringutils/src/strings.sol"; | ||
|
|
||
| struct EmailProof { |
There was a problem hiding this comment.
Should be JwtProof
| import { strings } from "solidity-stringutils/src/strings.sol"; | ||
|
|
||
| struct EmailProof { | ||
| string domainName; // Domain name of the sender's email |
There was a problem hiding this comment.
Can you mention what the domainName in this case is -> [kid, iss, azp]?
There was a problem hiding this comment.
@shreyas-londhe kid, iss, and azp are concatenated as a string with | as the delimiter. I'll update the comment.
|
|
||
| struct EmailProof { | ||
| string domainName; // Domain name of the sender's email | ||
| bytes32 publicKeyHash; // Hash of the DKIM public key used in email/proof |
There was a problem hiding this comment.
Can you update the comment appropriately?
There was a problem hiding this comment.
@shreyas-londhe Thank you point out it. I'll update it.
| struct EmailProof { | ||
| string domainName; // Domain name of the sender's email | ||
| bytes32 publicKeyHash; // Hash of the DKIM public key used in email/proof | ||
| uint timestamp; // Timestamp of the email |
There was a problem hiding this comment.
Should be timestamp of JWT
| bytes32 emailNullifier; // Nullifier of the email to prevent its reuse. | ||
| bytes32 accountSalt; // Create2 salt of the account | ||
| bool isCodeExist; // Check if the account code is exist | ||
| bytes proof; // ZK Proof of Email |
There was a problem hiding this comment.
should be of jwt
| uint256[ISS_FIELDS + COMMAND_FIELDS + AZP_FIELDS + 6] memory pubSignals; | ||
|
|
||
| // string[] = [kid, iss, azp] | ||
| string[] memory parts = this.stringToArray(proof.domainName); |
There was a problem hiding this comment.
Can you please explain how this encodes the inputs?
| function isDKIMPublicKeyHashValid( | ||
| string memory domainName, | ||
| bytes32 publicKeyHash | ||
| ) public view returns (bool) { | ||
| string[] memory parts = this.stringToArray(domainName); | ||
| string memory kidAndIss = string(abi.encode(parts[0], "|", parts[1])); | ||
| return dkimRegistry.isDKIMPublicKeyHashValid(kidAndIss, publicKeyHash) | ||
| && whitelistedClients[parts[2]]; | ||
| } |
There was a problem hiding this comment.
This is not a DKIM public key, it's a JWT verification public key
There was a problem hiding this comment.
@shreyas-londhe function names, etc. have not been changed to make the interface match the previous DKIMRegistry. @SoraSuegami
| /// @notice Sets a public key hash for a `kis|iss` string after validating the provided signature. | ||
| /// @param domainName The domain name contains kis, iss and azp fields. | ||
| /// @param publicKeyHash The public key hash to set. | ||
| /// @dev This function requires that the public key hash is not already set or revoked. | ||
| function setDKIMPublicKeyHash( | ||
| string memory domainName, | ||
| bytes32 publicKeyHash | ||
| ) public { | ||
| require(bytes(domainName).length != 0, "Invalid domain name"); | ||
| require(publicKeyHash != bytes32(0), "Invalid public key hash"); | ||
| string[] memory parts = this.stringToArray(domainName); | ||
| string memory kidAndIss = string(abi.encode(parts[0], "|", parts[1])); | ||
| require( | ||
| isDKIMPublicKeyHashValid(domainName, publicKeyHash) == false, | ||
| "publicKeyHash is already set" | ||
| ); | ||
| require( | ||
| dkimRegistry.revokedDKIMPublicKeyHashes(publicKeyHash) == false, | ||
| "publicKeyHash is revoked" | ||
| ); | ||
|
|
||
| dkimRegistry.setDKIMPublicKeyHash(kidAndIss, publicKeyHash); | ||
| // Register azp |
There was a problem hiding this comment.
Can you please not use DKIM as we are not using it?
There was a problem hiding this comment.
@shreyas-londhe I am doing this to match the logic with using the previous registry. does this mean I should store the public key hash in a different way?
| function setDKIMPublicKeyHash( | ||
| string memory domainName, | ||
| bytes32 publicKeyHash | ||
| ) public { |
There was a problem hiding this comment.
Can you make this function onlyOwner?
This PR refactors and adds docs and helper functions.