Brevis
Search
K

Slot Value Proof

Brevis storage proof attestation via zk-SNARKs enables efficient verification of any EVM storage slot value from a connected remote chain.
Previous sections described how Brevis sync (historical) block headers through ZK proofs. By using the synced block header information as the ground truth, one can prove the remote chain's EVM storage slot value by proving the following three parts:
  1. 1.
    validity of a block state root that matches the synced block header info;
  2. 2.
    validity of the contract account storage within the block state root;
  3. 3.
    validity of the slot value with the account storage.

Circuit

Public Inputs (can be used by on-chain app contracts):
  • BlockHash: block hash of this slot located
  • AddressProofKey: keccak256(eth address) as the account proof RLP key
  • Slot: slot key
  • SlotValue: slot value, also included in the storage MPT leaf
  • BockNumber: block number of this slot located
Private inputs include data fields about
  • Block header RLP
  • Account proof MPT information, including account address keccak256 hash, the account proof leaf RLP, account proof MPT node RLP array
  • Storage proof MPT information, including storage key hash, storage value RLP, storage MPT leaf RLP, and storage MPT node RLP array
Given a block number and block header RLP, the circuit attests to the validity of the RLP data and verifies whether the decoded block number matches the given block number. Meanwhile, the circuit decodes the state root for the account circuit.
The account circuit takes the account MPT (Merkle Patricia Trie) and account info RLP as private inputs and the account address as public input. It proves the validity of the account MPT and checks if the MPT root matches the state root in the block header. The circuit also decodes the storage hash for the storage circuit.
The storage circuit takes the storage MPT as the private input and the slot key/value as the public input. It proves the inclusion of the slot value in the MPT leaf, validates the MPT, and verifies if the MPT root matches the storage hash obtained from the account circuit.
These circuit components together form a storage proof circuit, with a storage proof automatically generated upon the arrival of a new slot attestation request.

Contract

Slot Value Circuit Verifier

The circuit verifier contract is generated by gnark verifier. The main process of this contract is to check the correctness of the proof by calculating the pairing on BN254 using Groth16.

Slot Value App Verifier

The ZK proof and metadata generated by the Brevis proofing system can be submitted to the SlotValueVerifier contract through the verifySlotValue function to get the ZK-attested slot value. Please refer to this section for smart contract usage.