Skip to content
Merged
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
15 changes: 14 additions & 1 deletion docs/docs/misc/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,22 @@ Aztec is in full-speed development. Literally every version breaks compatibility

The type signature for `SharedMutable` changed from `SharedMutable<T, DELAY>` to `SharedMutable<T, INITIAL_DELAY>`. The behavior is the same as before, except the delay can now be changed after deployment by calling `schedule_delay_change`.

### [Aztec.nr] get_public_key oracle replaced with get_ivpk_m

When implementing changes according to a [new key scheme](https://yp-aztec.netlify.app/docs/addresses-and-keys/keys) we had to change oracles.
What used to be called encryption public key is now master incoming viewing public key.

```diff
- use dep::aztec::oracles::get_public_key::get_public_key;
+ use dep::aztec::keys::getters::get_ivpk_m;

- let encryption_pub_key = get_public_key(self.owner);
+ let ivpk_m = get_ivpk_m(context, self.owner);
```

## 0.38.0

### [Aztec.nr] Emmiting encrypted logs
### [Aztec.nr] Emitting encrypted logs

The `emit_encrypted_log` function is now a context method.

Expand Down
7 changes: 4 additions & 3 deletions noir-projects/aztec-nr/address-note/src/address_note.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use dep::aztec::{
keys::getters::get_ivpk_m,
protocol_types::{address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER},
note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption},
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key},
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key},
context::PrivateContext, hash::poseidon2_hash
};

Expand Down Expand Up @@ -40,13 +41,13 @@ impl NoteInterface<ADDRESS_NOTE_LEN> for AddressNote {

// Broadcasts the note as an encrypted log on L1.
fn broadcast(self, context: &mut PrivateContext, slot: Field) {
let encryption_pub_key = get_public_key(self.owner);
let ivpk_m = get_ivpk_m(context, self.owner);
// docs:start:encrypted
context.emit_encrypted_log(
(*context).this_address(),
slot,
Self::get_note_type_id(),
encryption_pub_key,
ivpk_m,
self.serialize_content(),
);
// docs:end:encrypted
Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl PrivateContext {
contract_address: AztecAddress,
storage_slot: Field,
note_type_id: Field,
encryption_pub_key: GrumpkinPoint,
ivpk_m: GrumpkinPoint,
preimage: [Field; N]
) where [Field; N]: LensForEncryptedLog<N, M, L> {
// TODO(1139): perform encryption in the circuit
Expand All @@ -296,7 +296,7 @@ impl PrivateContext {
contract_address,
storage_slot,
note_type_id,
encryption_pub_key,
ivpk_m,
preimage,
counter
);
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/encrypted_logs/body.nr
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod test {

use crate::{
note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption},
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key},
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key},
context::PrivateContext, hash::poseidon2_hash
};

Expand Down
1 change: 0 additions & 1 deletion noir-projects/aztec-nr/aztec/src/oracle.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod get_l1_to_l2_membership_witness;
mod get_nullifier_membership_witness;
mod get_public_data_witness;
mod get_membership_witness;
mod get_public_key;
mod keys;
mod nullifier_key;
mod get_sibling_path;
Expand Down
8 changes: 0 additions & 8 deletions noir-projects/aztec-nr/aztec/src/oracle/get_public_key.nr

This file was deleted.

2 changes: 0 additions & 2 deletions noir-projects/aztec-nr/aztec/src/oracle/keys.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use dep::protocol_types::{address::{AztecAddress, PartialAddress}, grumpkin_point::GrumpkinPoint};

use crate::hash::poseidon2_hash;

#[oracle(getPublicKeysAndPartialAddress)]
fn get_public_keys_and_partial_address_oracle(_address: AztecAddress) -> [Field; 9] {}

Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/oracle/logs.nr
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ unconstrained pub fn emit_encrypted_log<N, M>(
contract_address: AztecAddress,
storage_slot: Field,
note_type_id: Field,
encryption_pub_key: GrumpkinPoint,
ivpk_m: GrumpkinPoint,
preimage: [Field; N],
counter: u32
) -> [Field; M] {
emit_encrypted_log_oracle(
contract_address,
storage_slot,
note_type_id,
encryption_pub_key,
ivpk_m,
preimage,
counter
)
Expand Down
1 change: 0 additions & 1 deletion noir-projects/aztec-nr/value-note/src/utils.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dep::aztec::prelude::{AztecAddress, PrivateContext, PrivateSet, NoteGetterOptions};
use dep::aztec::note::note_getter_options::SortOrder;
use dep::aztec::oracle::get_public_key::get_public_key;
use crate::{filter::filter_notes_min_sum, value_note::{ValueNote, VALUE_NOTE_LEN}};

// Sort the note values (0th field) in descending order.
Expand Down
7 changes: 4 additions & 3 deletions noir-projects/aztec-nr/value-note/src/value_note.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use dep::aztec::{
keys::getters::get_ivpk_m,
protocol_types::{address::AztecAddress, traits::{Deserialize, Serialize}, constants::GENERATOR_INDEX__NOTE_NULLIFIER},
note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption},
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key},
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key},
hash::poseidon2_hash, context::PrivateContext
};

Expand Down Expand Up @@ -43,12 +44,12 @@ impl NoteInterface<VALUE_NOTE_LEN> for ValueNote {

// Broadcasts the note as an encrypted log on L1.
fn broadcast(self, context: &mut PrivateContext, slot: Field) {
let encryption_pub_key = get_public_key(self.owner);
let ivpk_m = get_ivpk_m(context, self.owner);
context.emit_encrypted_log(
(*context).this_address(),
slot,
Self::get_note_type_id(),
encryption_pub_key,
ivpk_m,
self.serialize_content(),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@ mod subscription_note;
mod dapp_payload;

contract AppSubscription {
use dep::std;
use crate::dapp_payload::DAppPayload;

use dep::aztec::prelude::{
use crate::{dapp_payload::DAppPayload, subscription_note::{SubscriptionNote, SUBSCRIPTION_NOTE_LEN}};
use dep::{
aztec::{
prelude::{
AztecAddress, FunctionSelector, PrivateContext, NoteHeader, Map, PrivateMutable, PublicMutable,
SharedImmutable
},
protocol_types::traits::is_empty
},
authwit::{account::AccountActions, auth_witness::get_auth_witness, auth::assert_current_call_valid_authwit},
gas_token::GasToken, token::Token
};

use dep::aztec::protocol_types::traits::is_empty;

use dep::aztec::{context::Context, oracle::get_public_key::get_public_key};
use dep::authwit::{account::AccountActions, auth_witness::get_auth_witness, auth::assert_current_call_valid_authwit};

use crate::subscription_note::{SubscriptionNote, SUBSCRIPTION_NOTE_LEN};

use dep::gas_token::GasToken;
use dep::token::Token;

#[aztec(storage)]
struct Storage {
// The following is only needed in private but we use ShareImmutable here instead of PrivateImmutable because
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use dep::aztec::prelude::{AztecAddress, PrivateContext, NoteHeader, NoteInterface};
use dep::aztec::{
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
keys::getters::get_ivpk_m, protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key}
oracle::{nullifier_key::get_app_nullifier_secret_key}
};

global SUBSCRIPTION_NOTE_LEN: Field = 3;
Expand Down Expand Up @@ -39,12 +39,12 @@ impl NoteInterface<SUBSCRIPTION_NOTE_LEN> for SubscriptionNote {

// Broadcasts the note as an encrypted log on L1.
fn broadcast(self, context: &mut PrivateContext, slot: Field) {
let encryption_pub_key = get_public_key(self.owner);
let ivpk_m = get_ivpk_m(context, self.owner);
context.emit_encrypted_log(
(*context).this_address(),
slot,
Self::get_note_type_id(),
encryption_pub_key,
ivpk_m,
self.serialize_content(),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use dep::aztec::prelude::{AztecAddress, NoteInterface, NoteHeader, PrivateContext};
use dep::aztec::{
note::{utils::compute_note_hash_for_consumption},
oracle::{nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key},
hash::poseidon2_hash, protocol_types::{traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER}
keys::getters::get_ivpk_m, note::{utils::compute_note_hash_for_consumption},
oracle::nullifier_key::get_app_nullifier_secret_key, hash::poseidon2_hash,
protocol_types::{traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER}
};

// Shows how to create a custom note
Expand Down Expand Up @@ -47,12 +47,12 @@ impl NoteInterface<CARD_NOTE_LEN> for CardNote {

// Broadcasts the note as an encrypted log on L1.
fn broadcast(self, context: &mut PrivateContext, slot: Field) {
let encryption_pub_key = get_public_key(self.owner);
let ivpk_m = get_ivpk_m(context, self.owner);
context.emit_encrypted_log(
(*context).this_address(),
slot,
Self::get_note_type_id(),
encryption_pub_key,
ivpk_m,
self.serialize_content(),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, NoteInterface, NoteGetterOptions, PrivateContext};

use dep::aztec::{
note::utils::compute_note_hash_for_consumption,
oracle::{nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key},
hash::poseidon2_hash, protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER
keys::getters::get_ivpk_m, note::utils::compute_note_hash_for_consumption,
oracle::nullifier_key::get_app_nullifier_secret_key, hash::poseidon2_hash,
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER
};

global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5;
Expand Down Expand Up @@ -85,12 +85,12 @@ impl NoteInterface<ECDSA_PUBLIC_KEY_NOTE_LEN> for EcdsaPublicKeyNote {

// Broadcasts the note as an encrypted log on L1.
fn broadcast(self, context: &mut PrivateContext, slot: Field) {
let encryption_pub_key = get_public_key(self.owner);
let ivpk_m = get_ivpk_m(context, self.owner);
context.emit_encrypted_log(
(*context).this_address(),
slot,
Self::get_note_type_id(),
encryption_pub_key,
ivpk_m,
self.serialize_content(),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contract EcdsaAccount {
use dep::aztec::protocol_types::abis::call_context::CallContext;
use dep::std;

use dep::aztec::{context::{PublicContext, Context}, oracle::get_public_key::get_public_key};
use dep::aztec::context::Context;
use dep::authwit::{
entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions,
auth_witness::get_auth_witness
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
contract Escrow {
use dep::aztec::prelude::{AztecAddress, EthAddress, FunctionSelector, NoteHeader, PrivateContext, PrivateImmutable};

use dep::aztec::{context::{PublicContext, Context}, oracle::get_public_key::get_public_key};
use dep::aztec::context::{PublicContext, Context};

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ contract SchnorrAccount {

use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, PrivateContext, PrivateImmutable};
use dep::aztec::state_vars::{Map, PublicMutable};
use dep::aztec::{context::Context, oracle::get_public_key::get_public_key};
use dep::aztec::context::Context;
use dep::authwit::{
entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions,
auth_witness::get_auth_witness
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::aztec::prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext};
use dep::aztec::{
note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key},
keys::getters::get_ivpk_m, note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{nullifier_key::get_app_nullifier_secret_key},
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER
};

Expand Down Expand Up @@ -39,12 +39,12 @@ impl NoteInterface<PUBLIC_KEY_NOTE_LEN> for PublicKeyNote {

// Broadcasts the note as an encrypted log on L1.
fn broadcast(self, context: &mut PrivateContext, slot: Field) {
let encryption_pub_key = get_public_key(self.owner);
let ivpk_m = get_ivpk_m(context, self.owner);
context.emit_encrypted_log(
(*context).this_address(),
slot,
Self::get_note_type_id(),
encryption_pub_key,
ivpk_m,
self.serialize_content(),
);
}
Expand Down
13 changes: 5 additions & 8 deletions noir-projects/noir-contracts/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ contract Test {
use dep::aztec::state_vars::{shared_mutable::SharedMutablePrivateGetter, map::derive_storage_slot_in_map};

use dep::aztec::{
keys::getters::get_npk_m,
keys::getters::{get_npk_m, get_ivpk_m},
context::{Context, inputs::private_context_inputs::PrivateContextInputs},
hash::{pedersen_hash, poseidon2_hash, compute_secret_hash, ArgsHasher},
hash::{pedersen_hash, compute_secret_hash, ArgsHasher},
note::{
lifecycle::{create_note, destroy_note}, note_getter::{get_notes, view_notes},
note_getter_options::NoteStatus
},
deploy::deploy_contract as aztec_deploy_contract,
oracle::{
encryption::aes128_encrypt, get_public_key::get_public_key as get_public_key_oracle,
unsafe_rand::unsafe_rand
}
oracle::{encryption::aes128_encrypt, unsafe_rand::unsafe_rand}
};
use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash};
use dep::value_note::value_note::ValueNote;
Expand All @@ -53,8 +50,8 @@ contract Test {
}

#[aztec(private)]
fn get_public_key(address: AztecAddress) -> [Field; 2] {
let pub_key = get_public_key_oracle(address);
fn get_master_incoming_viewing_public_key(address: AztecAddress) -> [Field; 2] {
let pub_key = get_ivpk_m(&mut context, address);

[pub_key.x, pub_key.y]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use dep::aztec::{
prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext},
keys::getters::get_ivpk_m, prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext},
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key, get_public_key::get_public_key}
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key}
};

trait OwnedNote {
Expand Down Expand Up @@ -52,12 +52,12 @@ impl NoteInterface<TOKEN_NOTE_LEN> for TokenNote {
fn broadcast(self, context: &mut PrivateContext, slot: Field) {
// We only bother inserting the note if non-empty to save funds on gas.
if !(self.amount == U128::from_integer(0)) {
let encryption_pub_key = get_public_key(self.owner);
let ivpk_m = get_ivpk_m(context, self.owner);
context.emit_encrypted_log(
(*context).this_address(),
slot,
Self::get_note_type_id(),
encryption_pub_key,
ivpk_m,
self.serialize_content(),
);
}
Expand Down
Loading