January 24th, 2024
Blockchain is built on the philosophy of using cryptography to replace trust and build completely decentralized systems. Blockchain consensus algorithms and the process of verifying the authenticity and integrity of transactions on the ledger via digital signatures are two prime examples of using cryptography for this purpose.
State proofs are another example of using cryptography to reduce the need for trust in blockchain systems. The role of a state proof is to securely and succinctly summarize the state of the blockchain’s digital ledger in a form that anyone can verify. These state proofs can be used for various purposes within a blockchain ecosystem.
Blockchains are designed to implement an immutable digital ledger. The original blockchains, like Bitcoin, are designed to track financial transactions. Smart contract platforms, like Ethereum, implement a decentralized computer on the blockchain, using the ledger to record the set of instructions that have been executed within the blockchain’s virtual machine (VM).
The state of a blockchain is the content of its digital ledger and the status of its VM at a particular point in time. Each transaction or instruction executed within the blockchain’s VM will change this state.
A state proof is a record of the current state of the blockchain at a particular point in time. This state proof can be verified by anyone, enabling them to validate that the attested state of the blockchain is correct at that point in time.
State proofs use digital signatures to prove their authenticity. Once a state proof has been digitally signed using a private key, anyone can validate the digital signature using the corresponding private key. This both ensures that the signed data was generated by the alleged author and demonstrates that it has not been modified since it was digitally signed.
A state proof is designed to summarize the current state of the blockchain in a way that is easily verifiable and difficult to forge. Some of the key elements of a state proof include:
Commitment Trees: Commitment trees — such as Merkle trees or vector commitment trees — are an efficient, integrity-preserving method of summarizing data. Each transaction or piece of data is placed in one of the leaf nodes of the tree, and intermediate nodes securely summarize their children. At the top of the tree, the value of the root node can be used as a compact summary of the entire tree since it is infeasible to generate two different commitment trees of the same depth that have the same root value.
Digital Signatures: Digital signatures are used to prove the authenticity and integrity of the signed data. Only someone with knowledge of the correct private key can generate a digital signature for that account. Then, the corresponding public key can be used to verify the signature. The cryptographic algorithms that underpin digital signatures make it impossible to forge them or modify the data without detection after the signature is generated.
This combination of commitment trees and digital signatures creates a secure, integrity-preserving summary of the state of the blockchain network. The commitment tree provides the summary, while the digital signatures help to ensure authenticity and prevent the commitment tree from being modified after the fact.
State proofs provide an authenticated summary of the state of the blockchain at a particular point in time. Some of the many applications that state proofs have within the blockchain ecosystem include the following:
ZK-Rollups: Rollups are a Layer-2 solution designed to improve the scalability and performance of a blockchain by moving transactions off-chain. When a rollup bundles transactions together to record to the blockchain, it will include a proof demonstrating the authenticity of the state changes caused by the transaction bundle.
Enhanced Smart Contract Functionality: Smart contracts may be designed to interact with outside applications, which may lack the ability to track the state of the blockchain. State proofs offer a succinct means of proving the blockchain’s state to these external parties, expanding the potential applications of smart contracts.
Light Clients: Light clients are blockchain nodes that don’t track the blockchain’s entire digital ledger. Instead, it only tracks the chain of block headers and doesn’t download transaction data. State proofs are useful for light clients because they prove the current state of the blockchain without the need for the light client to view and verify every transaction performed to reach that state.
Cross-Chain Interoperability: Many blockchains were originally designed as standalone systems; however, cross-chain interactions have become increasingly common. The challenge with this is that one blockchain may need to verify or trust the current state of the other. A state proof provides a cryptographically-secured attestation of the current state of a blockchain.
Trustless Interactions: Blockchains are intended to be trustless systems, substituting cryptography and algorithms for implicit trust in a centralized authority. State proofs help to reinforce and support this paradigm by offering a trustless means of verifying the current state of the blockchain environment.
Historical State Verification: In some applications, it may be necessary to verify that the blockchain was in a particular state at a given point in time. This verification may be threatened by the potential for reorgs of the blockchain ledger. State proofs can be used to verify the state of the blockchain at a given time.
State proofs summarize the current state of the blockchain in an authenticated and integrity-preserving format. Both commitment trees and digital signatures offer cryptographic integrity protection, and digital signatures also authenticate the source of the state proof.
From a security perspective, the main risk of state proofs is a failure to validate them. For optimization reasons, a smart contract might check that a proof exists without taking the steps required to ensure that it is a valid proof. This type of mistake is what led to the Wormhole hack in 2022 where a failure to properly validate digital signatures on a cross-chain transfer led to $326 million in losses.