Skip to content

Commit

Permalink
add comment tying together subtreeupdate circuit & OffchainMerkle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sladuca committed Aug 4, 2023
1 parent 38cb6a9 commit b68fc7b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/contracts/contracts/libs/OffchainMerkleTree.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ library LibOffchainMerkleTree {
) internal {
uint256[] memory pis = _calculatePublicInputs(self, newRoot);

// 1) this library computes accumulatorHash on its own,
// the definition of accumulatorHash prevents collisions (different batch with same hash),
// and the subtree update circuit guarantees `accumulatorHash` is re-computed correctly,
// so if the circuit accepts, the only possible batch the updater could be inserting is precisely
// the batch we've enqueued here on-chain
// 2) the subtree update circuit guarantees that the new root is computed correctly,
// so due to (1), the only possible newRoot is the newRoot that results from inserting
// the batch we've enqueued here on-chain
require(
self.subtreeUpdateVerifier.verifyProof(proof, pis),
"subtree update proof invalid"
Expand Down

0 comments on commit b68fc7b

Please sign in to comment.