Skip to content

Commit 0a5e878

Browse files
committed
fmt
1 parent 3030cc8 commit 0a5e878

File tree

90 files changed

+1095
-645
lines changed

Some content is hidden

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

90 files changed

+1095
-645
lines changed

yarn-project/aztec-nr/authwit/src/auth.nr

+22-7
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ pub fn assert_valid_authwit(context: &mut PrivateContext, on_behalf_of: AztecAdd
3535
// Assert that `on_behalf_of` have authorized the current call with a valid authentication witness
3636
pub fn assert_current_call_valid_authwit(context: &mut PrivateContext, on_behalf_of: AztecAddress) {
3737
// message_hash = H(caller, contract_this, selector, args_hash)
38-
let message_hash = pedersen_hash([context.msg_sender().to_field(), context.this_address().to_field(), context.selector().to_field(), context.args_hash],
39-
GENERATOR_INDEX__SIGNATURE_PAYLOAD);
38+
let message_hash = pedersen_hash(
39+
[
40+
context.msg_sender().to_field(), context.this_address().to_field(), context.selector().to_field(), context.args_hash
41+
],
42+
GENERATOR_INDEX__SIGNATURE_PAYLOAD
43+
);
4044
assert_valid_authwit(context, on_behalf_of, message_hash);
4145
}
4246
// docs:end:assert_current_call_valid_authwit
@@ -55,17 +59,28 @@ pub fn assert_valid_authwit_public(context: &mut PublicContext, on_behalf_of: Az
5559
// Assert that `on_behalf_of` have authorized the current call in a public context
5660
pub fn assert_current_call_valid_authwit_public(context: &mut PublicContext, on_behalf_of: AztecAddress) {
5761
// message_hash = H(caller, contract_this, selector, args_hash)
58-
let message_hash = pedersen_hash([context.msg_sender().to_field(), context.this_address().to_field(), context.selector().to_field(), context.args_hash],
59-
GENERATOR_INDEX__SIGNATURE_PAYLOAD);
62+
let message_hash = pedersen_hash(
63+
[
64+
context.msg_sender().to_field(), context.this_address().to_field(), context.selector().to_field(), context.args_hash
65+
],
66+
GENERATOR_INDEX__SIGNATURE_PAYLOAD
67+
);
6068
assert_valid_authwit_public(context, on_behalf_of, message_hash);
6169
}
6270
// docs:end:assert_current_call_valid_authwit_public
6371

6472
// docs:start:compute_authwit_message_hash
6573
// Compute the message hash to be used by an authentication witness
66-
pub fn compute_authwit_message_hash<N>(caller: AztecAddress, target: AztecAddress, selector: FunctionSelector, args: [Field; N]) -> Field {
74+
pub fn compute_authwit_message_hash<N>(
75+
caller: AztecAddress,
76+
target: AztecAddress,
77+
selector: FunctionSelector,
78+
args: [Field; N]
79+
) -> Field {
6780
let args_hash = hash_args(args);
68-
pedersen_hash([caller.to_field(), target.to_field(), selector.to_field(), args_hash],
69-
GENERATOR_INDEX__SIGNATURE_PAYLOAD)
81+
pedersen_hash(
82+
[caller.to_field(), target.to_field(), selector.to_field(), args_hash],
83+
GENERATOR_INDEX__SIGNATURE_PAYLOAD
84+
)
7085
}
7186
// docs:end:compute_authwit_message_hash

yarn-project/aztec-nr/aztec/src/history.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ mod note_inclusion;
33
mod note_validity;
44
mod nullifier_inclusion;
55
mod nullifier_non_inclusion;
6-
mod public_value_inclusion;
6+
mod public_value_inclusion;

yarn-project/aztec-nr/aztec/src/history/note_inclusion.nr

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ pub fn prove_note_commitment_inclusion(
2323

2424
// 3) Prove that the commitment is in the note hash tree
2525
assert(
26-
block_header.note_hash_tree_root == compute_merkle_root(note_commitment, witness.index, witness.path),
27-
"Proving note inclusion failed"
26+
block_header.note_hash_tree_root
27+
== compute_merkle_root(note_commitment, witness.index, witness.path), "Proving note inclusion failed"
2828
);
29-
3029
// --> Now we have traversed the trees all the way up to archive root.
3130
}
3231

@@ -39,4 +38,4 @@ pub fn prove_note_inclusion<Note, N>(
3938
let note_commitment = compute_unique_siloed_note_hash(note_interface, note_with_header);
4039

4140
prove_note_commitment_inclusion(note_commitment, block_number, context);
42-
}
41+
}

yarn-project/aztec-nr/aztec/src/history/note_validity.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ pub fn prove_note_validity<Note, N>(
1616
) {
1717
prove_note_inclusion(note_interface, note_with_header, block_number, context);
1818
prove_note_not_nullified(note_interface, note_with_header, block_number, context);
19-
}
19+
}

yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr

+13-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ pub fn l1_to_l2_message_getter_len() -> Field {
1616
L1_TO_L2_MESSAGE_LENGTH + 1 + L1_TO_L2_MSG_TREE_HEIGHT + 1
1717
}
1818

19-
pub fn make_l1_to_l2_message_getter_data<N>(fields: [Field; N], start: Field, secret: Field) -> L1ToL2MessageGetterData {
19+
pub fn make_l1_to_l2_message_getter_data<N>(
20+
fields: [Field; N],
21+
start: Field,
22+
secret: Field
23+
) -> L1ToL2MessageGetterData {
2024
L1ToL2MessageGetterData {
21-
message: L1ToL2Message::deserialize(arr_copy_slice(fields, [0; L1_TO_L2_MESSAGE_LENGTH], start),
25+
message: L1ToL2Message::deserialize(
26+
arr_copy_slice(fields, [0; L1_TO_L2_MESSAGE_LENGTH], start),
2227
secret,
23-
fields[start + L1_TO_L2_MESSAGE_LENGTH]),
28+
fields[start + L1_TO_L2_MESSAGE_LENGTH]
29+
),
2430
leaf_index: fields[start + L1_TO_L2_MESSAGE_LENGTH],
25-
sibling_path: arr_copy_slice(fields,
31+
sibling_path: arr_copy_slice(
32+
fields,
2633
[0; L1_TO_L2_MSG_TREE_HEIGHT],
27-
L1_TO_L2_MESSAGE_LENGTH + 1),
34+
L1_TO_L2_MESSAGE_LENGTH + 1
35+
),
2836
root: fields[start + L1_TO_L2_MESSAGE_LENGTH + L1_TO_L2_MSG_TREE_HEIGHT + 1]
2937
}
3038
}

yarn-project/aztec-nr/aztec/src/note/lifecycle.nr

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ pub fn create_note_hash_from_public<Note, N>(
5353
context.push_new_note_hash(inner_note_hash);
5454
}
5555

56-
pub fn destroy_note<Note, N>(context: &mut PrivateContext, note: Note, note_interface: NoteInterface<Note, N>) {
56+
pub fn destroy_note<Note, N>(
57+
context: &mut PrivateContext,
58+
note: Note,
59+
note_interface: NoteInterface<Note, N>
60+
) {
5761
let mut nullifier = 0;
5862
let mut nullified_commitment: Field = EMPTY_NULLIFIED_COMMITMENT;
5963
let compute_nullifier = note_interface.compute_nullifier;

yarn-project/aztec-nr/aztec/src/note/note_getter.nr

+37-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ use crate::note::{
1616
use crate::oracle;
1717
use crate::types::vec::BoundedVec;
1818

19-
fn check_note_header<Note, N>(context: PrivateContext, storage_slot: Field, note_interface: NoteInterface<Note, N>, note: Note) {
19+
fn check_note_header<Note, N>(
20+
context: PrivateContext,
21+
storage_slot: Field,
22+
note_interface: NoteInterface<Note, N>,
23+
note: Note
24+
) {
2025
let get_header = note_interface.get_header;
2126
let header = get_header(note);
2227
let contract_address = context.this_address();
@@ -31,7 +36,11 @@ fn check_note_fields<N>(fields: [Field; N], selects: BoundedVec<Option<Select>,
3136
}
3237
}
3338

34-
fn check_notes_order<N>(fields_0: [Field; N], fields_1: [Field; N], sorts: BoundedVec<Option<Sort>, N>) {
39+
fn check_notes_order<N>(
40+
fields_0: [Field; N],
41+
fields_1: [Field; N],
42+
sorts: BoundedVec<Option<Sort>, N>
43+
) {
3544
for i in 0..sorts.len {
3645
let sort = sorts.get_unchecked(i).unwrap_unchecked();
3746
let eq = fields_0[sort.field_index] == fields_1[sort.field_index];
@@ -44,7 +53,11 @@ fn check_notes_order<N>(fields_0: [Field; N], fields_1: [Field; N], sorts: Bound
4453
}
4554
}
4655

47-
pub fn get_note<Note, N>(context: &mut PrivateContext, storage_slot: Field, note_interface: NoteInterface<Note, N>) -> Note {
56+
pub fn get_note<Note, N>(
57+
context: &mut PrivateContext,
58+
storage_slot: Field,
59+
note_interface: NoteInterface<Note, N>
60+
) -> Note {
4861
let note = get_note_internal(storage_slot, note_interface);
4962

5063
check_note_header(*context, storage_slot, note_interface, note);
@@ -94,7 +107,8 @@ pub fn get_notes<Note, N, FILTER_ARGS>(
94107
unconstrained fn get_note_internal<Note, N>(storage_slot: Field, note_interface: NoteInterface<Note, N>) -> Note {
95108
let placeholder_note = [Option::none()];
96109
let placeholder_fields = [0; GET_NOTE_ORACLE_RETURN_LENGTH];
97-
oracle::notes::get_notes(storage_slot,
110+
oracle::notes::get_notes(
111+
storage_slot,
98112
note_interface,
99113
0,
100114
[],
@@ -104,7 +118,8 @@ unconstrained fn get_note_internal<Note, N>(storage_slot: Field, note_interface:
104118
1, // limit
105119
0, // offset
106120
placeholder_note,
107-
placeholder_fields)[0].unwrap() // Notice: we don't allow dummies to be returned from get_note (singular).
121+
placeholder_fields
122+
)[0].unwrap() // Notice: we don't allow dummies to be returned from get_note (singular).
108123
}
109124

110125
unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
@@ -115,7 +130,8 @@ unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
115130
let (num_selects, select_by, select_values, sort_by, sort_order) = flatten_options(options.selects, options.sorts);
116131
let placeholder_opt_notes = [Option::none(); MAX_READ_REQUESTS_PER_CALL];
117132
let placeholder_fields = [0; GET_NOTES_ORACLE_RETURN_LENGTH];
118-
let opt_notes = oracle::notes::get_notes(storage_slot,
133+
let opt_notes = oracle::notes::get_notes(
134+
storage_slot,
119135
note_interface,
120136
num_selects,
121137
select_by,
@@ -125,18 +141,24 @@ unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
125141
options.limit,
126142
options.offset,
127143
placeholder_opt_notes,
128-
placeholder_fields);
144+
placeholder_fields
145+
);
129146

130147
let filter = options.filter;
131148
let filter_args = options.filter_args;
132149
filter(opt_notes, filter_args)
133150
}
134151

135-
unconstrained pub fn view_notes<Note, N>(storage_slot: Field, note_interface: NoteInterface<Note, N>, options: NoteViewerOptions<Note, N>) -> [Option<Note>; MAX_NOTES_PER_PAGE] {
152+
unconstrained pub fn view_notes<Note, N>(
153+
storage_slot: Field,
154+
note_interface: NoteInterface<Note, N>,
155+
options: NoteViewerOptions<Note, N>
156+
) -> [Option<Note>; MAX_NOTES_PER_PAGE] {
136157
let (num_selects, select_by, select_values, sort_by, sort_order) = flatten_options(options.selects, options.sorts);
137158
let placeholder_opt_notes = [Option::none(); MAX_NOTES_PER_PAGE];
138159
let placeholder_fields = [0; VIEW_NOTE_ORACLE_RETURN_LENGTH];
139-
oracle::notes::get_notes(storage_slot,
160+
oracle::notes::get_notes(
161+
storage_slot,
140162
note_interface,
141163
num_selects,
142164
select_by,
@@ -146,10 +168,14 @@ unconstrained pub fn view_notes<Note, N>(storage_slot: Field, note_interface: No
146168
options.limit,
147169
options.offset,
148170
placeholder_opt_notes,
149-
placeholder_fields)
171+
placeholder_fields
172+
)
150173
}
151174

152-
unconstrained fn flatten_options<Note, N>(selects: BoundedVec<Option<Select>, N>, sorts: BoundedVec<Option<Sort>, N>) -> (u8, [u8; N], [Field; N], [u8; N], [u2; N]) {
175+
unconstrained fn flatten_options<Note, N>(
176+
selects: BoundedVec<Option<Select>, N>,
177+
sorts: BoundedVec<Option<Sort>, N>
178+
) -> (u8, [u8; N], [Field; N], [u8; N], [u2; N]) {
153179
let mut num_selects = 0;
154180
let mut select_by = [0; N];
155181
let mut select_values = [0; N];

yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ impl Sort {
3434
}
3535
}
3636

37-
fn return_all_notes<Note, N>(notes: [Option<Note>; MAX_READ_REQUESTS_PER_CALL], _p: Field) -> [Option<Note>; MAX_READ_REQUESTS_PER_CALL] {
37+
fn return_all_notes<Note, N>(
38+
notes: [Option<Note>; MAX_READ_REQUESTS_PER_CALL],
39+
_p: Field
40+
) -> [Option<Note>; MAX_READ_REQUESTS_PER_CALL] {
3841
notes
3942
}
4043

yarn-project/aztec-nr/aztec/src/note/utils.nr

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ pub fn compute_note_hash_for_read_or_nullify<Note, N>(note_interface: NoteInterf
7070
}
7171
}
7272

73-
pub fn compute_note_hash_and_nullifier<Note, N, S>(note_interface: NoteInterface<Note, N>, note_header: NoteHeader, serialized_note: [Field; S]) -> [Field; 4] {
73+
pub fn compute_note_hash_and_nullifier<Note, N, S>(
74+
note_interface: NoteInterface<Note, N>,
75+
note_header: NoteHeader,
76+
serialized_note: [Field; S]
77+
) -> [Field; 4] {
7478
let deserialize = note_interface.deserialize;
7579
let set_header = note_interface.set_header;
7680
let mut note = deserialize(arr_copy_slice(serialized_note, [0; N], 0));

yarn-project/aztec-nr/aztec/src/oracle/call_private_function.nr

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ use dep::protocol_types::{
55
};
66

77
#[oracle(callPrivateFunction)]
8-
fn call_private_function_oracle(_contract_address: AztecAddress, _function_selector: FunctionSelector, _args_hash: Field) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {}
8+
fn call_private_function_oracle(
9+
_contract_address: AztecAddress,
10+
_function_selector: FunctionSelector,
11+
_args_hash: Field
12+
) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {}
913

10-
unconstrained pub fn call_private_function_internal(contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {
14+
unconstrained pub fn call_private_function_internal(
15+
contract_address: AztecAddress,
16+
function_selector: FunctionSelector,
17+
args_hash: Field
18+
) -> [Field; CALL_PRIVATE_FUNCTION_RETURN_SIZE] {
1119
call_private_function_oracle(contract_address, function_selector, args_hash)
1220
}

yarn-project/aztec-nr/aztec/src/oracle/debug_log.nr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ fn debug_log_format_oracle<T, N>(_msg: T, _args: [Field; N], _num_args: Field) -
88
#[oracle(debugLog)]
99
fn debug_log_field_oracle(_field: Field) -> Field {}
1010
#[oracle(debugLog)]
11-
fn debug_log_array_oracle<T, N>(_arbitrary_array: [T;N]) -> Field {}
11+
fn debug_log_array_oracle<T, N>(_arbitrary_array: [T; N]) -> Field {}
1212
#[oracle(debugLogWithPrefix)]
13-
fn debug_log_array_with_prefix_oracle<S, T, N>(_prefix: S, _arbitrary_array: [T;N]) -> Field {}
13+
fn debug_log_array_with_prefix_oracle<S, T, N>(_prefix: S, _arbitrary_array: [T; N]) -> Field {}
1414

1515
/// NOTE: call this with a str<N> msg of length > 1
1616
/// Example:

yarn-project/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ use dep::protocol_types::{
1111
global ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE: Field = 13;
1212

1313
#[oracle(enqueuePublicFunctionCall)]
14-
fn enqueue_public_function_call_oracle(_contract_address: AztecAddress, _function_selector: FunctionSelector, _args_hash: Field) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {}
14+
fn enqueue_public_function_call_oracle(
15+
_contract_address: AztecAddress,
16+
_function_selector: FunctionSelector,
17+
_args_hash: Field
18+
) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {}
1519

16-
unconstrained pub fn enqueue_public_function_call_internal(contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {
20+
unconstrained pub fn enqueue_public_function_call_internal(
21+
contract_address: AztecAddress,
22+
function_selector: FunctionSelector,
23+
args_hash: Field
24+
) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {
1725
enqueue_public_function_call_oracle(contract_address, function_selector, args_hash)
1826
}

yarn-project/aztec-nr/aztec/src/oracle/get_block_header.nr

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub fn get_block_header(block_number: u32, context: PrivateContext) -> BlockHead
3232

3333
// 2) Check that the block header block number is more than or equal to the block number we want to prove against
3434
// We could not perform the proof otherwise because the archive root from the header would not "contain" the block we want to prove against
35-
assert(block_header_block_number >= block_number, "Block header block number is smaller than the block number we want to prove against");
35+
assert(
36+
block_header_block_number >= block_number, "Block header block number is smaller than the block number we want to prove against"
37+
);
3638

3739
// 3) Get block header of a given block from oracle
3840
let block_header = get_block_header_internal(block_number);
@@ -44,7 +46,10 @@ pub fn get_block_header(block_number: u32, context: PrivateContext) -> BlockHead
4446
let witness = get_archive_membership_witness(block_header_block_number, block_hash);
4547

4648
// 6) Check that the block is in the archive (i.e. the witness is valid)
47-
assert(context.block_header.archive_root == compute_merkle_root(block_hash, witness.index, witness.path), "Proving membership of a block in archive failed");
49+
assert(
50+
context.block_header.archive_root
51+
== compute_merkle_root(block_hash, witness.index, witness.path), "Proving membership of a block in archive failed"
52+
);
4853

4954
// 7) Return the block header
5055
block_header

yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr

+12-3
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,31 @@ unconstrained pub fn get_membership_witness<N, M>(block_number: u32, tree_id: Fi
2525
MembershipWitness { index: fields[0], path: arr_copy_slice(fields, [0; N], 1) }
2626
}
2727

28-
unconstrained pub fn get_contract_membership_witness(block_number: u32, leaf_value: Field) -> MembershipWitness<CONTRACT_TREE_HEIGHT, CONTRACT_TREE_HEIGHT + 1> {
28+
unconstrained pub fn get_contract_membership_witness(
29+
block_number: u32,
30+
leaf_value: Field
31+
) -> MembershipWitness<CONTRACT_TREE_HEIGHT, CONTRACT_TREE_HEIGHT + 1> {
2932
let contract_tree_id = 0; // TODO(#3443)
3033
get_membership_witness(block_number, contract_tree_id, leaf_value)
3134
}
3235

3336
// Note: get_nullifier_membership_witness function is implemented in get_nullifier_membership_witness.nr
3437

35-
unconstrained pub fn get_note_hash_membership_witness<N, M>(block_number: u32, leaf_value: Field) -> MembershipWitness<NOTE_HASH_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT + 1> {
38+
unconstrained pub fn get_note_hash_membership_witness<N, M>(
39+
block_number: u32,
40+
leaf_value: Field
41+
) -> MembershipWitness<NOTE_HASH_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT + 1> {
3642
let note_hash_tree_id = 2; // TODO(#3443)
3743
get_membership_witness(block_number, note_hash_tree_id, leaf_value)
3844
}
3945

4046
// There is no `get_public_data_membership_witness` function because it doesn't make sense to be getting a membership
4147
// witness for a value in the public data tree.
4248

43-
unconstrained pub fn get_archive_membership_witness(block_number: u32, leaf_value: Field) -> MembershipWitness<ARCHIVE_HEIGHT, ARCHIVE_HEIGHT + 1> {
49+
unconstrained pub fn get_archive_membership_witness(
50+
block_number: u32,
51+
leaf_value: Field
52+
) -> MembershipWitness<ARCHIVE_HEIGHT, ARCHIVE_HEIGHT + 1> {
4453
let archive_tree_id = 5; // TODO(#3443)
4554
get_membership_witness(block_number, archive_tree_id, leaf_value)
4655
}

0 commit comments

Comments
 (0)