Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/note/note_getter.nr
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn extract_property_value_from_selector<let N: u32>(packed_note: [Field; N], sel
let mut acc: Field = 1;
for i in 0..32 {
if i < length {
value_field += value[(31 + offset - i) as u32] as Field * acc;
value_field += value[(31 - offset - i) as u32] as Field * acc;
acc = acc * 256;
}
}
Expand Down
11 changes: 11 additions & 0 deletions noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,14 @@ unconstrained fn constrain_view_note_rejects_mismatched_owner() {
let _ = confirm_hinted_note(context, note, Option::some(owner), storage_slot);
});
}

#[test]
unconstrained fn extract_property_value_from_selector_with_nonzero_offset() {
// 256 as a Field in big-endian bytes is [0, 0, ..., 0, 1, 0] (byte[30]=1, byte[31]=0).
// With offset: 1 and length: 1, we skip 1 byte from the least-significant end,
// so we should read byte[30] which is 1.
let packed = [256 as Field];
let selector = PropertySelector { index: 0, offset: 1, length: 1 };
let result = super::extract_property_value_from_selector(packed, selector);
assert_eq(result, 1);
}
Comment thread
nchamo marked this conversation as resolved.
Loading