diff --git a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp index 6f4486319f4..bb4cdf82959 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp +++ b/circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp @@ -360,8 +360,9 @@ WASM_EXPORT void abis__compute_contract_leaf(uint8_t const* contract_leaf_preima { NewContractData leaf_preimage; read(contract_leaf_preimage_buf, leaf_preimage); - leaf_preimage.hash(); - NT::fr::serialize_to_buffer(leaf_preimage.hash(), output); + // as per the circuit implementation, if contract address == zero then return a zero leaf + auto to_write = leaf_preimage.contract_address == NT::address(0) ? NT::fr(0) : leaf_preimage.hash(); + NT::fr::serialize_to_buffer(to_write, output); } /* Typescript test helpers that call as_string_output() to stress serialization. diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 7ede6c7b1e3..d2f266d15d5 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -238,7 +238,8 @@ TEST_F(base_rollup_tests, contract_leaf_inserted) // create expected end contract tree snapshot auto expected_contract_leaf = crypto::pedersen_hash::hash_multiple( - { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }); + { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }, + GeneratorIndex::CONTRACT_LEAF); auto expeted_end_contracts_snapshot_tree = stdlib::merkle_tree::MemoryTree(CONTRACT_TREE_HEIGHT); expeted_end_contracts_snapshot_tree.update_element(0, expected_contract_leaf); @@ -284,7 +285,8 @@ TEST_F(base_rollup_tests, contract_leaf_inserted_in_non_empty_snapshot_tree) // create expected end contract tree snapshot auto expected_contract_leaf = crypto::pedersen_hash::hash_multiple( - { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }); + { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }, + GeneratorIndex::CONTRACT_LEAF); auto expeted_end_contracts_snapshot_tree = start_contract_tree_snapshot; expeted_end_contracts_snapshot_tree.update_element(12, expected_contract_leaf); @@ -533,7 +535,8 @@ TEST_F(base_rollup_tests, calldata_hash) .function_tree_root = fr(2), }; auto contract_leaf = crypto::pedersen_hash::hash_multiple( - { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }); + { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }, + GeneratorIndex::CONTRACT_LEAF); inputs.kernel_data[0].public_inputs.end.new_contracts[0] = new_contract; auto contract_leaf_buffer = contract_leaf.to_buffer(); auto contract_address_buffer = new_contract.contract_address.to_field().to_buffer(); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index e50e0d81132..3f0f12b4a66 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -87,8 +87,8 @@ std::vector calculate_contract_leaves(BaseRollupInputs baseRollupInputs) NT::fr function_tree_root = new_contacts[j].function_tree_root; // Pedersen hash of the 3 fields (contract_address, portal_contract_address, function_tree_root) - auto contract_leaf = - crypto::pedersen_hash::hash_multiple({ contract_address, portal_contract_address, function_tree_root }); + auto contract_leaf = crypto::pedersen_hash::hash_multiple( + { contract_address, portal_contract_address, function_tree_root }, GeneratorIndex::CONTRACT_LEAF); // When there is no contract deployment, we should insert a zero leaf into the tree and ignore the // member-ship check. This is to ensure that we don't hit "already deployed" errors when we are not diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp index 0fa7fb8976e..0f338199031 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp @@ -279,7 +279,8 @@ TEST_F(root_rollup_tests, almost_full_root) }; base_inputs_2.kernel_data[0].public_inputs.end.new_contracts[0] = new_contract; auto contract_leaf = crypto::pedersen_hash::hash_multiple( - { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }); + { new_contract.contract_address, new_contract.portal_contract_address, new_contract.function_tree_root }, + GeneratorIndex::CONTRACT_LEAF); contract_tree.update_element(0, contract_leaf); base_inputs_2.new_contracts_subtree_sibling_path =