ERC-7585 · Draft · ERC · 2023-12-27
ERC-7585: MixHash and Public Data Storage Proofs
Defines MixHash, a 256-bit Merkle-root identifier that also encodes file size, and a challenge-based scheme where anyone can prove on-chain they store a copy of public data.
What problem does it solve?
NFTs and on-chain records often point to files (images, datasets, media) that live off-chain. Nothing in ERC-721 or ERC-1155 lets a contract check that copies of that data actually still exist somewhere. Decentralized storage markets, data oracles and archival incentives all need such a check.
ERC-7585 proposes two pieces: a content identifier called MixHash that supports cheap chunk-level proofs, and a public data storage proof game that rewards people for keeping copies of public data.
How it works
MixHash is a 256-bit value laid out as:
| 2 bits hash type | 62 bits file size | 192 bits low bits of Merkle root |
0b00 = SHA-256, 0b10 = Keccak-256 (0b01, 0b11 reserved)
The file is split into 1 KB chunks (the last one zero-padded). Each chunk hash is truncated to 128 bits as a leaf, inner nodes also use 128 bits, and the root is a full hash. This keeps proofs small while staying the same size as an ordinary bytes32 hash.
Storage proof game:
- A block at height
hprovides a public, unpredictable nonce (typically the block hash). - A Supplier appends the nonce to each 1 KB chunk in turn and finds the chunk
mthat gives the smallest new Merkle root. This requires reading the whole file. - They submit
{mixHash, h, m, path, leaf}. The contract checks the path against the MixHash, checks thathis recent (e.g. within 2 blocks), and records the result. - The contract cannot know whether
mis truly optimal, so others can challenge with a better chunk. A successful challenge proves the earlier submitter did not have the full file and they can be penalised. If nobody challenges in time, the proof is accepted.
The short deadline is the defence against suppliers fetching data from the network on demand instead of storing it. An optional proof-of-work variant exists for slow chains, but the spec advises against using it unless necessary.
Optional interfaces: ERCPublicDataOwner.getPublicDataOwner(mixHash), and an NFT extension with tokenIdIsMixHash() and tokenDataHash(tokenId) that links tokens to their data.
Sample code
Decoding a MixHash (TypeScript):
function parseMixHash(mix: bigint) {
const hashType = Number(mix >> 254n); // 0 = SHA-256, 2 = Keccak-256
const size = (mix >> 192n) & ((1n << 62n) - 1n); // file size in bytes
const rootLow192 = mix & ((1n << 192n) - 1n);
return {
algo: hashType === 0 ? "sha256" : hashType === 2 ? "keccak256" : "reserved",
size,
chunks: (size + 1023n) / 1024n,
rootLow192: "0x" + rootLow192.toString(16).padStart(48, "0"),
};
}
Things to know
- Status: Draft. The ERC-165 interface ids are still placeholders in the spec.
- Security rests on economics ("Nash consensus"), not on a cryptographic proof of replication. The design deliberately does not prevent one copy being claimed as several (Sybil attacks).
- Only for public data: proofs reveal 1 KB chunks on-chain. Very small files are unsuitable because they are too easy to fetch on demand.
- The scheme cannot tell whether data is genuinely public. Rewarding proofs for arbitrary MixHashes lets suppliers invent data only they hold, so systems need to decide which MixHashes count, for example via NFTs that reference them.