Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-6327 proposes a mechanism for using passwords to authorize transaction data in a manner analogous to signing with private keys. The aim is to make authentication more intuitive and easier to manage.

This article explains the proposal with additional context and examples.

You can find my other articles on EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs here.

Overview

Elastic Signature (ES) is a mechanism for signing data using a secret that a person can remember. Here, the secret is not a fixed-length private key of the kind used in conventional cryptographic schemes, but something the user can choose, such as a password. ES does not require the contract to store the plaintext secret and uses zero-knowledge proofs to enable fully on-chain verification of knowledge of that secret.

Users can rotate their secret when needed, and the proposal does not impose a fixed password length at the interface level. An implementation must nevertheless define how passwords are encoded and processed by its circuit. This flexibility can mitigate the consequences of a compromised secret, provided the legitimate user can rotate it before an attacker exploits it. Passwords may also be more familiar than private keys to people new to blockchains.

ES defines a standard interface for using this mechanism in smart contracts. DApps and wallets can integrate ES-based signature verification and operation authorization, subject to the security of their chosen implementation.

Motivation

ES aims to introduce the concept of a changeable signing secret. One of the difficulties many people encounter when using a blockchain is private key management. Private keys provide powerful control, but loss or disclosure can have irreversible consequences, creating a significant barrier for beginners.

One existing approach is to use a custodial wallet service that holds private keys on users' behalf. This introduces dependence on a service provider and is at odds with a fully decentralized custody model.

Using zero-knowledge proofs, ES aims to provide a signing mechanism that users can manage without having to handle the secret in the same way as a conventional private key. The user remembers a password, and a smart contract can verify proof of knowledge without receiving the password itself.

This can simplify onboarding and make decentralized applications more accessible to nontechnical users. The ability to rotate the secret may also reduce concerns about long-term secret management, although the reset and recovery mechanisms still require careful design.

Use cases

ES is not a replacement for the conventional private key of an EOA. Instead, it can be used as an additional signing mechanism. Applications can combine both forms of authorization to improve security rather than having to choose one or the other.

Use in DeFi applications

A DeFi application integrating ES can require an additional password-based proof when a user performs a sensitive operation, such as transferring assets. If both the ordinary private-key signature and an ES proof are mandatory, someone who obtains only the private key cannot perform that protected operation without also satisfying the ES requirement. In this configuration, ES acts as a second authentication factor and can strengthen security.

Use in smart contract wallets

Smart contract wallets, including those using account abstraction through ERC-4337, can support flexible signature validation methods.

For more on ERC-4337, see the following article.

[ERC-4337] Implementing Account Abstraction Without Protocol Changes

Integrating ES into a wallet can support the following experience.

  • The user sets a password when first using the wallet.
  • The user need not personally retain a conventional private key for authorization if the wallet supports an appropriate password-based authorization model.
  • The secret can be changed through the supported reset mechanism.

In particular, a decentralized wallet that users operate with a password can feel more like a familiar web service, reducing barriers for newcomers.

Specification

ES (Elastic Signature) uses a variable-length secret, such as a password, and a zero-knowledge proof to establish knowledge of that secret without revealing it. The password itself is not stored by the on-chain verifier, and verification can take place entirely on-chain. The password can be changed through the reset procedure, and ES can be used alongside conventional private-key signatures to strengthen authorization.

ES verification involves three roles: the Verifier, Requester, and Prover.

The overall process is based on the following hash values.

Name Description
pwdhash Hash derived from the password.
datahash Hash of the data associated with the operation.
fullhash Hash calculated from datahash and known variables such as nonce and chainid.
expiration Timestamp after which the proof is no longer valid.
allhash Hash derived from fullhash and pwdhash.

The three roles have the following responsibilities.

Verifier

  • Calculates fullhash using the datahash supplied by the Requester.
  • Retrieves the pwdhash associated with the user's address, which can be an EOA or a smart contract wallet.
  • Verifies the correctness of the allhash generated by the Prover and submitted by the Requester, together with the proof.

Requester

  • Generates datahash and determines the proof's expiration.
  • Submits the proof and allhash received from the Prover to the Verifier.

Prover

  • Generates proof and allhash using the secret and known variables such as datahash, expiration, nonce, and chainid.

Requirements

  • Known variables must be shared among all participants.
  • A nonce must be included.
  • The chainid must be included.
  • Verifier-specific variables may also be included.
  • The public statement must include or bind pwdhash, fullhash, and allhash.
  • The Verifier and Prover must agree on how fullhash is calculated.
  • The calculation of datahash must also be clearly defined.

IElasticSignature interface

javascript
pragma solidity ^0.8.0;

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 resetPassword(
        uint[8] memory proof1,
        uint expiration1,
        uint allhash1,
        uint[8] memory proof2,
        uint pwdhash2,
        uint expiration2,
        uint allhash2
    ) external;

    function verify(
        address user,
        uint[8] memory proof,
        uint datahash,
        uint expiration,
        uint allhash
    ) external;
}

Events

SetPassword
javascript
event SetPassword(address indexed user, uint indexed pwdhash);

Emitted when a user sets or resets their password hash. It associates the updated password hash with the user's address and notifies observers of the change. The mechanism supports both EOAs and smart contract wallets.

Parameters

  • user

    • Address of the user who set the password hash.
  • pwdhash

    • The newly configured password hash.
Verified
javascript
event Verified(address indexed user, uint indexed nonce);

Emitted when a submitted proof is successfully verified. Following successful password-based authorization, the nonce is advanced to prevent reuse of the same authorization. The nonce is an important part of replay protection in this proof-based scheme.

Parameters

  • user

    • Address of the user whose proof was verified.
  • nonce

    • The newly issued nonce.

Functions

pwdhashOf
javascript
function pwdhashOf(address user) external view returns (uint);

Retrieves the pwdhash registered for a specified user address. The Verifier uses this function to obtain the password hash associated with the user when verifying a proof.

Parameters

  • user
    • Address of the user whose password hash is being retrieved.

Return value

  • pwdhash
    • Password hash registered for the specified address.
resetPassword
javascript
function resetPassword(
    uint[8] memory proof1,
    uint expiration1,
    uint allhash1,
    uint[8] memory proof2,
    uint pwdhash2,
    uint expiration2,
    uint allhash2
) external;

Updates an existing password to a new one. The first proof (proof1) establishes knowledge of the old password, while the second proof (proof2) establishes the required proof corresponding to the new password. These two checks are intended to ensure that the password update is authorized by someone who knows the old secret and that the new secret is correctly registered.

Parameters

  • proof1

    • Proof generated using the old password.
  • expiration1

    • Expiration timestamp of the old-password proof.
  • allhash1

    • allhash generated using the old password.
  • proof2

    • Proof generated using the new password.
  • pwdhash2

    • Hash of the new password.
  • expiration2

    • Expiration timestamp of the new-password proof.
  • allhash2

    • allhash generated using the new password.
verify
javascript
function verify(
    address user,
    uint[8] memory proof,
    uint datahash,
    uint expiration,
    uint allhash
) external;

Called by other contracts to verify a proof generated by a user. The transaction-requesting application, such as a DeFi application, calculates datahash and passes it to this function along with the user's proof and allhash.

The Verifier recomputes fullhash internally and checks the proof against the expected public values, including allhash. Verification fails if expiration has passed or the submitted public values and proof are invalid. On success, the Verified event is emitted and the nonce is updated.

Parameters

  • user

    • Address of the user whose authorization is being verified.
  • proof

    • Proof generated using the user's password.
  • datahash

    • Hash of the operation's data.
  • expiration

    • Expiration timestamp of the proof.
  • allhash

    • Public statement value generated alongside the proof.

Additional considerations

Why the contract stores pwdhash

In ES, the plaintext password is not stored by the contract, but its derived hash, pwdhash, is stored on-chain. The contract retains the association between a user's address and that hash and uses it to verify zero-knowledge proofs.

The ES contract acting as Verifier checks whether the submitted proof and allhash are consistent with the registered pwdhash. The password itself is not disclosed in the proof. Verification establishes that the proof was generated by someone who knows a corresponding secret, rather than independently proving that the prover is the original human user.

How the ZK circuit and hashes fit together

Data flow from user input through the ZK circuit to the Verifier https://eips.ethereum.org/EIPS/eip-6327

The diagram illustrates the flow of data from a user operation through the ZK circuit to verification by the Verifier.

  1. On the left, the user supplies the operation's data to the block labeled input. Examples include the token type (token) and transfer or withdrawal quantity (amount).

  2. A datahash is calculated from these inputs. In the diagram, values such as token and amount are combined into datahash.

  3. Additional values, including expiration (validity deadline), chainId (chain ID), and nonce (a single-use counter), are combined to produce fullhash. This hash binds the authorization to the relevant chain, expiration, and operation.

  4. Separately, the user's wallet address and password (pwd) are provided to the ZK circuit. At the top of the diagram, the arrow labeled wallet address to pwdhash represents the password hash associated with that address in the contract.

  5. The ZK circuit takes the following inputs.

    • address

    • pwd

    • fullhash

      It produces the following proof and associated public values.

    • proof (zero-knowledge proof)

    • pwdhash (password hash)

    • allhash (hash combining fullhash and pwdhash)

  6. On the right, the Verifier contract performs verify using its registered pwdhash, the submitted proof and allhash, and the reconstructed fullhash. It verifies that the prover knows a password corresponding to the registered pwdhash and that the proof is bound to this particular fullhash.

The important point is that the user's operation data and password are distinct inputs. They are bound together by the ZK circuit, resulting in a proof associated with fullhash, pwdhash, and allhash.

Computation inside the ZK circuit using Poseidon

Two-stage Poseidon hash computation inside the ZK circuit https://eips.ethereum.org/EIPS/eip-6327

The diagram shows how the ZK circuit is constructed using the Poseidon hash function.

Poseidon is designed for efficient computation within zero-knowledge proof circuits. The diagram divides hashing into two stages, labeled Poseidon 1 and Poseidon 2.

The flow is as follows.

  1. The circuit receives the following inputs.

    • password
    • address
    • fullhash
  2. Poseidon 1 computes pwdhash from password and address. The dashed lines in the diagram show the password and address entering Poseidon 1 and its output appearing as pwdhash.

  3. Poseidon 2 combines the pwdhash output from Poseidon 1 with fullhash to calculate allhash. The green arrows show fullhash and pwdhash entering Poseidon 2 and allhash emerging on the right.

  4. The proof-generation process provides the following proof and public values.

    • proof (zero-knowledge proof)
    • allhash
    • pwdhash
    • fullhash

    Although fullhash is also an input, including it among the public values lets the Verifier determine which operation the proof concerns.

The diagram emphasizes that pwdhash and allhash are consistently derived from the circuit's hash computations. The Verifier checks a proof against constraints representing those Poseidon computations. Assuming the circuit and proof system are sound, a Prover cannot produce an accepted proof for an arbitrary allhash inconsistent with the password, address, and fullhash.

Workflow (User → Requester → ES contract)

Workflow between the user, requester, and ES verifier contract

The diagram shows who submits which data to whom. It involves the User (Prover), a third-party contract (Requester), and the ES contract (Verifier).

  1. The User on the left wants to perform an operation such as a withdrawal. The token type and amount are treated as operation inputs.

  2. The User executes the ZK circuit with the password and data describing the withdrawal, generating the following values.

    • proof
    • allhash

    These values are shown as outputs of the ZK block.

  3. The User sends the withdrawal data, proof, and allhash to the third-party contract acting as Requester. This third-party contract could be a DeFi application's contract.

  4. The Requester calculates datahash using the submitted values, such as token and amount, and associates the operation with the user's address. In the middle of the diagram, it submits the following data to the ES contract on the right.

    • datahash

    • User address

      It also submits the following values received from the User.

    • proof

    • allhash

  5. The ES contract retrieves the user's registered pwdhash and calculates fullhash from the submitted datahash and the other required known variables. It then performs verification using the following values.

    • fullhash
    • pwdhash
    • proof
    • allhash

    On the right side of the diagram, these four values are supplied to verification in the ES contract.

  6. Successful verification establishes that the withdrawal was authorized by a prover who knows the registered password. By requiring ES in addition to private-key authorization, an application can arrange for funds to move only when both authorization conditions are satisfied.

Compatibility

ES-based verification is designed to coexist with existing signature verification mechanisms.

ES concerns password-based signatures and operates at a different layer from the conventional signature mechanism using an EOA's private key. Existing EOA signature verification logic need not be changed or replaced merely to add ES. Both methods can be used in parallel.

Existing contracts and wallets can therefore continue to verify EOA signatures while incorporating ES where appropriate.

Reference implementation

js
pragma solidity ^0.8.0;

import "../interfaces/IElasticSignature.sol";
import "./verifier.sol";

contract ZKPass is IElasticSignature {
    Verifier verifier = new Verifier();

    mapping(address => uint) public pwdhashOf;

    mapping(address => uint) public nonceOf;

    constructor() {
    }

    function resetPassword(
        uint[8] memory proof1,
        uint expiration1,
        uint allhash1,
        uint[8] memory proof2,
        uint pwdhash2,
        uint expiration2,
        uint allhash2
    ) public override {
        uint nonce = nonceOf[msg.sender];

        if (nonce == 0) {
            //init password

            pwdhashOf[msg.sender] = pwdhash2;
            nonceOf[msg.sender] = 1;
            verify(msg.sender, proof2, 0, expiration2, allhash2);
        } else {
            //reset password

            // check old pwdhash
            verify(msg.sender, proof1, 0, expiration1, allhash1);

            // check new pwdhash
            pwdhashOf[msg.sender] = pwdhash2;
            verify(msg.sender, proof2, 0, expiration2, allhash2);
        }

        emit SetPassword(msg.sender, pwdhash2);
    }

    function verify(
        address user,
        uint[8] memory proof,
        uint datahash,
        uint expiration,
        uint allhash
    ) public override {
        require(
            block.timestamp < expiration,
            "ZKPass::verify: expired"
        );

        uint pwdhash = pwdhashOf[user];
        require(
            pwdhash != 0,
            "ZKPass::verify: user not exist"
        );

        uint nonce = nonceOf[user];
        uint fullhash = uint(keccak256(abi.encodePacked(expiration, block.chainid, nonce, datahash))) / 8; // 256b->254b
        require(
            verifyProof(proof, pwdhash, fullhash, allhash),
            "ZKPass::verify: verify proof fail"
        );

        nonceOf[user] = nonce + 1;

        emit Verified(user, nonce);
    }

    /////////// util ////////////

    function verifyProof(
        uint[8] memory proof,
        uint pwdhash,
        uint fullhash, //254b
        uint allhash
    ) internal view returns (bool) {
        return
            verifier.verifyProof(
                [proof[0], proof[1]],
                [[proof[2], proof[3]], [proof[4], proof[5]]],
                [proof[6], proof[7]],
                [pwdhash, fullhash, allhash]
            );
    }
}

verifier.sol is automatically generated by snarkjs. The circuit source, circuit.circom, is shown below.

c++
pragma circom 2.0.0;

include "../../node_modules/circomlib/circuits/poseidon.circom";

template Main() {
    signal input in[3];
    signal output out[3];

    component poseidon1 = Poseidon(2);
    component poseidon2 = Poseidon(2);

    poseidon1.inputs[0] <== in[0];  //pwd
    poseidon1.inputs[1] <== in[1];  //address
    out[0] <== poseidon1.out; //pwdhash

    poseidon2.inputs[0] <== poseidon1.out;
    poseidon2.inputs[1] <== in[2]; //fullhash
    out[1] <== in[2]; //fullhash
    out[2] <== poseidon2.out; //allhash
}

component main = Main();

Security

The proposal's security discussion assumes that pwdhash is public and estimates resistance to brute-force attacks in which candidate passwords are tested against the password hash.

Risks arising from public pwdhash values

ES does not store plaintext passwords on-chain, but their derived pwdhash values are public. Assuming Poseidon as the hash function, the proposal uses a hypothetical rate of 100 million hashes per second (100 Mhash/s) on a GPU such as an RTX 3090 to estimate the resistance of passwords of different lengths and character sets.

Illustrative cracking-time estimates

The following table reproduces the estimates and assumptions presented in the original discussion. These are illustrative figures, not independently benchmarked results or recommended password policies.

Password characteristics Estimated cracking time
8 characters (digits only) 1 second
8 characters (digits and letters) 25 days
8 characters (digits, letters, and symbols) 594 days
12 characters (digits only) 10,000 seconds
12 characters (digits and letters) 1,023,042 years
12 characters (digits, letters, and symbols) 116,586,246 years

The original estimates assume an exhaustive search at roughly 100 Mhash/s. Increasing the size of the character set increases the number of possible combinations exponentially for a fixed password length. Actual resistance depends on the password generation process, the precise alphabet and encoding, the hash implementation, and the attacker's resources. Human-chosen passwords are generally not distributed uniformly, so they can be substantially weaker than the table suggests.

Comparison with private keys

The original discussion compares the size of the password search space with that of a private key.

  • A 256-bit private key has a nominal search space of approximately 2^256.
  • A uniformly random 40-character password drawn from digits, letters, and symbols in a 92-character alphabet has a search space of 92^40.

The value 92 is the assumed size of the combined character alphabet. In this model:

  • 92^40 > 2^256

Consequently, the nominal search space of a uniformly generated 40-character password from that alphabet exceeds that of a 256-bit value. This compares search-space sizes, not the effective security of complete cryptographic systems. In particular, generic attacks on a 256-bit elliptic-curve key may require approximately 2^128 group operations, while the security of password-based proof verification also depends on its hash and circuit.

The underlying idea is that a sufficiently long, independently and uniformly generated secret can provide substantial brute-force resistance even when its derived hash is public. Length and character variety alone do not guarantee this resistance for a memorable, human-chosen password.

Citation

George (@JXRow), "ERC-6327: Elastic Signature [DRAFT]," Ethereum Improvement Proposals, no. 6327, January 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6327.

Conclusion

ERC-6327 proposes a mechanism for password-based authorization of transaction data, aiming to provide a more intuitive and manageable authentication experience alongside existing signing methods.