Skip to content

Commit

Permalink
Merge branch 'matter-labs-audit-fixes' into feat/use-salt-for-deploy-…
Browse files Browse the repository at this point in the history
…safe-recovery-module
  • Loading branch information
wshino authored Oct 22, 2024
2 parents ed182c6 + f062ebf commit c68c613
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RPC_URL=""
SIGNER=0x69bec2dd161d6bbcc91ec32aa44d9333ebc864c0 # Signer for the dkim oracle on IC
ETHERSCAN_API_KEY=

CREATE2_SALT=1234
CREATE2_SALT=1234
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@matterlabs/era-contracts": "github:matter-labs/era-contracts",
"@openzeppelin/contracts-upgradeable": "5.0.1",
"@rhinestone/modulekit": "github:rhinestonewtf/modulekit",
"@zk-email/contracts": "6.0.3",
"@zk-email/ether-email-auth-contracts": "0.1.1-preview",
"@zk-email/contracts": "https://gitpkg.vercel.app/zkemail/zk-email-verify/packages/contracts?feat/dkim-registry-updates",
"@zk-email/ether-email-auth-contracts": "https://gitpkg.vercel.app/zkemail/ether-email-auth/packages/contracts?feat/audit-fix-2024-09-registry",
"erc7579-implementation": "github:erc7579/erc7579-implementation",
"solidity-stringutils": "github:LayerZero-Labs/solidity-stringutils"
},
Expand Down
75 changes: 35 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 22 additions & 12 deletions script/DeployEmailRecoveryModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Verifier } from "@zk-email/ether-email-auth-contracts/src/utils/Verifie
import { Groth16Verifier } from "@zk-email/ether-email-auth-contracts/src/utils/Groth16Verifier.sol";
import { ECDSAOwnedDKIMRegistry } from
"@zk-email/ether-email-auth-contracts/src/utils/ECDSAOwnedDKIMRegistry.sol";
import { UserOverrideableDKIMRegistry } from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol";
import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol";
import { EmailRecoveryFactory } from "src/factories/EmailRecoveryFactory.sol";
import { OwnableValidator } from "src/test/OwnableValidator.sol";
Expand All @@ -19,13 +20,14 @@ contract DeployEmailRecoveryModuleScript is Script {
function run() public {
vm.startBroadcast(vm.envUint("PRIVATE_KEY"));
address verifier = vm.envOr("VERIFIER", address(0));
address dkimRegistry = vm.envOr("DKIM_REGISTRY", address(0));
address dkimRegistrySigner = vm.envOr("SIGNER", address(0));
address dkimRegistrySigner = vm.envOr("DKIM_REGISTRY_SIGNER", address(0));
address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0));
address validatorAddr = vm.envOr("VALIDATOR", address(0));

address initialOwner = vm.addr(vm.envUint("PRIVATE_KEY"));

UserOverrideableDKIMRegistry dkim;

if (verifier == address(0)) {
Verifier verifierImpl = new Verifier();
console.log("Verifier implementation deployed at: %s", address(verifierImpl));
Expand All @@ -39,18 +41,26 @@ contract DeployEmailRecoveryModuleScript is Script {
console.log("Deployed Verifier at", verifier);
}

if (dkimRegistry == address(0)) {
// Deploy Useroverridable DKIM registry
dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM_REGISTRY", address(0)));
uint256 setTimeDelay = vm.envOr("DKIM_DELAY", uint256(0));
if (address(dkim) == address(0)) {
require(dkimRegistrySigner != address(0), "DKIM_REGISTRY_SIGNER is required");

ECDSAOwnedDKIMRegistry dkimImpl = new ECDSAOwnedDKIMRegistry();
console.log("ECDSAOwnedDKIMRegistry implementation deployed at: %s", address(dkimImpl));
UserOverrideableDKIMRegistry overrideableDkimImpl = new UserOverrideableDKIMRegistry();
console.log(
"UserOverrideableDKIMRegistry implementation deployed at: %s",
address(overrideableDkimImpl)
);
ERC1967Proxy dkimProxy = new ERC1967Proxy(
address(dkimImpl),
abi.encodeCall(dkimImpl.initialize, (initialOwner, dkimRegistrySigner))
address(overrideableDkimImpl),
abi.encodeCall(
overrideableDkimImpl.initialize,
(initialOwner, dkimRegistrySigner, setTimeDelay)
)
);
dkimRegistry = address(ECDSAOwnedDKIMRegistry(address(dkimProxy)));
vm.setEnv("ECDSA_DKIM", vm.toString(address(dkimRegistry)));
console.log("Deployed DKIM Registry at", dkimRegistry);
dkim = UserOverrideableDKIMRegistry(address(dkimProxy));
vm.setEnv("DKIM_REGISTRY", vm.toString(address(dkim)));
console.log("UseroverrideableDKIMRegistry proxy deployed at: %s", address(dkim));
}

if (emailAuthImpl == address(0)) {
Expand All @@ -74,7 +84,7 @@ contract DeployEmailRecoveryModuleScript is Script {
bytes32(uint256(0)),
bytes32(uint256(0)),
type(EmailRecoveryCommandHandler).creationCode,
dkimRegistry,
address(dkim),
validatorAddr,
bytes4(keccak256(bytes("changeOwner(address)")))
);
Expand Down
Loading

0 comments on commit c68c613

Please sign in to comment.