diff --git a/.aztec-sync-commit b/.aztec-sync-commit index 5a1cd9c70bd..4d9320c79ba 100644 --- a/.aztec-sync-commit +++ b/.aztec-sync-commit @@ -1 +1 @@ -58e15edf7fd3d32267b0aed883fc84f6cee327c9 +aa90f6ed7bfae06bdf6990816d154bbd24993689 diff --git a/aztec_macros/src/transforms/functions.rs b/aztec_macros/src/transforms/functions.rs index 8b3c7d2f53b..09c11e173fe 100644 --- a/aztec_macros/src/transforms/functions.rs +++ b/aztec_macros/src/transforms/functions.rs @@ -48,6 +48,12 @@ pub fn transform_function( func.def.body.0.insert(0, init_check); } + // Add assertion for initialization arguments + if is_initializer { + let assert_init_args = create_assert_init_args(); + func.def.body.0.insert(0, assert_init_args); + } + // Add access to the storage struct if storage_defined { let storage_def = abstract_storage(&ty.to_lowercase(), false); @@ -205,6 +211,23 @@ 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. +/// +/// ```noir +/// assert_initialization_args_match_address_preimage(context); +/// ``` +fn create_assert_init_args() -> Statement { + make_statement(StatementKind::Expression(call( + variable_path(chained_dep!( + "aztec", + "initializer", + "assert_initialization_args_match_address_preimage" + )), + vec![variable("context")], + ))) +} + /// Creates the private context object to be accessed within the function, the parameters need to be extracted to be /// appended into the args hash object. /// diff --git a/cspell.json b/cspell.json index d961b600f40..d9cf654674f 100644 --- a/cspell.json +++ b/cspell.json @@ -139,6 +139,7 @@ "plonkc", "PLONKish", "pprof", + "preimage", "preprocess", "prettytable", "printstd",