Receipt Proof
Brevis receipt proof attestation via zk-SNARKs enables efficient verification of any transactions' receipt (included in the synced blocks) that happened on a connected remote chain.
Similar to the storage slot value proof described in the previous section, receipt proof is also using the synced block header information stored on the destination chain as the ground truth. With this, one can prove the source chain's receipt information by proving the following parts:
- 1.validity of a block receipt root that matches the synced block header info;
- 2.validity of the receipt leaf hash that matches the receipt root.
The rest of this page outlines the mechanisms for implementing receipt proof attestation:
This circuit is composed of two parts, including MPT calculation and block header calculation.
Public Inputs (can be used by on-chain app contracts):
LeafHash
Leaf node (receipt leaf node) key of the receipt MPT.BlockHash
Hash of the block which include this receipt.BlockNumber
Number of the block which include this receipt.BlockTime
Time of the block which include this receipt.
Private Inputs:
Key
The key nibble of the receipt in MPT.KeyLength
The length of the key above.RootHash
Receipt MPT root hash.KeyFragmentStarts
The index for each node in key nibbles.NodeRlp
Node value for each node in the merkle branch.NodeRlpRoundIndexes
NodeRlp keecak round number.NodePathPrefixLength
Length for check node type in merkle branch.NodeTypes
MPT node type.Depth
MPT depth.BlockHashRlp
Block rlp.BlockFieldsNum
Block fields count.BlockRoundIndex
Block hash keccak count from block rlp.
The receipt root hash is one field of the block header RLP, which is used to calculate the block hash. The circuit first proves that the receipt root hash is included in the decoded block RLP, and then it computes the keccak hash of the block RLP to match the provided public input.
To prove the validity of the public input receipt leaf hash, the circuit uses the Merkel branch that includes the receipt leaf to compute the MPT root hash and verify that it matches the validated receipt root hash. Note that the circuit only validates the receipt leaf hash, leaving the validation of receipt RLP fields to the on-chain verifier contract.
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.
The ZK proof and metadata generated by the Brevis proofing system can be submitted to the ReceiptVerifier contract through the
verifyReceipt
function to get the ZK-attested slot value. Please refer to this section for smart contract usage.