Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add inclusion check l1->l2 #4141

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions yarn-project/aztec-nr/aztec/src/messaging.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use l1_to_l2_message_getter_data::make_l1_to_l2_message_getter_data;
use crate::abi::PublicContextInputs;
use crate::oracle::get_l1_to_l2_message::get_l1_to_l2_message_call;

use dep::std::merkle::compute_merkle_root;

use dep::protocol_types::address::{
AztecAddress,
EthAddress,
Expand All @@ -25,6 +27,14 @@ pub fn process_l1_to_l2_message(
let returned_message = get_l1_to_l2_message_call(msg_key);
let l1_to_l2_message_data = make_l1_to_l2_message_getter_data(returned_message, 0, secret);

// Check that the returned message is actually the message we looked up
let msg_hash = l1_to_l2_message_data.message.message_hash();
assert(msg_hash == msg_key);

// Check that the message is in the tree
let root = compute_merkle_root(msg_hash, l1_to_l2_message_data.leaf_index, l1_to_l2_message_data.sibling_path);
assert(root == l1_to_l2_root);

// Check tree roots against the inputs
assert(l1_to_l2_message_data.root == l1_to_l2_root);

Expand Down