Workflow
The Storage Proof Workflow enables secure verification of arbitrary on-chain data. Let's break down each step in detail:
1. Accessing the Block Hash
Every piece of data on the blockchain belongs to a specific block. The block hash serves as a unique identifier for that block, summarizing all its contents.
Purpose: To establish a trusted starting point for the proof.
Process:
For recent blocks (within the last 256 blocks on Ethereum), use the
BLOCKHASH
opcode.For older blocks, utilize the Historical Block Hash Accumulator (refer to the dedicated page for in-depth explanation).
Outcome: A verified block hash that serves as the anchor for subsequent steps.
2. Accessing the Block Header
Once we have the block hash, we need to retrieve and verify the corresponding block header.
Purpose: To access crucial metadata about the block and verify its authenticity.
Process:
Retrieve the block header data.
Hash the provided block header.
Compare this hash with the block hash from step 1.
Outcome: A verified block header, giving access to important roots (state, receipts, transactions).
3. Determining the Desired Root
The block header contains three important roots:
stateRoot
: Summarizes the entire state of the blockchain at that block.receiptsRoot
: Summarizes all transaction outcomes in the block.transactionsRoot
: Summarizes all transactions in the block.Purpose: To select the appropriate root for the data we want to prove.
Process: Extract the relevant root based on the type of data being verified:
For account states or contract storage: use
stateRoot
For transaction receipts: use
receiptsRoot
For transaction details: use
transactionsRoot
Outcome: A cryptographic root that will be used as the basis for data verification.
4. Verifying Data Against the Chosen Root
This step involves proving that specific data exists within the structure represented by the chosen root.
Purpose: To cryptographically verify the existence and correctness of specific data.
Process:
Generate a Merkle proof off-chain, showing the path from the specific data to the chosen root.
Verify this proof on-chain against the root from step 3.
Outcome: Cryptographic certainty that the data existed in the blockchain at the specified block.
Advanced Verification Scenarios
Verifying Contract Storage Data
When verifying data within a contract's storage, additional steps are required:
Verify the contract account exists within the state trie.
Extract the storage root from the contract account.
Verify the specific storage slot data against this storage root.
Verifying Historical Transaction Data
For transaction data:
Use the
transactionsRoot
from the block header.Verify the transaction exists within the transactions trie.
Extract and verify specific transaction fields as needed.
Efficiency Considerations
Proofs are generated off-chain to reduce on-chain computational load.
Only the final verification step occurs on-chain, minimizing gas costs.
The use of zero-knowledge proofs can further optimize the verification process for complex data structures.
Security Assurances
The cryptographic nature of the proofs ensures data integrity.
No trust in external data providers is required; all verifications are done against on-chain roots.
The process is resistant to tampering, as any change in the data would invalidate the entire proof.
By following this workflow, developers can create applications that securely access and verify both current and historical blockchain data, enabling a new class of cross-chain and historically-aware smart contracts.
Last updated