How zHash works
A hash-based account for Solana and the EVM. The chain learns a 32-byte secret only as that secret pays for one committed action.
- Secret
HMAC-SHA256(seed, domain ‖ chain ‖ account ‖ nonce) - Controller
SHA-256(secret) - Next
SHA-256(secret at the next nonce)
Overview
The account has no elliptic-curve key. Authority is SHA-256 of a 32-byte secret. The holder keeps a 32-byte seed off-chain and derives one secret per nonce. The chain stores the hash of the current secret. It does not store the seed.
A spend has two steps. Commit publishes a fingerprint of the action while the secret is still private. Reveal puts that secret on the chain. In the same call the router installs the hash of the next secret, and that next secret is not in the transaction. The chain can keep the revealed secret forever. It cannot spend it twice.
| Piece | Where it lives | What it is |
|---|---|---|
| Seed | The holder | 32 bytes. Never enters a transaction. |
| Secret | Revealed once | HMAC of the seed for one chain, account, and nonce. |
| Controller | Router storage | SHA-256 of the current secret. This is the authority. |
| Commit key | The commit transaction | SHA-256 of the wallet and the slot. The secret is not in it. |
| Wallet | A proxy | On the EVM, CREATE2 from the initial controller. It holds the assets. |
Threat model
The account is built for an adversary who can read a secp256k1 private key. That reader may be an agent beside the key, or a biased ECDSA nonce that leaks it. A copied key still signs the next nonce, and the one after that.
A later adversary with a quantum computer can run Shor’s algorithm. Shor recovers the elliptic-curve keys ordinary accounts use. It leaves SHA-256 in place. Grover’s algorithm only shortens search against the hash.
| What they hold | Key-pair account | zHash |
|---|---|---|
| A copied private key | Every later signature | The account has no curve key |
| A biased ECDSA nonce | The private key, still valid | The hash of one secret |
| Shor’s algorithm | The elliptic-curve key | SHA-256 stays |
| Bytes published on the chain | A signature from a live key | A secret that has already paid |
Seed
The seed is 32 bytes, held by its owner, off-chain. It never enters a transaction. A copy of the seed derives every later secret. Loss of the seed leaves the assets in the account. The protocol names no owner and no recovery.
The HMAC message is the domain, then three big-endian 32-byte words. The same seed on another chain, or another account, derives a different wallet.
message = domain || uint256be(chainId) || uint256be(accountId) || uint256be(nonce) secret = HMAC-SHA256(seed, message)
- EVM domain
- zHash.secret.v119 ASCII bytes.
- Solana domain
- zHash.secret.solana.v1
- Account
- 0 by defaultA second account id derives a second family of secrets from the same seed.
- Nonce
- Starts at 0Each reveal moves it by one. Secret 0 and secret 1 are different bytes.
- Copy
- Derives every later secretTwo copies can commit two digests. A commit that does not match the secret is skipped. The earliest match runs.
- Loss
- Assets stay in the proxyThere is no owner key and no recovery path.
Secret
The secret for nonce N is an HMAC of the seed. The controller the router stores is the SHA-256 of that secret alone, packed as raw bytes.
secret = HMAC-SHA256(seed, domain ‖ chainId ‖ accountId ‖ nonce) controller = SHA-256(secret)
- Domain
- zHash.secret.v119 ASCII bytes. Solana uses zHash.secret.solana.v1.
- Controller
- sha256(abi.encodePacked(secret))The hash the router stores. The seed is not on the chain.
- Slot tag
- 0xfc9ea4b3acb906486de6330d0df020910833379f5c057c0a73dd025ea43dc384sha256("zHash.slot.v2")
- Slot
- sha256(abi.encode(slot tag, secret))
- List key
- sha256(abi.encode(wallet, slot))A commit publishes this key. The transaction does not carry the wallet or the secret.
Commit
The holder records the action before the secret is public. Three hashes bind that record. The digest covers every field the reveal will check.
key = SHA-256(abi.encode(wallet, slot))
fingerprint = SHA-256(abi.encode(secret, digest))
digest = SHA-256(abi.encode(
operation tag,
chain, wallet, nonce, controller,
target, value, SHA-256(data),
next controller, secret))
- Operation tag
- 0xa0b321d7e9d1615b20dd4bb54be3850a4dcf834cf8080d978e9e72893596f906sha256("zHash.operation.v4")
- Target
- The contract the wallet will call
- Value
- Wei, or lamports, sent with that call
- Data
- SHA-256 of the calldataThe digest binds the hash of the bytes, so a changed call is a different digest.
- Next controller
- SHA-256 of the next secretThat secret is not in this transaction.
- Fingerprint
- sha256(abi.encode(secret, digest))The earliest fingerprint that matches the secret is the action. It cannot be withdrawn.
- Order
- Append onlyA later commit does not replace an earlier one. A commit that does not match the secret is skipped. The earliest match runs.
- Same block
- Commit, then revealBoth are valid in one block. The holder broadcasts the secret after the commitment is included.
Reveal
The router checks the secret and the commitment, then rotates, then lets the wallet perform the call. The checks run in this order. The first one that fails reverts, and the nonce stays.
- 01WalletThe router has a controller for this address. An unknown wallet reverts.
- 02SecretSHA-256 of the revealed secret equals the stored controller.
- 03CommitmentThe earliest fingerprint that matches this secret has a digest equal to this operation.
- 04Next controllerIt is not zero, and it is not the controller already stored.
- 05BalanceThe value of the call is within what the wallet holds.
- 06Rotate, then callThe new controller and the next nonce are stored. The wallet call runs after that.
- Before
SHA-256(secret 0) - Reveal
secret 0 - After
SHA-256(secret 1)
On the EVM the wallet call returns success or failure. The router does not use a successful return. A failed call emits CallFailed. A return longer than 1,024 bytes is not copied and also emits CallFailed. The controller and nonce stored before that call remain. On Solana the program writes the next controller and then invokes the wallet. A lamport transfer within the balance completes with that controller. Solana has no call that returns failure and lets the instruction continue: if the invocation fails, the instruction fails, and that write is not part of a landed transaction.
Router
Any account may submit a commit or a reveal and pay the gas. That key is not authority. The wallet obeys the router alone. The wallet is an EIP-1167 proxy. Its CREATE2 salt is the initial controller, so predictWallet returns the address before createWallet deploys it.
- walletOf
- Initial controller → proxy address
- Account
- Controller and nonce for that proxy
- Commits
- The list of fingerprint and digest under a key
- Search
- The cursor and the recorded match for a secret, once the list is longer than the direct scan
- Direct scan
- 10The reveal reads the first ten commits itself. A longer list is located with processCommits. The earliest match is still the one that executes.
- Return data
- Not used on successA return longer than 1,024 bytes is not copied. On the EVM the new controller stays.
- Batch
- 16 on the EVM, 8 on SolanaOnly commit, process, and execute. The relayer pays gas and holds no privilege.
Rules
A seed from the earlier Lamport wallet is refused. This router takes a new seed. The domain string is part of the secret, so a note for another domain does not open the account.
| Condition | Result |
|---|---|
| Lamport domain | Refused. The domain is part of the HMAC message. |
| Zero controller | Refused, on create and as the next controller. |
| Next controller equals the current one | Refused. The reveal must move the hash. |
| Secret does not hash to the controller | The reveal reverts. The nonce stays. |
| No matching fingerprint | The reveal reverts. The nonce stays. |
| Value above the balance | The reveal reverts before rotation. The nonce stays. |
| Target call fails on the EVM | CallFailed is emitted. The controller and nonce stored before the call remain. The router does not use a successful return. A return longer than 1,024 bytes is not copied. |
| Invocation fails on Solana | The instruction fails, so the controller write is not part of a landed transaction. A lamport transfer within the balance completes with the new controller. |
| Two commits from two copies of the seed | A commit that does not match the secret is skipped. The earliest fingerprint that matches is the one that runs. A later match is not selected. |
| A commit after an earlier one | Appended. It does not replace the earlier commit. |
Functions
These are the calls on the EVM router. Anyone may send one and pay the gas. The caller does not become authority. The wallet still obeys the router alone.
bytes32 controller = router.hashSecret(secret); address wallet = router.predictWallet(controller); router.createWallet(controller); bytes32 slot = router.slotHash(secret); bytes32 key = router.commitmentKey(wallet, slot); bytes32 digest = router.operationHash(wallet, action, secret); bytes32 fingerprint = router.commitmentFingerprint(secret, digest); router.commit(key, fingerprint, digest); router.execute(wallet, action, secret);
Read
A holder computes the same hashes the chain will check. These calls change nothing.
- hashSecret
- SHA-256 of the raw 32-byte secret. That hash is the controller this secret can open.
- slotHash
- SHA-256 of the slot tag and the secret. It names the commitment list for that secret.
- commitmentKey
- SHA-256 of the wallet and the slot.
commitpublishes this key. The transaction carries neither the wallet nor the secret. - commitmentFingerprint
- SHA-256 of the secret and the digest. The chain stores it beside the digest, and the reveal must reproduce it.
- operationHash
- SHA-256 of the operation tag, the chain, the wallet, the nonce, the controller, the call, the next controller, and the secret.
- predictWallet
- The proxy address for an initial controller. The salt is that controller, so the address is known before the proxy exists.
- nonce, controller
- The nonce and the controller the router stores for a wallet.
- commitmentCount, commitments
- How many commits sit under a key, and the fingerprint and digest at one index.
- resumeIndex
- The index
processCommitsrecorded for a secret, once the search has reached a verified commit.
function hashSecret(bytes32 secret) public pure returns (bytes32) router.hashSecret(secret);
function slotHash(bytes32 secret) public pure returns (bytes32) router.slotHash(secret);
function commitmentKey(address wallet, bytes32 slot) public pure returns (bytes32) router.commitmentKey(wallet, slot);
function commitmentFingerprint(bytes32 secret, bytes32 digest) public pure returns (bytes32) router.commitmentFingerprint(secret, digest);
function operationHash(address wallet, Action calldata action, bytes32 secret) public view returns (bytes32)
struct Action { address target; uint256 value; bytes data; bytes32 nextController; }
function predictWallet(bytes32 initialController) public view returns (address) address wallet = router.predictWallet(controller);
function nonce(address wallet) external view returns (uint256) function controller(address wallet) external view returns (bytes32)
function commitmentCount(bytes32 key) external view returns (uint256)
function commitments(bytes32 key, uint256 index)
external view returns (bytes32 fingerprint, bytes32 digest, bool present)
function resumeIndex(bytes32 key, bytes32 secret)
external view returns (uint256 index, bool found)
Change
- createWallet
- Deploys the proxy for an initial controller, or returns the proxy already deployed. A zero controller is refused. The proxy then holds the assets, and only the router may call it.
- commit
- Appends a fingerprint and a digest under the key. A later commit does not replace an earlier one. The earliest verified fingerprint is the action, and it cannot be withdrawn.
- processCommits
- Reads a batch of commits and records the earliest fingerprint that matches the secret. The reveal itself reads the first ten. A longer list is located here first. Junk before the match takes one call per batch. A later match is not selected.
- execute
- Checks that the secret hashes to the stored controller, selects the earliest matching fingerprint, stores the next controller, and moves the nonce. Then the wallet performs the call. A check that fails before rotation reverts, and the nonce stays. After rotation the new controller stays, including when the target call fails. The router does not use a successful return. A return over 1,024 bytes is not copied.
- batch
- Runs up to sixteen
commit,processCommits, andexecutecalls, in order, in one transaction. One item that reverts leaves the earlier items in place. An empty list, a longer list, or any other call reverts the whole batch.
function createWallet(bytes32 initialController) external returns (address wallet) router.createWallet(controller);
function commit(bytes32 key, bytes32 fingerprint, bytes32 digest) external returns (uint256 index) router.commit(key, fingerprint, digest);
function processCommits(bytes32 key, bytes32 secret, uint256 maxIterations)
external returns (bool found, uint256 index)
router.processCommits(key, secret, 32);
function execute(address wallet, Action calldata action, bytes32 secret) external
router.execute(
wallet,
Action({
target: token,
value: 0,
data: abi.encodeCall(IERC20.transfer, (to, amount)),
nextController: router.hashSecret(nextSecret)
}),
secret
);
function batch(bytes[] calldata calls) external returns (bool[] memory ok)
router.batch([
abi.encodeCall(zHashRouter.commit, (key, fingerprint, digest)),
abi.encodeCall(zHashRouter.execute, (wallet, action, secret))
]);
The proxy accepts ether. Ether sent to the implementation itself is refused. execute on the proxy runs only when the router calls it.
function execute(address target, uint256 value, bytes calldata data)
external returns (bool ok, bytes memory ret, uint256 size)
Solana
Solana uses the same derivation with the domain zHash.secret.solana.v1. The chain word in an operation is the router program id. The wallet address is known from the router authority and the initial controller before create_wallet. Each instruction starts with a one-byte tag.
- initialize · 0
- The upgrade authority records the wallet program once. Initialize before that authority is revoked. A revoked authority cannot initialize.
- create_wallet · 1
- Creates the wallet for an initial controller, or returns when that wallet already exists.
- commit · 2
- Appends a fingerprint and a digest. The earliest verified fingerprint is the action.
- process · 3
- Locates the earliest matching commit when the list is longer than the direct scan of ten.
- execute · 4
- Checks the secret, the commitment, and the balance, then writes the next controller and invokes the wallet. A lamport transfer within the balance completes with that controller. If the invocation fails, the instruction fails, and the write is not part of a landed transaction.
- batch · 5
- Runs up to eight commit, process, and execute steps in order. A step that returns a program error is logged, and later steps still run. A failed cross-program call aborts the transaction, including the earlier steps.
data = [0]
data = [1] || controller[32]
data = [2] || key[32] || fingerprint[32] || digest[32]
data = [3] || key[32] || secret[32] || max_iterations as u16 le
data = [4]
|| secret[32]
|| next_controller[32]
|| target[32]
|| value as u64 le
|| data_len as u16 le
|| data
data = [5] || count
|| repeated (tag, account_count, len as u16 le, payload)
FAQ
Who can submit a transaction?
Any account can send commit, processCommits, and execute, and that account pays the gas. The router does not treat the sender as authority. The wallet’s execute accepts the router alone. The action that runs is the earliest verified fingerprint for the revealed secret.
What does the chain learn?
commit publishes the list key, the fingerprint, and the digest. execute publishes the 32-byte secret. The seed stays with the holder. The next controller in that transaction is SHA-256 of a secret the transaction does not contain.
Can one secret pay twice?
execute stores the next controller and adds one to the nonce before the wallet call. The revealed secret hashes to the controller that was just replaced, so a second execute with that secret fails BadSecret.
What if the seed is lost?
The proxy still holds the assets. The router stores a controller and a nonce for that proxy. The protocol has no owner key that can replace a lost seed.
What if someone copies the seed?
The copy can derive every later secret and can commit its own digest. Commits are appended. execute selects the earliest fingerprint that matches the secret and whose digest equals the operation. A later matching commit is not selected.
Can a commit be withdrawn?
commit only appends a fingerprint and a digest. No call removes or replaces an entry. A commit that does not match the secret is skipped. The earliest fingerprint that matches stays the action.
Can commit and reveal share a block?
Yes. Nothing in the router requires a later block. The holder sends the secret after the commitment is included, so the secret and the commitment are not pending together.
What if the call fails?
The wallet call runs after the router has stored the next controller and moved the nonce. On the EVM that call returns success or failure. The router does not use a successful return. A failed call emits CallFailed with the reason. A return longer than 1,024 bytes is not copied and also emits CallFailed. The stored controller and nonce remain. On Solana the program writes the next controller and then invokes the wallet. A lamport transfer is checked against the balance before that write, so a transfer within the balance completes with the new controller. Solana has no call that returns failure and lets the instruction continue. If the invocation fails, the instruction fails, and the write is not part of a landed transaction.
A check that fails before the controller is stored is a different outcome. An unknown wallet, a secret that does not hash to the controller, a missing fingerprint, a zero or reused next controller, or a value above the balance reverts the transaction. The nonce stays.
Why is SHA-256 the authority?
The controller is sha256(abi.encodePacked(secret)). A key-pair account instead keeps one secp256k1 private key, and every signature is from that key. Shor’s algorithm recovers an elliptic-curve key. SHA-256 asks for a preimage. Grover’s algorithm shortens the search for that preimage. It does not recover the secret the way Shor recovers a curve key.
Does one secret open every wallet?
No. The HMAC message is the domain, then the chain id, the account id, and the nonce, each integer a big-endian 32-byte word. The EVM domain is zHash.secret.v1. Solana uses zHash.secret.solana.v1. A different domain, chain, account, or nonce is a different secret, and its SHA-256 is a different controller.