diff --git a/boxes/boxes/react/src/contracts/src/main.nr b/boxes/boxes/react/src/contracts/src/main.nr index ed7cb86ea800..f4924981e8e4 100644 --- a/boxes/boxes/react/src/contracts/src/main.nr +++ b/boxes/boxes/react/src/contracts/src/main.nr @@ -26,7 +26,7 @@ contract BoxReact { let mut new_number = ValueNote::new(number, owner); let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner)); + numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); } #[private] @@ -38,7 +38,7 @@ contract BoxReact { let mut new_number = ValueNote::new(number, owner); let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner)); + numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); } unconstrained fn getNumber(owner: AztecAddress) -> pub ValueNote { diff --git a/boxes/boxes/vanilla/src/contracts/src/main.nr b/boxes/boxes/vanilla/src/contracts/src/main.nr index 98c205b85fd9..c27e8f81a744 100644 --- a/boxes/boxes/vanilla/src/contracts/src/main.nr +++ b/boxes/boxes/vanilla/src/contracts/src/main.nr @@ -26,7 +26,7 @@ contract Vanilla { let mut new_number = ValueNote::new(number, owner); let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner)); + numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); } #[private] @@ -38,7 +38,7 @@ contract Vanilla { let mut new_number = ValueNote::new(number, owner); let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner)); + numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); } unconstrained fn getNumber(owner: AztecAddress) -> pub ValueNote { diff --git a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr index dbbaebb28592..f4fc93e0228c 100644 --- a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr +++ b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr @@ -22,7 +22,7 @@ impl EasyPrivateUint { impl EasyPrivateUint<&mut PrivateContext> { // Very similar to `value_note::utils::increment`. - pub fn add(self, addend: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { + pub fn add(self, addend: u64, owner: AztecAddress, outgoing_viewer: AztecAddress, sender: AztecAddress) { let outgoing_viewer_keys = get_public_keys(outgoing_viewer); // Creates new note for the owner. let mut addend_note = ValueNote::new(addend as Field, owner); @@ -33,12 +33,13 @@ impl EasyPrivateUint<&mut PrivateContext> { self.context, outgoing_viewer_keys.ovpk_m, owner, + sender, )); // docs:end:insert } // Very similar to `value_note::utils::decrement`. - pub fn sub(self, subtrahend: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { + pub fn sub(self, subtrahend: u64, owner: AztecAddress, outgoing_viewer: AztecAddress, sender: AztecAddress) { let outgoing_viewer_keys = get_public_keys(outgoing_viewer); // docs:start:pop_notes @@ -63,6 +64,7 @@ impl EasyPrivateUint<&mut PrivateContext> { self.context, outgoing_viewer_keys.ovpk_m, owner, + sender, )); } } diff --git a/noir-projects/aztec-nr/value-note/src/utils.nr b/noir-projects/aztec-nr/value-note/src/utils.nr index fd7bb7c41c81..06eaca64a06c 100644 --- a/noir-projects/aztec-nr/value-note/src/utils.nr +++ b/noir-projects/aztec-nr/value-note/src/utils.nr @@ -23,6 +23,7 @@ pub fn increment( amount: Field, recipient: AztecAddress, outgoing_viewer: AztecAddress, // docs:end:increment_args + sender: AztecAddress, ) { let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; @@ -32,6 +33,7 @@ pub fn increment( balance.context, outgoing_viewer_ovpk_m, recipient, + sender, )); } @@ -44,8 +46,9 @@ pub fn decrement( amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress, + sender: AztecAddress, ) { - let sum = decrement_by_at_most(balance, amount, owner, outgoing_viewer); + let sum = decrement_by_at_most(balance, amount, owner, outgoing_viewer, sender); assert(sum == amount, "Balance too low"); } @@ -62,6 +65,7 @@ pub fn decrement_by_at_most( max_amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress, + sender: AztecAddress, ) -> Field { let options = create_note_getter_options_for_decreasing_balance(max_amount); let notes = balance.pop_notes(options); @@ -80,7 +84,7 @@ pub fn decrement_by_at_most( change_value = decremented - max_amount; decremented -= change_value; } - increment(balance, change_value, owner, outgoing_viewer); + increment(balance, change_value, owner, outgoing_viewer, sender); decremented } diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr index 2e9f3e9299dd..4d1b2f542e1a 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr @@ -53,6 +53,7 @@ contract AppSubscription { &mut context, keys.ovpk_m, user_address, + user_address, )); context.set_as_fee_payer(); @@ -116,7 +117,7 @@ contract AppSubscription { let mut subscription_note = SubscriptionNote::new(subscriber, expiry_block_number, tx_count); storage.subscriptions.at(subscriber).initialize_or_replace(&mut subscription_note).emit( - encode_and_encrypt_note(&mut context, msg_sender_ovpk_m, subscriber), + encode_and_encrypt_note(&mut context, msg_sender_ovpk_m, subscriber, context.msg_sender()), ); } diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index 2cc91c195dbe..34edfa95d375 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -118,6 +118,7 @@ impl Deck<&mut PrivateContext> { self.set.context, msg_sender_ovpk_m, owner, + self.set.context.msg_sender(), )); inserted_cards = inserted_cards.push_back(card_note); } diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index a07237b535ac..9a995e47d959 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -63,6 +63,7 @@ contract Child { &mut context, owner_ovpk_m, owner, + context.msg_sender(), )); new_value } diff --git a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr index d59d4c89e0cb..92e89729e74a 100644 --- a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr @@ -91,6 +91,7 @@ contract Crowdfunding { &mut context, donor_ovpk_m, donor, + donor, )); } // docs:end:donate diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index 9422490654b7..dada8fd336b8 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -181,6 +181,7 @@ contract DocsExample { &mut context, msg_sender_ovpk_m, context.msg_sender(), + context.msg_sender(), )); } // docs:end:initialize-private-mutable @@ -196,6 +197,7 @@ contract DocsExample { &mut context, msg_sender_ovpk_m, context.msg_sender(), + context.msg_sender(), )); } @@ -209,6 +211,7 @@ contract DocsExample { &mut context, msg_sender_ovpk_m, context.msg_sender(), + context.msg_sender(), )); } } @@ -221,6 +224,7 @@ contract DocsExample { &mut context, msg_sender_ovpk_m, context.msg_sender(), + context.msg_sender(), )); } // docs:start:state_vars-NoteGetterOptionsComparatorExampleNoir @@ -238,6 +242,7 @@ contract DocsExample { &mut context, msg_sender_ovpk_m, context.msg_sender(), + context.msg_sender(), )); DocsExample::at(context.this_address()).update_leader(context.msg_sender(), points).enqueue( &mut context, @@ -259,6 +264,7 @@ contract DocsExample { &mut context, msg_sender_ovpk_m, context.msg_sender(), + context.msg_sender(), )); // docs:end:state_vars-PrivateMutableReplace DocsExample::at(context.this_address()).update_leader(context.msg_sender(), points).enqueue( diff --git a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr index 8f2dc055f33a..5a486330c9b5 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr @@ -39,6 +39,7 @@ contract EcdsaKAccount { &mut context, this_ovpk_m, this, + this, )); } diff --git a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr index b8e2e18b08a8..94e86352fda9 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr @@ -37,6 +37,7 @@ contract EcdsaRAccount { &mut context, this_ovpk_m, this, + this, )); } diff --git a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr index b5438144c2ab..4aa3759433a8 100644 --- a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr @@ -32,6 +32,7 @@ contract Escrow { &mut context, msg_sender_ovpk_m, owner, + context.msg_sender(), )); } diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index cdb13bbe4a65..8be4ea123432 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -40,6 +40,7 @@ contract InclusionProofs { &mut context, msg_sender_ovpk_m, owner, + context.msg_sender(), )); } // docs:end:create_note diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr index 717799fc5a00..ab93fc030404 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr @@ -307,6 +307,7 @@ contract NFT { &mut context, from_ovpk_m, to, + from, )); } diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index 5858192c8d8c..52494022a512 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -47,6 +47,7 @@ contract PendingNoteHashes { &mut context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); let options = NoteGetterOptions::with_filter(filter_notes_min_sum, amount); @@ -96,6 +97,7 @@ contract PendingNoteHashes { &mut context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); } @@ -120,6 +122,7 @@ contract PendingNoteHashes { &mut context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); } @@ -136,10 +139,10 @@ contract PendingNoteHashes { // Insert note let emission = owner_balance.insert(&mut note); - emission.emit(encode_and_encrypt_note(&mut context, outgoing_viewer_ovpk_m, owner)); + emission.emit(encode_and_encrypt_note(&mut context, outgoing_viewer_ovpk_m, owner, context.msg_sender())); // Emit note again - emission.emit(encode_and_encrypt_note(&mut context, outgoing_viewer_ovpk_m, owner)); + emission.emit(encode_and_encrypt_note(&mut context, outgoing_viewer_ovpk_m, owner, context.msg_sender())); } // Nested/inner function to get a note and confirm it matches the expected value @@ -359,6 +362,7 @@ contract PendingNoteHashes { &mut context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); // We will emit a note log with an incorrect preimage to ensure the pxe throws @@ -372,6 +376,7 @@ contract PendingNoteHashes { &mut context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); } @@ -392,6 +397,7 @@ contract PendingNoteHashes { context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); } } diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr index 325932f6206a..84379b702a15 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -44,6 +44,7 @@ contract SchnorrAccount { &mut context, this_ovpk_m, this, + this, )); } diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr index b1bfe78f5651..3523cc6e3f7d 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr @@ -36,7 +36,7 @@ contract Spam { for _ in 0..MAX_NOTE_HASHES_PER_CALL { storage.balances.at(caller).add(caller, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, caller_ovpk_m, caller), + encode_and_encrypt_note_unconstrained(&mut context, caller_ovpk_m, caller, caller), ); } diff --git a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr index 418c6a9c281e..b45d67c51265 100644 --- a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr @@ -52,6 +52,7 @@ contract StaticChild { &mut context, msg_sender_ovpk_m, owner, + context.msg_sender(), )); new_value } @@ -70,6 +71,7 @@ contract StaticChild { &mut context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); new_value } diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index f6565b2a80f8..612a1c0bfaef 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -109,6 +109,7 @@ contract Test { &mut context, outgoing_viewer_ovpk_m, owner, + context.msg_sender(), )); } @@ -343,6 +344,7 @@ contract Test { &mut context, msg_sender_ovpk_m, owner, + context.msg_sender(), )); storage_slot += 1; Test::at(context.this_address()) diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index 765d8530ae92..45f9c657544c 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -191,7 +191,7 @@ contract TokenBlacklist { // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.add(to, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, msg_sender_ovpk_m, to), + encode_and_encrypt_note_unconstrained(&mut context, msg_sender_ovpk_m, to, context.msg_sender()), ); } @@ -212,7 +212,7 @@ contract TokenBlacklist { // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from), + encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), ); TokenBlacklist::at(context.this_address())._increase_public_balance(to, amount).enqueue( @@ -241,11 +241,13 @@ contract TokenBlacklist { &mut context, from_ovpk_m, from, + from, )); storage.balances.add(to, amount).emit(encode_and_encrypt_note_unconstrained( &mut context, from_ovpk_m, to, + from, )); } @@ -264,7 +266,7 @@ contract TokenBlacklist { // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from), + encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), ); TokenBlacklist::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index 4707c337acbc..7559e956f7b3 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -310,6 +310,7 @@ contract Token { &mut context, from_ovpk_m, to, + context.msg_sender(), )); } // docs:end:redeem_shield @@ -326,7 +327,7 @@ contract Token { // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(from).sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from), + encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), ); Token::at(context.this_address())._increase_public_balance(to, amount).enqueue(&mut context); } @@ -452,6 +453,7 @@ contract Token { &mut context, from_ovpk_m, from, + from, )); // docs:end:encrypted // docs:end:increase_private_balance @@ -461,6 +463,7 @@ contract Token { &mut context, from_ovpk_m, to, + from, )); } // docs:end:transfer_from @@ -476,7 +479,7 @@ contract Token { // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(from).sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from), + encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), ); Token::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); } @@ -644,6 +647,7 @@ contract Token { &mut context, user_ovpk, user, + user, )); // 4. Now we get the partial payloads