Skip to content

Commit

Permalink
feat: Check initializer msg.sender matches deployer from address prei…
Browse files Browse the repository at this point in the history
…mage (AztecProtocol/aztec-packages#5222)

Checks that the msg.sender in initializer calls matches the deployer
address defined in the address preimage, unless when it's set to zero.
  • Loading branch information
AztecBot committed Mar 15, 2024
2 parents ef01b8e + 3778f01 commit 142054c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions aztec_macros/src/transforms/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ pub fn transform_function(
func.def.body.0.insert(0, init_check);
}

// Add assertion for initialization arguments
// Add assertion for initialization arguments and sender
if is_initializer {
let assert_init_args = create_assert_init_args();
func.def.body.0.insert(0, assert_init_args);
func.def.body.0.insert(0, create_assert_initializer());
}

// Add access to the storage struct
Expand Down Expand Up @@ -211,18 +210,19 @@ fn create_internal_check(fname: &str) -> Statement {
)))
}

/// Creates a call to assert_initialization_args_match_address_preimage to ensure
/// the initialization arguments used in the init call match the address preimage.
/// Creates a call to assert_initialization_matches_address_preimage to be inserted
/// in the initializer. Checks that the args and sender to the initializer match the
/// commitments from the address preimage.
///
/// ```noir
/// assert_initialization_args_match_address_preimage(context);
/// assert_initialization_matches_address_preimage(context);
/// ```
fn create_assert_init_args() -> Statement {
fn create_assert_initializer() -> Statement {
make_statement(StatementKind::Expression(call(
variable_path(chained_dep!(
"aztec",
"initializer",
"assert_initialization_args_match_address_preimage"
"assert_initialization_matches_address_preimage"
)),
vec![variable("context")],
)))
Expand Down

0 comments on commit 142054c

Please sign in to comment.