ERC-7522 OIDC ZK verifier for AA accounts (OIDC ZK Verifier for AA Account)
Draft · Accounts & wallets · created 2023-09-20
Links an OIDC social account, such as Google, to an ERC-4337 smart account and uses a zero-knowledge proof to verify that identity on-chain, enabling approval of user operations or recovery of a lost account.
Why it is needed
Smart accounts can design authentication and recovery methods to fit their needs, but using familiar Web2 authentication like Google login requires linking an OIDC (OpenID Connect) identity to the account. The ID token an OIDC issuer provides is usually in JWT format, so verifying the signature itself is not hard. The problem is that existing approaches for using this in on-chain verification mostly rely on multi-party computation (MPC). The MPC approach requires a third-party service to sign and aggregate signatures, creating centralization risks such as a single point of failure and vendor lock-in. There is also no cryptographic guarantee that the user's Web2 identity and Web3 address remain separated, leaving a privacy concern. Zero-knowledge proofs can solve this problem, but if each implementation has different verifier functions and proof inputs, wallets and apps become hard to interoperate. So a common OIDC ZK verifier interface is defined for use in ERC-4337 account verification.
What to implement
function getVerificationKeyOfIdp() external view returns(bytes memory);: Returns the public key, that is, the verification key, of the key pair the identity provider (IDP) uses to sign ID tokens.function getIdHash(address account) external view returns(bytes32);: Takes a smart account address and returns the hash of the user ID linked to that account.
In depth
Four defined roles
The specification defines four roles. The identity provider (IDP) is the service that authenticates the user and issues a signed ID token. The user is the client that authenticates the user and generates the ZK proof. The ZK aggregator is an off-chain service that combines multiple users' ZK proofs. OpenIdZkVerifier is the on-chain contract that verifies the ZK proof. EntryPoint, Aggregator, and AA Account are used exactly as defined in ERC-4337. This proposal lists ERC-4337 as a required predecessor standard.
Three pieces of information needed for on-chain verification
For IOpenIdVerifier to verify identity ownership on-chain, it needs at least three pieces of information. First, the user ID that identifies the user at the IDP. The getIdHash function takes a smart account address and returns the hash of the user ID, and multiple smart accounts can be linked to the same user ID. Second, the public key of the key pair the identity provider uses to sign ID tokens, provided by the getVerificationKeyOfIdp function. Third, the ZK proof that verifies the OIDC identity, with verification performed by the verify function. The verification key and the user operation hash are not included in the public input struct, since the public key can be obtained via getVerificationKeyOfIdp and the operation hash can be computed from the original user operation passed in.
Proof public input struct
The OpenIdZkProofPublicInput struct must contain the following fields. jwtHeaderAndPayloadHash is the hash of the combined JWT header and payload. userIdHash is the hash of the user ID, and the user ID must be present as the value of one of the claims. expirationTimestamp is the JWT's expiration time, and the exp claim value can be used. jwtSignature is the JWT's signature. A typical JWT consists of three parts: header, claims, and signature. The identity the user claims is contained in the claims part, and the signature part is usually an RSA signature over the hash of the combined header and claims, made with a key corresponding to the issuer's well-known public key.
verify and verifyAggregated
The verify function takes the user operation (op) defined by ERC-4337, the proof public input (input) containing the JWT information, and the ZK proof (proof) generated for both, and verifies them. The verifyAggregated function is similar to verify, but takes a list of user operations (ops), a list of inputs (inputs), and a single aggregated proof (aggregatedProof) to verify multiple operations at once. ZK proof aggregation has been proven feasible, opening a path to lower verification costs at scale.
Why ZK instead of MPC
The most common existing approach for linking an OIDC identity to a smart account is multi-party computation (MPC), but its limitations are clear. It relies on a third-party service to sign and aggregate signatures, creating centralization risks such as a single point of failure and vendor lock-in, and there is no cryptographic guarantee that the Web2 identity and Web3 address remain separated, leaving privacy concerns. ZK verification solves all of these problems. The link between the Web2 identity and the Web3 account is hidden, preserving privacy; proof generation happens on the client without any third-party service, making the process fully decentralized; and proof aggregation offers the prospect of cheaper verification at scale.
The flagship use case is guardian recovery
A user can link an ERC-4337 account to an OIDC identity and grant authority so that the OIDC verifier confirms the linked identity on-chain to approve user operations. However, because ZK verification is costly, a common use case is to set the verifier as a guardian, recovering the account owner if the owner key is lost or stolen. Setting multiple OIDC identities, such as a Google account and a Facebook account, as guardians reduces the centralization risk posed by any single identity provider.
A proposal still at the draft stage
This proposal has been in Draft status since it was registered on September 20, 2023. The interface and input structure may change during discussion, or progress may stall, so the latest source should be checked before implementing or citing it.
Things to watch out for
- Preventing replay attacks via expiration timestamp verification: The proof must verify expirationTimestamp to prevent replay attacks. expirationTimestamp must be an increasing value, and the exp field of the JWT payload can be used.
- Preventing front-running attacks via user operation verification: The proof must verify the user operation to prevent front-running attacks.
- userIdHash verification: The proof must verify userIdHash.
- Confirming the link between sender and user ID: The verifier must confirm that each user operation's sender is linked to the corresponding user ID hash via the getIdHash function.