Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::protocol::{hash::poseidon2_hash_bytes, traits::{Deserialize, Empty, F

#[derive(Eq, Serialize, Deserialize)]
pub struct AuthorizationSelector {
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
// Low 32 bits of the poseidon2 hash of the function signature.
inner: u32,
}

Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/event/event_selector.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::protocol::{hash::poseidon2_hash_bytes, traits::{Deserialize, Empty, F

#[derive(Deserialize, Eq, Serialize)]
pub struct EventSelector {
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
// Low 32 bits of the poseidon2 hash of the event signature.
inner: u32,
}

Expand Down
16 changes: 15 additions & 1 deletion noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,25 @@ pub comptime fn noinitcheck(f: FunctionDefinition) {
}
}

/// An allow_phase_change function will allow transitioning from the non-revertible to the revertible phase during its
/// An `allow_phase_change` function will allow transitioning from the non-revertible to the revertible phase during its
/// execution.
///
/// This is an advanced feature that is typically only required for account contract entrypoints that handle
/// transaction fee payment.
///
/// ## Note Retrieval
///
/// When notes are read e.g. via [`crate::note::note_getter::get_notes`], a
/// [`ConfirmedNote`](crate::note::ConfirmedNote) value is returned which includes note metadata, notably whether the
/// note was created in a previous transaction (a settled note) or in the current one (a pending note), either in the
/// current or previous phase. Because `allow_phase_change` functions can change phases, this metadata can be left
/// stale, e.g. it is possible to read a pending current phase note and then change phases, resulting in the note being
/// pending previous phase insted.
///
/// Such a note would be rejected by the kernels if it was tried to be nullified, as the metadata is incorrect. It is
/// therefore important to not allow [`ConfirmedNote`](crate::note::ConfirmedNote),
/// [`HintedNote`](crate::note::HintedNote) or [`NoteMetadata`](crate::note::note_metadata::NoteMetadata) values to
/// cross the phase barrier caused by [`crate::context::PrivateContext::end_setup`].
pub comptime fn allow_phase_change(f: FunctionDefinition) {
// Marker attribute - see the comment at the top of this file
if !is_fn_external(f) {
Expand Down
14 changes: 5 additions & 9 deletions noir-projects/aztec-nr/uint-note/src/uint_note.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use aztec::{
context::{PrivateContext, PublicContext},
history::nullifier::assert_nullifier_existed_by,
context::{NullifierExistenceRequest, PrivateContext, PublicContext},
keys::getters::{get_nhk_app, get_public_keys, try_get_public_keys},
macros::notes::custom_note,
messages::{
Expand Down Expand Up @@ -216,14 +215,11 @@ impl PartialUintNote {
// We verify that the partial note we're completing is valid (i.e. completer is correct, it uses the correct
// state variable's storage slot, and it is internally consistent).
let validity_commitment = self.compute_validity_commitment(completer);
// `assert_nullifier_existed_by` function expects the nullifier to be siloed (hashed with the address of the
// contract that emitted the nullifier) as it checks the value directly against the nullifier tree and all the
// nullifiers in the tree are siloed by the protocol.

let siloed_validity_commitment = compute_siloed_nullifier(context.this_address(), validity_commitment);
assert_nullifier_existed_by(
context.get_anchor_block_header(),
siloed_validity_commitment,
);
// Note that this means we don't support scenarios in which the validity commitment was created in the same
// transaction.
context.assert_nullifier_exists(NullifierExistenceRequest::for_settled(siloed_validity_commitment));

// We need to do two things:
// - emit an unencrypted log containing the public fields (the storage slot and value) via the private log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::meta::derive;

#[derive(Deserialize, Eq, Serialize)]
pub struct FunctionSelector {
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
// Low 32 bits of the poseidon2 hash of the function signature.
pub inner: u32,
}

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/stdlib/src/abi/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { bufferToHex } from '@aztec/foundation/string';

import { inspect } from 'util';

/** A selector is the first 4 bytes of the hash of a signature. */
/** A selector is the low 4 bytes of the poseidon2 hash of a signature. */
export abstract class Selector {
/** The size of the selector in bytes. */
public static SIZE = 4;
Expand Down
Loading