Skip to content

Commit

Permalink
Add jwtVerifier and jwtRecoveryController
Browse files Browse the repository at this point in the history
  • Loading branch information
wshino committed Oct 2, 2024
1 parent 77550ea commit daaca75
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/contracts/src/utils/JwtGroth16Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

pragma solidity >=0.7.0 <0.9.0;

contract Groth16Verifier {
contract JwtGroth16Verifier {
// Scalar field size
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
// Base field size
Expand Down
70 changes: 56 additions & 14 deletions packages/contracts/test/helpers/DeploymentHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EmailAuth, EmailAuthMsg} from "../../src/EmailAuth.sol";
import {IVerifier} from "../../src/interfaces/IVerifier.sol";
import {Verifier} from "../../src/utils/Verifier.sol";
import {JwtVerifier} from "../../src/utils/JwtVerifier.sol";
import {EmailProof} from "../../src/interfaces/IVerifier.sol";
import {Groth16Verifier} from "../../src/utils/Groth16Verifier.sol";
import {JwtGroth16Verifier} from "../../src/utils/JwtGroth16Verifier.sol";
import {ECDSAOwnedDKIMRegistry} from "../../src/utils/ECDSAOwnedDKIMRegistry.sol";
import {UserOverrideableDKIMRegistry} from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol";
import {JwtRegistry} from "../../src/utils/JwtRegistry.sol";
Expand All @@ -29,10 +31,12 @@ contract DeploymentHelper is Test {

EmailAuth emailAuth;
IVerifier verifier;
IVerifier jwtVerifier;
ECDSAOwnedDKIMRegistry dkim;
UserOverrideableDKIMRegistry overrideableDkim;
JwtRegistry jwtRegistry;
RecoveryController recoveryController;
RecoveryController jwtRecoveryController;
SimpleWallet simpleWalletImpl;
SimpleWallet simpleWallet;

Expand Down Expand Up @@ -124,6 +128,24 @@ contract DeploymentHelper is Test {
);
verifier = IVerifier(address(verifierProxy));
}
// Create JwtVerifier
{
JwtVerifier verifierImpl = new JwtVerifier();
console.log(
"JwtVerifier implementation deployed at: %s",
address(verifierImpl)
);
JwtGroth16Verifier groth16Verifier = new JwtGroth16Verifier();
ERC1967Proxy verifierProxy = new ERC1967Proxy(
address(verifierImpl),
abi.encodeCall(
verifierImpl.initialize,
(msg.sender, address(groth16Verifier))
)
);
jwtVerifier = IVerifier(address(verifierProxy));
}

accountSalt = 0x2c3abbf3d1171bfefee99c13bf9c47f1e8447576afd89096652a34f27b297971;

// Create EmailAuth implementation
Expand All @@ -137,21 +159,41 @@ contract DeploymentHelper is Test {

// Create RecoveryController as EmailAccountRecovery implementation
RecoveryController recoveryControllerImpl = new RecoveryController();
ERC1967Proxy recoveryControllerProxy = new ERC1967Proxy(
address(recoveryControllerImpl),
abi.encodeCall(
recoveryControllerImpl.initialize,
(
signer,
address(verifier),
address(dkim),
address(emailAuthImpl)
{
ERC1967Proxy recoveryControllerProxy = new ERC1967Proxy(
address(recoveryControllerImpl),
abi.encodeCall(
recoveryControllerImpl.initialize,
(
signer,
address(verifier),
address(dkim),
address(emailAuthImpl)
)
)
)
);
recoveryController = RecoveryController(
payable(address(recoveryControllerProxy))
);
);
recoveryController = RecoveryController(
payable(address(recoveryControllerProxy))
);
}
// Create RecoveryController for JWT as EmailAccountRecovery implementation
{
ERC1967Proxy recoveryControllerProxy = new ERC1967Proxy(
address(recoveryControllerImpl),
abi.encodeCall(
recoveryControllerImpl.initialize,
(
signer,
address(jwtVerifier),
address(jwtRegistry),
address(emailAuthImpl)
)
)
);
jwtRecoveryController = RecoveryController(
payable(address(recoveryControllerProxy))
);
}

// Create SimpleWallet
simpleWalletImpl = new SimpleWallet();
Expand Down

0 comments on commit daaca75

Please sign in to comment.