Skip to content

Commit

Permalink
feat: Use tail public inputs as transaction hash (#11100)
Browse files Browse the repository at this point in the history
Implements AztecProtocol/aztec-packages#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
  • Loading branch information
sirasistant authored and AztecBot committed Jan 11, 2025
1 parent fc3af20 commit 26d2b5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions cpp/src/barretenberg/vm/avm/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ void AvmTraceBuilder::insert_private_revertible_state(const std::vector<FF>& 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)));
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/barretenberg/vm/avm/trace/trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 26d2b5f

Please sign in to comment.