Skip to content

Commit 2ff645d

Browse files
Merge 68cf94b into de304d8
2 parents de304d8 + 68cf94b commit 2ff645d

File tree

62 files changed

+2213
-1029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2213
-1029
lines changed

boxes/boxes/react/src/contracts/src/main.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ contract BoxReact {
66
protocol_types::public_keys::OvpkM,
77
keys::getters::get_public_keys,
88
prelude::{AztecAddress, PrivateMutable, Map, NoteInterface, NoteHeader, Point},
9-
encrypted_logs::encrypted_note_emission::encode_and_encrypt_note,
9+
encrypted_logs::log_assembly_strategies::default_aes128::note::encode_and_encrypt_note,
1010
macros::{storage::storage, functions::{private, public, initializer}}
1111
};
1212
use dep::value_note::value_note::ValueNote;

boxes/boxes/vanilla/src/contracts/src/main.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ contract Vanilla {
66
protocol_types::public_keys::OvpkM,
77
keys::getters::get_public_keys,
88
prelude::{AztecAddress, PrivateMutable, Map, NoteInterface, NoteHeader, Point},
9-
encrypted_logs::encrypted_note_emission::encode_and_encrypt_note,
9+
encrypted_logs::log_assembly_strategies::default_aes128::note::encode_and_encrypt_note,
1010
macros::{storage::storage, functions::{private, public, initializer}}
1111
};
1212
use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN};

boxes/boxes/vite/src/contracts/src/main.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use dep::aztec::macros::aztec;
33
#[aztec]
44
contract BoxReact {
55
use dep::aztec::{
6-
encrypted_logs::encrypted_note_emission::encode_and_encrypt_note,
6+
encrypted_logs::log_assembly_strategies::default_aes128::note::encode_and_encrypt_note,
77
macros::{functions::{initializer, private}, storage::storage},
88
prelude::{AztecAddress, Map, PrivateMutable},
99
};

cspell.json

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"dockerized",
9090
"doesnt",
9191
"dont",
92+
"ecdh",
9293
"elif",
9394
"enrs",
9495
"entrypoints",
@@ -281,6 +282,7 @@
281282
"unexcluded",
282283
"unfinalised",
283284
"unnullify",
285+
"unpadded",
284286
"unprefixed",
285287
"unshift",
286288
"unshifted",

docs/docs/migration_notes.md

+17
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ impl Packable<U128_PACKED_LEN> for U128 {
3131
}
3232
```
3333

34+
### Logs for notes, partial notes, and events have been refactored.
35+
36+
We're preparing to make log assembly more customisable. These paths have changed.
37+
```diff
38+
- use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note,
39+
+ use dep::aztec::encrypted_logs::log_assembly_strategies::default_aes128::note::encode_and_encrypt_note,
40+
```
41+
42+
And similar paths for `encode_and_encrypt_note_unconstrained`, and for events and partial notes.
43+
44+
The way in which logs are assembled in this "default_aes128" strategy is has also changed. I repeat: **Encrypted log layouts have changed**. The corresponding typescript for note discovery has also been changed, but if you've rolled your own functions for parsing and decrypting logs, those will be broken by this change.
45+
46+
### `NoteInferface` and `EventInterface` no-longer have a `to_be_bytes` method.
47+
48+
You can remove this method from any custom notes or events that you've implemented.
49+
50+
3451
## 0.72.0
3552
### Some functions in `aztec.js` and `@aztec/accounts` are now async
3653
In our efforts to make libraries more browser-friendly and providing with more bundling options for `bb.js` (like a non top-level-await version), some functions are being made async, in particular those that access our cryptographic functions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
use std::hash::{from_field_unsafe as fr_to_fq_unsafe, sha256};
2+
3+
use dep::protocol_types::{
4+
constants::{GENERATOR_INDEX__SYMMETRIC_KEY, GENERATOR_INDEX__SYMMETRIC_KEY_2},
5+
hash::poseidon2_hash_with_separator,
6+
point::Point,
7+
};
8+
9+
use crate::utils::point::point_to_bytes;
10+
11+
fn extract_close_to_uniformly_random_256_bits_from_ecdh_shared_secret_using_poseidon2(
12+
shared_secret: Point,
13+
) -> [u8; 32] {
14+
let rand1: Field = poseidon2_hash_with_separator(
15+
[shared_secret.x, shared_secret.y],
16+
GENERATOR_INDEX__SYMMETRIC_KEY,
17+
);
18+
let rand2: Field = poseidon2_hash_with_separator(
19+
[shared_secret.x, shared_secret.y],
20+
GENERATOR_INDEX__SYMMETRIC_KEY_2,
21+
);
22+
let rand1_bytes: [u8; 16] = rand1.to_le_bytes();
23+
let rand2_bytes: [u8; 16] = rand2.to_le_bytes();
24+
let mut bytes: [u8; 32] = [0; 32];
25+
for i in 0..16 {
26+
bytes[i] = rand1_bytes[i];
27+
bytes[i + 1] = rand2_bytes[i];
28+
}
29+
bytes
30+
}
31+
32+
fn extract_close_to_uniformly_random_256_bits_from_ecdh_shared_secret_using_sha256(
33+
shared_secret: Point,
34+
) -> [u8; 32] {
35+
let shared_secret_bytes: [u8; 32] = point_to_bytes(shared_secret);
36+
37+
let mut shared_secret_bytes_with_separator: [u8; 33] = std::mem::zeroed();
38+
for i in 0..shared_secret_bytes.len() {
39+
shared_secret_bytes_with_separator[i] = shared_secret_bytes[i];
40+
}
41+
shared_secret_bytes_with_separator[32] = GENERATOR_INDEX__SYMMETRIC_KEY;
42+
43+
sha256(shared_secret_bytes_with_separator)
44+
}
45+
46+
fn derive_aes_symmetric_key_and_iv_from_ecdh_shared_secret(
47+
shared_secret: Point,
48+
randomness_extraction_fn: fn(Point) -> [u8; 32],
49+
) -> ([u8; 16], [u8; 16]) {
50+
let random_256_bits = randomness_extraction_fn(shared_secret);
51+
let mut sym_key = [0; 16];
52+
let mut iv = [0; 16];
53+
for i in 0..16 {
54+
sym_key[i] = random_256_bits[i];
55+
iv[i] = random_256_bits[i + 16];
56+
}
57+
(sym_key, iv)
58+
}
59+
60+
pub fn derive_aes_symmetric_key_and_iv_from_ecdh_shared_secret_using_sha256(
61+
shared_secret: Point,
62+
) -> ([u8; 16], [u8; 16]) {
63+
derive_aes_symmetric_key_and_iv_from_ecdh_shared_secret(
64+
shared_secret,
65+
extract_close_to_uniformly_random_256_bits_from_ecdh_shared_secret_using_sha256,
66+
)
67+
}
68+
69+
pub fn derive_aes_symmetric_key_and_iv_from_ecdh_shared_secret_using_poseidon2(
70+
shared_secret: Point,
71+
) -> ([u8; 16], [u8; 16]) {
72+
derive_aes_symmetric_key_and_iv_from_ecdh_shared_secret(
73+
shared_secret,
74+
extract_close_to_uniformly_random_256_bits_from_ecdh_shared_secret_using_poseidon2,
75+
)
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod aes128;

noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr

-64
This file was deleted.

noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr

-89
This file was deleted.

noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr

-66
This file was deleted.

0 commit comments

Comments
 (0)