Skip to content

Commit

Permalink
chore: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Jun 11, 2024
1 parent b1ba695 commit 595abc0
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn emit_with_keys<Note, N, NB, M>(
context.emit_raw_note_log(note_hash_counter, encrypted_log);
}

pub fn with_az_enc<Note, N, NB, M>(
pub fn encode_and_encrypt<Note, N, NB, M>(
context: &mut PrivateContext,
ov: AztecAddress,
iv: AztecAddress
Expand All @@ -46,7 +46,7 @@ pub fn with_az_enc<Note, N, NB, M>(
}
}

pub fn with_az_enc_with_keys<Note, N, NB, M>(
pub fn encode_and_encrypt_with_keys<Note, N, NB, M>(
context: &mut PrivateContext,
ovpk: GrumpkinPoint,
ivpk: GrumpkinPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint};
use crate::{context::PrivateContext, state_vars::private_mutable::PrivateMutable};
use crate::test::{mocks::mock_note::MockNote, helpers::context_builder::ContextBuilder};
use dep::std::{unsafe::zeroed, test::OracleMock};
use crate::encrypted_logs::encrypted_note_emission::with_az_enc_with_keys;
use crate::encrypted_logs::encrypted_note_emission::encode_and_encrypt_with_keys;

global contract_address = AztecAddress::from_field(13);
global storage_slot = 17;
Expand All @@ -28,7 +28,7 @@ fn test_initialize_or_replace_without_nullifier() {
let mut note = MockNote::new(value).contract_address(contract_address).storage_slot(storage_slot).build();

OracleMock::mock("checkNullifierExists").returns(0);
state_var.initialize_or_replace(&mut note).emit(with_az_enc_with_keys(state_var.context, ovpk_m, ivpk_m));
state_var.initialize_or_replace(&mut note).emit(encode_and_encrypt_with_keys(state_var.context, ovpk_m, ivpk_m));

// Since we reported there was no nullifier, we should initialize and see the following side-effects:
// - a new note being created
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::aztec::{
context::PrivateContext, protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint},
note::note_getter_options::NoteGetterOptions, state_vars::PrivateSet,
encrypted_logs::encrypted_note_emission::with_az_enc
encrypted_logs::encrypted_note_emission::encode_and_encrypt
};
use dep::value_note::{filter::filter_notes_min_sum, value_note::ValueNote};

Expand Down Expand Up @@ -30,7 +30,7 @@ impl<Context> EasyPrivateUint<&mut PrivateContext> {

// Insert the new note to the owner's set of notes.
// docs:start:insert
self.set.insert(&mut addend_note).emit(with_az_enc(self.context, outgoing_viewer, owner));
self.set.insert(&mut addend_note).emit(encode_and_encrypt(self.context, outgoing_viewer, owner));
// docs:end:insert
}

Expand Down Expand Up @@ -63,6 +63,6 @@ impl<Context> EasyPrivateUint<&mut PrivateContext> {
// Creates change note for the owner.
let result_value = minuend - subtrahend;
let mut result_note = ValueNote::new(result_value as Field, owner_npk_m_hash);
self.set.insert(&mut result_note).emit(with_az_enc(self.context, outgoing_viewer, owner));
self.set.insert(&mut result_note).emit(encode_and_encrypt(self.context, outgoing_viewer, owner));
}
}
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/value-note/src/utils.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::aztec::prelude::{AztecAddress, PrivateContext, PrivateSet, NoteGetterOptions};
use dep::aztec::note::note_getter_options::SortOrder;
use dep::aztec::protocol_types::grumpkin_point::GrumpkinPoint;
use dep::aztec::encrypted_logs::encrypted_note_emission::with_az_enc;
use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt;
use crate::{filter::filter_notes_min_sum, value_note::{ValueNote, VALUE_NOTE_LEN, VALUE_NOTE_BYTES_LEN}};

// Sort the note values (0th field) in descending order.
Expand All @@ -23,7 +23,7 @@ pub fn increment(

let mut note = ValueNote::new(amount, recipient_npk_m_hash);
// Insert the new note to the owner's set of notes and emit the log if value is non-zero.
balance.insert(&mut note).emit(with_az_enc(balance.context, outgoing_viewer, recipient));
balance.insert(&mut note).emit(encode_and_encrypt(balance.context, outgoing_viewer, recipient));
}

// Find some of the `owner`'s notes whose values add up to the `amount`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract AppSubscription {
AztecAddress, FunctionSelector, PrivateContext, NoteHeader, Map, PrivateMutable, PublicMutable,
SharedImmutable
},
encrypted_logs::encrypted_note_emission::with_az_enc,
encrypted_logs::encrypted_note_emission::encode_and_encrypt,
protocol_types::{traits::is_empty, grumpkin_point::GrumpkinPoint}
},
authwit::{account::AccountActions, auth_witness::get_auth_witness, auth::assert_current_call_valid_authwit},
Expand Down Expand Up @@ -45,7 +45,7 @@ contract AppSubscription {

// We are emitting both the outgoing and the incoming logs to the subscriber here because passing a separate
// outgoing_viewer arg to entrypoint function is impractical and the outgoing are not so valuable here.
storage.subscriptions.at(user_address).replace(&mut note).emit(with_az_enc(&mut context, user_address, user_address));
storage.subscriptions.at(user_address).replace(&mut note).emit(encode_and_encrypt(&mut context, user_address, user_address));

context.set_as_fee_payer();

Expand Down Expand Up @@ -116,7 +116,7 @@ contract AppSubscription {
let subscriber_npk_m_hash = header.get_npk_m_hash(&mut context, subscriber_address);

let mut subscription_note = SubscriptionNote::new(subscriber_npk_m_hash, expiry_block_number, tx_count);
storage.subscriptions.at(subscriber_address).initialize_or_replace(&mut subscription_note).emit(with_az_enc(&mut context, context.msg_sender(), subscriber_address));
storage.subscriptions.at(subscriber_address).initialize_or_replace(&mut subscription_note).emit(encode_and_encrypt(&mut context, context.msg_sender(), subscriber_address));
}

unconstrained fn is_initialized(subscriber_address: AztecAddress) -> pub bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use dep::aztec::{
traits::{ToField, Serialize, FromField}, grumpkin_point::GrumpkinPoint,
constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL
},
encrypted_logs::encrypted_note_emission::with_az_enc_with_keys, note::note_getter::view_notes,
encrypted_logs::encrypted_note_emission::encode_and_encrypt_with_keys, note::note_getter::view_notes,
state_vars::PrivateSet, note::constants::MAX_NOTES_PER_PAGE
};
use dep::std;
Expand Down Expand Up @@ -114,7 +114,7 @@ impl Deck<&mut PrivateContext> {
let mut inserted_cards = &[];
for card in cards {
let mut card_note = CardNote::from_card(card, owner_npk_m_hash);
self.set.insert(&mut card_note.note).emit(with_az_enc_with_keys(self.set.context, msg_sender_ovpk_m, owner_ivpk_m));
self.set.insert(&mut card_note.note).emit(encode_and_encrypt_with_keys(self.set.context, msg_sender_ovpk_m, owner_ivpk_m));
inserted_cards = inserted_cards.push_back(card_note);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contract Child {
context::gas::GasOpts,
protocol_types::{abis::call_context::CallContext, grumpkin_point::GrumpkinPoint},
note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader},
encrypted_logs::encrypted_note_emission::with_az_enc
encrypted_logs::encrypted_note_emission::encode_and_encrypt
};
use dep::value_note::value_note::ValueNote;

Expand Down Expand Up @@ -56,7 +56,7 @@ contract Child {
let owner_npk_m_hash = header.get_npk_m_hash(&mut context, owner);

let mut note = ValueNote::new(new_value, owner_npk_m_hash);
storage.a_map_with_private_values.at(owner).insert(&mut note).emit(with_az_enc(&mut context, context.msg_sender(), owner));
storage.a_map_with_private_values.at(owner).insert(&mut note).emit(encode_and_encrypt(&mut context, context.msg_sender(), owner));
new_value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contract Crowdfunding {
abis::function_selector::FunctionSelector, address::AztecAddress, traits::Serialize,
grumpkin_point::GrumpkinPoint
},
encrypted_logs::encrypted_note_emission::with_az_enc,
encrypted_logs::encrypted_note_emission::encode_and_encrypt,
state_vars::{PrivateSet, PublicImmutable, SharedImmutable}
};
use dep::value_note::value_note::ValueNote;
Expand Down Expand Up @@ -87,7 +87,7 @@ contract Crowdfunding {
// contract by proving that the hash of this note exists in the note hash tree.
let donor_npk_m_hash = header.get_npk_m_hash(&mut context, donor);
let mut note = ValueNote::new(amount as Field, donor_npk_m_hash);
storage.donation_receipts.insert(&mut note).emit(with_az_enc(&mut context, donor, donor));
storage.donation_receipts.insert(&mut note).emit(encode_and_encrypt(&mut context, donor, donor));
}
// docs:end:donate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ contract DelegatedOn {
AztecAddress, FunctionSelector, NoteHeader, NoteGetterOptions, NoteViewerOptions, PublicMutable,
PrivateSet, PrivateContext, Map
};
use dep::aztec::encrypted_logs::encrypted_note_emission::with_az_enc;
use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt;
use dep::aztec::{protocol_types::grumpkin_point::GrumpkinPoint};
use dep::value_note::value_note::ValueNote;

Expand All @@ -20,7 +20,7 @@ contract DelegatedOn {
let owner_npk_m_hash = header.get_npk_m_hash(&mut context, owner);

let mut note = ValueNote::new(new_value, owner_npk_m_hash);
storage.a_map_with_private_values.at(owner).insert(&mut note).emit(with_az_enc(&mut context, context.msg_sender(), owner));
storage.a_map_with_private_values.at(owner).insert(&mut note).emit(encode_and_encrypt(&mut context, context.msg_sender(), owner));
new_value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract DocsExample {
PrivateContext, Map, PublicMutable, PublicImmutable, PrivateMutable, PrivateImmutable,
PrivateSet, SharedImmutable, Deserialize
};
use dep::aztec::encrypted_logs::encrypted_note_emission::{with_az_enc, with_az_enc_with_keys};
use dep::aztec::encrypted_logs::encrypted_note_emission::{encode_and_encrypt, encode_and_encrypt_with_keys};
use dep::aztec::note::note_getter_options::Comparator;
use dep::aztec::protocol_types::grumpkin_point::GrumpkinPoint;
// how to import methods from other files/folders within your workspace
Expand Down Expand Up @@ -173,7 +173,7 @@ contract DocsExample {
let msg_sender_npk_m_hash = header.get_npk_m_hash(&mut context, context.msg_sender());

let mut new_card = CardNote::new(points, randomness, msg_sender_npk_m_hash);
storage.private_immutable.initialize(&mut new_card).emit(with_az_enc(&mut context, context.msg_sender(), context.msg_sender()));
storage.private_immutable.initialize(&mut new_card).emit(encode_and_encrypt(&mut context, context.msg_sender(), context.msg_sender()));
}
// docs:end:initialize-private-mutable

Expand All @@ -185,7 +185,7 @@ contract DocsExample {

let mut legendary_card = CardNote::new(points, randomness, msg_sender_npk_m_hash);
// create and broadcast note
storage.legendary_card.initialize(&mut legendary_card).emit(with_az_enc(&mut context, context.msg_sender(), context.msg_sender()));
storage.legendary_card.initialize(&mut legendary_card).emit(encode_and_encrypt(&mut context, context.msg_sender(), context.msg_sender()));
}

#[aztec(private)]
Expand All @@ -197,7 +197,7 @@ contract DocsExample {

for i in 0..amounts.len() {
let mut note = CardNote::new(amounts[i], 1, msg_sender_npk_m_hash);
storage.set.insert(&mut note).emit(with_az_enc_with_keys(&mut context, msg_sender_ovpk_m, msg_sender_ivpk_m));
storage.set.insert(&mut note).emit(encode_and_encrypt_with_keys(&mut context, msg_sender_ovpk_m, msg_sender_ivpk_m));
}
}

Expand All @@ -207,7 +207,7 @@ contract DocsExample {
let msg_sender_npk_m_hash = header.get_npk_m_hash(&mut context, context.msg_sender());

let mut note = CardNote::new(amount, randomness, msg_sender_npk_m_hash);
storage.set.insert(&mut note).emit(with_az_enc(&mut context, context.msg_sender(), context.msg_sender()));
storage.set.insert(&mut note).emit(encode_and_encrypt(&mut context, context.msg_sender(), context.msg_sender()));
}

// docs:start:state_vars-NoteGetterOptionsComparatorExampleNoir
Expand All @@ -231,7 +231,7 @@ contract DocsExample {
let msg_sender_npk_m_hash = header.get_npk_m_hash(&mut context, context.msg_sender());

let mut new_card = CardNote::new(points, randomness, msg_sender_npk_m_hash);
storage.legendary_card.replace(&mut new_card).emit(with_az_enc(&mut context, context.msg_sender(), context.msg_sender()));
storage.legendary_card.replace(&mut new_card).emit(encode_and_encrypt(&mut context, context.msg_sender(), context.msg_sender()));
DocsExample::at(context.this_address()).update_leader(context.msg_sender(), points).enqueue(&mut context);
}

Expand All @@ -252,7 +252,7 @@ contract DocsExample {

let mut new_card = CardNote::new(points, card.randomness, msg_sender_npk_m_hash);
// docs:start:state_vars-PrivateMutableReplace
storage.legendary_card.replace(&mut new_card).emit(with_az_enc(&mut context, context.msg_sender(), context.msg_sender()));
storage.legendary_card.replace(&mut new_card).emit(encode_and_encrypt(&mut context, context.msg_sender(), context.msg_sender()));
// docs:end:state_vars-PrivateMutableReplace

DocsExample::at(context.this_address()).update_leader(context.msg_sender(), points).enqueue(&mut context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod ecdsa_public_key_note;
// The signing key is stored in an immutable private note and should be different from the signing key.
contract EcdsaAccount {
use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, NoteGetterOptions, PrivateContext, PrivateImmutable};
use dep::aztec::encrypted_logs::encrypted_note_emission::with_az_enc;
use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt;

use dep::aztec::protocol_types::abis::call_context::CallContext;
use dep::std;
Expand Down Expand Up @@ -35,7 +35,7 @@ contract EcdsaAccount {
// important.

let mut pub_key_note = EcdsaPublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this_npk_m_hash);
storage.public_key.initialize(&mut pub_key_note).emit(with_az_enc(&mut context, this, this));
storage.public_key.initialize(&mut pub_key_note).emit(encode_and_encrypt(&mut context, this, this));
}

// Note: If you globally change the entrypoint signature don't forget to update default_entrypoint.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Sample escrow contract that stores a balance of a private token on behalf of an owner.
contract Escrow {
use dep::aztec::prelude::{AztecAddress, EthAddress, FunctionSelector, NoteHeader, PrivateContext, PrivateImmutable};
use dep::aztec::encrypted_logs::encrypted_note_emission::with_az_enc;
use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt;

use dep::address_note::address_note::AddressNote;

Expand All @@ -20,7 +20,7 @@ contract Escrow {
let owner_npk_m_hash = header.get_npk_m_hash(&mut context, owner);

let mut note = AddressNote::new(owner, owner_npk_m_hash);
storage.owner.initialize(&mut note).emit(with_az_enc(&mut context, context.msg_sender(), owner));
storage.owner.initialize(&mut note).emit(encode_and_encrypt(&mut context, context.msg_sender(), owner));
}

// Withdraws balance. Requires that msg.sender is the owner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ contract InclusionProofs {
AztecAddress, EthAddress, FunctionSelector, NoteHeader, NoteGetterOptions, PrivateContext, Map,
PrivateSet, PublicMutable
};
use dep::aztec::encrypted_logs::encrypted_note_emission::with_az_enc;
use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt;

use dep::aztec::protocol_types::{grumpkin_point::GrumpkinPoint, contract_class_id::ContractClassId, header::Header};
use dep::aztec::{note::note_getter_options::NoteStatus};
Expand Down Expand Up @@ -36,7 +36,7 @@ contract InclusionProofs {
let owner_npk_m_hash = header.get_npk_m_hash(&mut context, owner);

let mut note = ValueNote::new(value, owner_npk_m_hash);
owner_private_values.insert(&mut note).emit(with_az_enc(&mut context, context.msg_sender(), owner));
owner_private_values.insert(&mut note).emit(encode_and_encrypt(&mut context, context.msg_sender(), owner));
}
// docs:end:create_note

Expand Down
Loading

0 comments on commit 595abc0

Please sign in to comment.