From 26d2b5f09d5dcbcada16b3d6a1fb7fb0f9d2b4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Rodr=C3=ADguez?= Date: Fri, 10 Jan 2025 13:51:37 +0100 Subject: [PATCH] feat: Use tail public inputs as transaction hash (#11100) Implements https://github.com/AztecProtocol/aztec-packages/issues/9269 Separates the role of the first nullifier and the transaction hash. The transaction hash is now the hash of the tail public inputs. The first nullifier is still used for note uniqueness and replayability protection --- cpp/src/barretenberg/vm/avm/trace/trace.cpp | 7 ++++--- cpp/src/barretenberg/vm/avm/trace/trace.hpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cpp/src/barretenberg/vm/avm/trace/trace.cpp b/cpp/src/barretenberg/vm/avm/trace/trace.cpp index cd7e26908..346ac3b05 100644 --- a/cpp/src/barretenberg/vm/avm/trace/trace.cpp +++ b/cpp/src/barretenberg/vm/avm/trace/trace.cpp @@ -288,7 +288,8 @@ void AvmTraceBuilder::insert_private_revertible_state(const std::vector& sil for (size_t i = 0; i < siloed_note_hashes.size(); i++) { size_t note_index_in_tx = i + get_inserted_note_hashes_count(); - FF nonce = AvmMerkleTreeTraceBuilder::unconstrained_compute_note_hash_nonce(get_tx_hash(), note_index_in_tx); + FF nonce = + AvmMerkleTreeTraceBuilder::unconstrained_compute_note_hash_nonce(get_first_nullifier(), note_index_in_tx); unique_note_hashes.push_back( AvmMerkleTreeTraceBuilder::unconstrained_compute_unique_note_hash(nonce, siloed_note_hashes.at(i))); } @@ -3101,8 +3102,8 @@ AvmError AvmTraceBuilder::op_emit_note_hash(uint8_t indirect, uint32_t note_hash AppendTreeHint note_hash_write_hint = execution_hints.note_hash_write_hints.at(note_hash_write_counter++); FF siloed_note_hash = AvmMerkleTreeTraceBuilder::unconstrained_silo_note_hash( current_public_call_request.contract_address, row.main_ia); - FF nonce = - AvmMerkleTreeTraceBuilder::unconstrained_compute_note_hash_nonce(get_tx_hash(), inserted_note_hashes_count); + FF nonce = AvmMerkleTreeTraceBuilder::unconstrained_compute_note_hash_nonce(get_first_nullifier(), + inserted_note_hashes_count); FF unique_note_hash = AvmMerkleTreeTraceBuilder::unconstrained_compute_unique_note_hash(nonce, siloed_note_hash); ASSERT(unique_note_hash == note_hash_write_hint.leaf_value); diff --git a/cpp/src/barretenberg/vm/avm/trace/trace.hpp b/cpp/src/barretenberg/vm/avm/trace/trace.hpp index 0ae4e06d9..a2c750d63 100644 --- a/cpp/src/barretenberg/vm/avm/trace/trace.hpp +++ b/cpp/src/barretenberg/vm/avm/trace/trace.hpp @@ -395,7 +395,7 @@ class AvmTraceBuilder { uint32_t get_inserted_note_hashes_count(); uint32_t get_inserted_nullifiers_count(); uint32_t get_public_data_writes_count(); - FF get_tx_hash() const { return public_inputs.previous_non_revertible_accumulated_data.nullifiers[0]; } + FF get_first_nullifier() const { return public_inputs.previous_non_revertible_accumulated_data.nullifiers[0]; } // TODO: remove these once everything is constrained. AvmMemoryTag unconstrained_get_memory_tag(AddressWithMode addr);