diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr index 202da79eb183..b6b60d7d1642 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr @@ -1,21 +1,22 @@ -use dep::aztec::prelude::{AztecAddress, PrivateContext, NoteHeader, NoteInterface}; use dep::aztec::{ - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator}, - note::utils::compute_note_hash_for_nullify, keys::getters::get_nsk_app + hash::poseidon2_hash_with_separator, note::utils::compute_note_hash_for_nullify, + keys::getters::get_nsk_app, oracle::unsafe_rand::unsafe_rand, + prelude::{PrivateContext, NoteHeader, NoteInterface}, + protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER }; -global SUBSCRIPTION_NOTE_LEN: Field = 3; -// ADDRESS_NOTE_LEN * 32 + 32(storage_slot as bytes) + 32(note_type_id as bytes) -global SUBSCRIPTION_NOTE_BYTES_LEN: Field = 3 * 32 + 64; +global SUBSCRIPTION_NOTE_LEN: Field = 4; +// SUBSCRIPTION_NOTE_BYTES_LEN * 32 + 32(storage_slot as bytes) + 32(note_type_id as bytes) +global SUBSCRIPTION_NOTE_BYTES_LEN: Field = SUBSCRIPTION_NOTE_LEN * 32 + 64; -// Stores a public key composed of two fields -// TODO: Do we need to include a nonce, in case we want to read/nullify/recreate with the same pubkey value? #[aztec(note)] struct SubscriptionNote { // The nullifying public key hash is used with the nsk_app to ensure that the note can be privately spent. npk_m_hash: Field, expiry_block_number: Field, remaining_txs: Field, + // Randomness of the note to hide its contents + randomness: Field, } impl NoteInterface for SubscriptionNote { @@ -43,6 +44,9 @@ impl NoteInterface for Subsc impl SubscriptionNote { pub fn new(npk_m_hash: Field, expiry_block_number: Field, remaining_txs: Field) -> Self { - SubscriptionNote { npk_m_hash, expiry_block_number, remaining_txs, header: NoteHeader::empty() } + let randomness = unsafe { + unsafe_rand() + }; + Self { npk_m_hash, expiry_block_number, remaining_txs, randomness, header: NoteHeader::empty() } } }