From 8a774eb1a0d9d29f6a4ccfe6857cf05c7a313ef0 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Tue, 19 Mar 2024 15:29:35 +0000 Subject: [PATCH 1/3] add notes --- docs/docs/misc/migration_notes.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index a82148537c0..ba95779bd06 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -6,9 +6,29 @@ keywords: [sandbox, cli, aztec, notes, migration, updating, upgrading] Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. -## 0.28.0 +## 0.30.0 +### [AztecJS] Simplify authwit syntax +```diff +- const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); +- await wallets[0].setPublicAuth(messageHash, true).send().wait(); ++ await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true).send().wait(); +``` + +```diff +const action = asset + .withWallet(wallets[1]) + .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce); +-const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); +-const witness = await wallets[0].createAuthWitness(messageHash); ++const witness = await wallets[0].createAuthWit({ caller: accounts[1].address, action }); +await wallets[1].addAuthWitness(witness); +``` + +Also note some of the naming changes: +`setPublicAuth` -> `setPublicAuthWit` +`createAuthWitness` -> `createAuthWit` -### Automatic NoteInterface implementation and selector changes +### [Aztec.nr] Automatic NoteInterface implementation and selector changes Implementing a note required a fair amount of boilerplate code, which has been substituted by the `#[aztec(note)]` attribute. From 8f66fe13f9df2e369d3d8668c9796e2eccea7400 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Tue, 19 Mar 2024 15:39:50 +0000 Subject: [PATCH 2/3] add diff --- docs/docs/misc/migration_notes.md | 104 +++++++++--------------------- 1 file changed, 29 insertions(+), 75 deletions(-) diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index ba95779bd06..984603024fa 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -34,7 +34,8 @@ Implementing a note required a fair amount of boilerplate code, which has been s Before: -```rust +```diff ++ #[aztec(note)] struct AddressNote { address: AztecAddress, owner: AztecAddress, @@ -43,23 +44,23 @@ struct AddressNote { } impl NoteInterface for AddressNote { - fn serialize_content(self) -> [Field; ADDRESS_NOTE_LEN]{ - [self.address.to_field(), self.owner.to_field(), self.randomness] - } - - fn deserialize_content(serialized_note: [Field; ADDRESS_NOTE_LEN]) -> Self { - AddressNote { - address: AztecAddress::from_field(serialized_note[0]), - owner: AztecAddress::from_field(serialized_note[1]), - randomness: serialized_note[2], - header: NoteHeader::empty(), - } - } - - fn compute_note_content_hash(self) -> Field { - pedersen_hash(self.serialize_content(), 0) - } - +- fn serialize_content(self) -> [Field; ADDRESS_NOTE_LEN]{ +- [self.address.to_field(), self.owner.to_field(), self.randomness] +- } +- +- fn deserialize_content(serialized_note: [Field; ADDRESS_NOTE_LEN]) -> Self { +- AddressNote { +- address: AztecAddress::from_field(serialized_note[0]), +- owner: AztecAddress::from_field(serialized_note[1]), +- randomness: serialized_note[2], +- header: NoteHeader::empty(), +- } +- } +- +- fn compute_note_content_hash(self) -> Field { +- pedersen_hash(self.serialize_content(), 0) +- } +- fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let note_hash_for_nullify = compute_note_hash_for_consumption(self); let secret = context.request_nullifier_secret_key(self.owner); @@ -80,13 +81,13 @@ impl NoteInterface for AddressNote { ],0) } - fn set_header(&mut self, header: NoteHeader) { - self.header = header; - } - - fn get_header(note: Self) -> NoteHeader { - note.header - } +- fn set_header(&mut self, header: NoteHeader) { +- self.header = header; +- } +- +- fn get_header(note: Self) -> NoteHeader { +- note.header +- } fn broadcast(self, context: &mut PrivateContext, slot: Field) { let encryption_pub_key = get_public_key(self.owner); @@ -100,56 +101,9 @@ impl NoteInterface for AddressNote { ); } - fn get_note_type_id() -> Field { - 6510010011410111511578111116101 - } -} - -``` - -After: - -```rust -#[aztec(note)] -struct AddressNote { - address: AztecAddress, - owner: AztecAddress, - randomness: Field, -} - -impl NoteInterface for AddressNote { - fn compute_nullifier(self, context: &mut PrivateContext) -> Field { - let note_hash_for_nullify = compute_note_hash_for_consumption(self); - let secret = context.request_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - note_hash_for_nullify, - secret.low, - secret.high, - ],0) - } - - fn compute_nullifier_without_context(self) -> Field { - let note_hash_for_nullify = compute_note_hash_for_consumption(self); - let secret = get_nullifier_secret_key(self.owner); - pedersen_hash([ - note_hash_for_nullify, - secret.low, - secret.high, - ],0) - } - - fn broadcast(self, context: &mut PrivateContext, slot: Field) { - let encryption_pub_key = get_public_key(self.owner); - emit_encrypted_log( - context, - (*context).this_address(), - slot, - Self::get_note_type_id(), - encryption_pub_key, - self.serialize_content(), - ); - } +- fn get_note_type_id() -> Field { +- 6510010011410111511578111116101 +- } } ``` From d742f2462a54429e9614950976768faf05e9f048 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Tue, 19 Mar 2024 16:07:04 +0000 Subject: [PATCH 3/3] remove before --- docs/docs/misc/migration_notes.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index 984603024fa..1e1af122f26 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -32,8 +32,6 @@ Also note some of the naming changes: Implementing a note required a fair amount of boilerplate code, which has been substituted by the `#[aztec(note)]` attribute. -Before: - ```diff + #[aztec(note)] struct AddressNote {