Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: key-rotation related issues in TokenWithRefunds #7631

Merged
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
12 changes: 6 additions & 6 deletions noir-projects/aztec-nr/aztec/src/note/utils.nr
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ use dep::protocol_types::{
};
use dep::std::{embedded_curve_ops::multi_scalar_mul, hash::from_field_unsafe};

pub fn compute_slotted_note_hash_raw(storage_slot: Field, note_hiding_point: Point) -> Field {
pub fn compute_slotted_note_hiding_point_raw(storage_slot: Field, note_hiding_point: Point) -> Point {
// 1. We derive the storage slot point by multiplying the storage slot with the generator G_slot.
// We use the unsafe version because the multi_scalar_mul will constrain the scalars.
let storage_slot_scalar = from_field_unsafe(storage_slot);
let storage_slot_point = multi_scalar_mul([G_slot], [storage_slot_scalar]);
let slotted_note_hiding_point = storage_slot_point + note_hiding_point;
let slotted_note_hash = slotted_note_hiding_point.x;

slotted_note_hash
// 2. Then we compute the slotted note hiding point by adding the storage slot point to the note hiding point.
storage_slot_point + note_hiding_point
}

pub fn compute_slotted_note_hash<Note, let N: u32, let M: u32>(note: Note) -> Field where Note: NoteInterface<N, M> {
let header = note.get_header();
let note_hash = note.compute_note_hiding_point();
let note_hiding_point = note.compute_note_hiding_point();

compute_slotted_note_hash_raw(header.storage_slot, note_hash)
compute_slotted_note_hiding_point_raw(header.storage_slot, note_hiding_point).x
}

pub fn compute_siloed_nullifier<Note, let N: u32, let M: u32>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ contract PrivateFPC {
#[aztec(storage)]
struct Storage {
other_asset: SharedImmutable<AztecAddress>,
admin_npk_m_hash: SharedImmutable<Field>
admin: SharedImmutable<AztecAddress>,
}

#[aztec(public)]
#[aztec(initializer)]
fn constructor(other_asset: AztecAddress, admin_npk_m_hash: Field) {
fn constructor(other_asset: AztecAddress, admin: AztecAddress) {
storage.other_asset.initialize(other_asset);
storage.admin_npk_m_hash.initialize(admin_npk_m_hash);
storage.admin.initialize(admin);
}

#[aztec(private)]
Expand All @@ -32,7 +32,7 @@ contract PrivateFPC {
emit_randomness_as_unencrypted_log(&mut context, fee_payer_randomness);

TokenWithRefunds::at(asset).setup_refund(
storage.admin_npk_m_hash.read_private(),
storage.admin.read_private(),
context.msg_sender(),
amount,
user_randomness,
Expand Down
Loading
Loading