ERC-1812 · Stagnant · ERC · 2019-03-03
ERC-1812: Ethereum Verifiable Claims
Off-chain verifiable claims ("issuer says subject has attribute X") built on EIP-712 typed signatures, so they can be kept private yet checked by smart contracts.
What problem does it solve?
Real-world apps need facts like "this address passed KYC" or "this person is an accredited investor". Storing such identity claims on-chain is often dangerous, and under rules like the EU GDPR possibly illegal, because the blockchain is public and immutable. Off-chain standards existed (W3C Verifiable Credentials, uPort messages), but they used JSON-LD or JWT, which smart contracts cannot easily check.
ERC-1812 uses EIP-712 typed data instead. Wallets can already sign it, and Solidity can verify it with ecrecover. The user keeps the signed claim off-chain and presents it to a contract only when needed.
How it works
A claim reads: Issuer says Subject is something or has some attribute. Each claim type is an EIP-712 struct with at least:
subject(address): who the claim is aboutvalidFrom,validTo(uint256seconds): validity window; use the maxuint256for "never expires"
Claim types come in three flavours:
- Binary: issued or not, e.g.
Person. - Value: carries a readable value, e.g. a name. The spec warns this can be a privacy violation if pushed on-chain.
- Hashed: carries
keccak256of a value, e.g. an email. Also flagged as risky if the value is guessable.
Verifying. Each claim format has a verifying contract with a verify-style view function. It rebuilds the EIP-712 digest, checks the validity window and recovers the issuer address.
Delegation. An issuer field lets someone other than the signer be the issuer, checked either against an ERC-1056 registry (validDelegate(issuer, "veriKey", signer)) or via an embedded signed Delegate claim.
Revocation. A simple registry where issuer or subject can mark a claim's EIP-712 digest as revoked.
Sample code
A verifier for a minimal Know claim (Solidity):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract KnowVerifier {
struct Know { address subject; uint256 validFrom; uint256 validTo; }
bytes32 constant KNOW_TYPEHASH =
keccak256("Know(address subject,uint256 validFrom,uint256 validTo)");
bytes32 public immutable DOMAIN_SEPARATOR;
constructor() {
DOMAIN_SEPARATOR = keccak256(abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256("KnowClaim"), keccak256("1"), block.chainid, address(this)));
}
function verifyIssuer(Know calldata c, uint8 v, bytes32 r, bytes32 s)
external view returns (address issuer)
{
require(c.validFrom <= block.timestamp && block.timestamp < c.validTo, "not valid now");
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR,
keccak256(abi.encode(KNOW_TYPEHASH, c.subject, c.validFrom, c.validTo))));
issuer = ecrecover(digest, v, r, s);
require(issuer != address(0), "bad signature");
}
}
Issuing the claim from a wallet (ethers v6):
const domain = { name: "KnowClaim", version: "1", chainId, verifyingContract };
const types = { Know: [
{ name: "subject", type: "address" },
{ name: "validFrom", type: "uint256" },
{ name: "validTo", type: "uint256" },
]};
const claim = { subject, validFrom: Math.floor(Date.now() / 1000), validTo: 2n ** 256n - 1n };
const signature = await issuerSigner.signTypedData(domain, types, claim);
Things to know
- Status: Stagnant. The domain name in the spec is still a placeholder (
"EIP1???Claim"), and its sampleverifyIssuerhas thevalidFromcomparison reversed; the version above checksvalidFrom <= now. - Passing a claim to a contract publishes it on-chain. Prefer binary claims for on-chain use and keep value or hashed claims off-chain.
- Hashes of low-entropy values (names, emails) can be brute-forced, so they do not hide the data.
- Related attestation designs include ERC-1386.