-
Notifications
You must be signed in to change notification settings - Fork 234
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
refactor: removing msg-key #4856
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1c3ea1e
refactor: removing msg-key
LHerskind 3f4a922
refactor: prune getL1ToL2Message return value
LHerskind 1c366cf
chore: rename the l1 to l2 oracle
LHerskind e6e2c59
chore: missing throw
LHerskind ecb19b4
chore: purging more msg-key
LHerskind b7d73ea
chore: remove unused log and fix find and replace issues
LHerskind 8dc5687
chore: address comments
LHerskind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,38 @@ | ||
mod l1_to_l2_message; | ||
mod l1_to_l2_message_getter_data; | ||
|
||
use l1_to_l2_message_getter_data::make_l1_to_l2_message_getter_data; | ||
|
||
use crate::oracle::get_l1_to_l2_message::get_l1_to_l2_message_call; | ||
use crate::oracle::get_l1_to_l2_membership_witness::get_l1_to_l2_membership_witness; | ||
|
||
use dep::std::merkle::compute_merkle_root; | ||
use crate::messaging::l1_to_l2_message::L1ToL2Message; | ||
use dep::protocol_types::{constants::L1_TO_L2_MSG_TREE_HEIGHT, address::{AztecAddress, EthAddress}, utils::arr_copy_slice}; | ||
|
||
use dep::protocol_types::address::{AztecAddress, EthAddress}; | ||
|
||
// Returns the nullifier for the message | ||
pub fn process_l1_to_l2_message( | ||
l1_to_l2_root: Field, | ||
storage_contract_address: AztecAddress, | ||
portal_contract_address: EthAddress, | ||
chain_id: Field, | ||
version: Field, | ||
msg_key: Field, | ||
content: Field, | ||
secret: Field | ||
) -> Field { | ||
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); | ||
let msg = L1ToL2Message::new( | ||
portal_contract_address, | ||
chain_id, | ||
storage_contract_address, | ||
version, | ||
content, | ||
secret | ||
); | ||
let entry_key = msg.hash(); | ||
|
||
// Check that the returned message is actually the message we looked up | ||
let msg_hash = l1_to_l2_message_data.message.hash(); | ||
assert(msg_hash == msg_key, "Message not matching requested key"); | ||
let returned_message = get_l1_to_l2_membership_witness(entry_key); | ||
let leaf_index = returned_message[0]; | ||
let sibling_path = arr_copy_slice(returned_message, [0; L1_TO_L2_MSG_TREE_HEIGHT], 1); | ||
|
||
// 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 | ||
); | ||
// This is implicitly checking that the values of the message are correct | ||
let root = compute_merkle_root(entry_key, leaf_index, sibling_path); | ||
assert(root == l1_to_l2_root, "Message not in state"); | ||
|
||
// Validate this is the target contract | ||
assert(l1_to_l2_message_data.message.recipient.eq(storage_contract_address), "Invalid recipient"); | ||
|
||
// Validate the sender is the portal contract | ||
assert(l1_to_l2_message_data.message.sender.eq(portal_contract_address), "Invalid sender"); | ||
|
||
// Validate the chain id is correct | ||
assert(l1_to_l2_message_data.message.chainId == chain_id, "Invalid Chainid"); | ||
|
||
// Validate the version is correct | ||
assert(l1_to_l2_message_data.message.version == version, "Invalid Version"); | ||
|
||
// Validate the message hash is correct | ||
assert(l1_to_l2_message_data.message.content == content, "Invalid Content"); | ||
|
||
// Validate the message secret is correct | ||
l1_to_l2_message_data.message.validate_message_secret(); | ||
|
||
// Compute Nullifier | ||
l1_to_l2_message_data.message.compute_nullifier() | ||
msg.compute_nullifier() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!