ERC-6327 · Draft · ERC · 2023-01-13
ERC-6327: Elastic Signature
A draft interface for password-based "elastic signatures": users prove knowledge of a changeable secret with a zero-knowledge proof that a contract verifies, as an extra signing factor on top of a private key.
What problem does it solve?
Private keys are hard for non-technical users: they cannot be changed, cannot be remembered, and losing one means losing everything. Custodial key services make onboarding easier but depend on a vendor.
ERC-6327 proposes an elastic signature (ES): authorising an action with a human-friendly secret, like a password, that can be changed whenever the user wants. The password is never stored or revealed. Instead the user produces a zero-knowledge proof that they know it, and a verifier contract checks the proof on-chain.
The spec positions ES as an additional factor, not a replacement for keys: for example a DeFi app requiring a password to withdraw even if the wallet key is compromised, or a password plugin for an ERC-4337 smart account.
How it works
Three roles and a handful of hashes:
pwdhash= hash of the password (bound to the user's address); stored on-chain by the verifier.datahash= hash of the action being authorised, produced by the requester contract.fullhash= hash ofdatahashplus well-known values, which should include a per-usernonceand thechainid(the reference implementation also mixes in anexpiration).allhash= hash ofpwdhashandfullhash.
Flow:
- The prover (user's client) computes
allhashand a zk-SNARKprooffrom the password, address andfullhash. - The requester contract calls
verify(user, proof, datahash, expiration, allhash)on the verifier. - The verifier recomputes
fullhash, looks uppwdhash, checks the proof against the public values[pwdhash, fullhash, allhash], then increments the user's nonce and emitsVerified.
resetPassword changes the password by requiring proofs from both the old and the new secret. The reference circuit uses Poseidon hashes (circom/snarkjs).
Sample code
A requester contract that gates withdrawals on an elastic signature:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
interface IElasticSignature {
event SetPassword(address indexed user, uint indexed pwdhash);
event Verified(address indexed user, uint indexed nonce);
function pwdhashOf(address user) external view returns (uint);
function verify(address user, uint[8] memory proof, uint datahash,
uint expiration, uint allhash) external;
}
contract PasswordVault {
IElasticSignature public immutable es;
mapping(address => uint256) public balance;
constructor(IElasticSignature _es) { es = _es; }
function withdraw(uint256 amount, uint[8] calldata proof,
uint expiration, uint allhash) external {
// datahash binds the proof to this exact action
uint datahash = uint(keccak256(abi.encode(address(this), msg.sender, amount)));
es.verify(msg.sender, proof, datahash, expiration, allhash); // reverts if invalid
balance[msg.sender] -= amount;
payable(msg.sender).transfer(amount);
}
}
Things to know
- Status is Draft; the interface and hash construction may still change.
pwdhashis public, so the password can be brute-forced offline. The spec's own estimates show short passwords fall quickly on a GPU; only very long, high-entropy secrets approach private-key strength.- The nonce prevents replay of a proof; the chain ID in
fullhashprevents cross-chain reuse. The prover and verifier must agree exactly on howfullhashanddatahashare built. - Proof generation happens client-side and needs the circuit artefacts; the on-chain verifier is generated from that circuit, so both must match.