Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Aug 2, 2024
1 parent ef1fff3 commit 9aef14d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,15 @@ contract TokenWithRefunds {
};

// 5. Now we get the note hiding points.
let fee_payer_point = fee_payer_partial_note.to_note_hiding_point();
let user_point = user_partial_note.to_note_hiding_point();
let mut fee_payer_point = fee_payer_partial_note.to_note_hiding_point();
let mut user_point = user_partial_note.to_note_hiding_point();

// 6. Now we "manually" compute the slot points and add them to hiding points.
let fee_payer_balances_slot = derive_storage_slot_in_map(TokenWithRefunds::storage().balances.slot, fee_payer);
let user_balances_slot = derive_storage_slot_in_map(TokenWithRefunds::storage().balances.slot, user);

// TODO(benesjan): do not access longer access .inner here
let slotted_fee_payer_point = compute_slotted_note_hiding_point_raw(fee_payer_balances_slot, fee_payer_point.inner);
let slotted_user_point = compute_slotted_note_hiding_point_raw(user_balances_slot, user_point.inner);
fee_payer_point.add_slot(fee_payer_balances_slot);
user_point.add_slot(user_balances_slot);

// 7. Set the public teardown function to `complete_refund(...)`. Public teardown is the only time when a public
// function has access to the final transaction fee, which is needed to compute the actual refund amount.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dep::aztec::{
generators::{Ga1 as G_amt, Ga2 as G_npk, Ga3 as G_rnd},
generators::{Ga1 as G_amt, Ga2 as G_npk, Ga3 as G_rnd, G_slot},
prelude::{NoteHeader, NoteInterface, PrivateContext},
protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, point::Point, scalar::Scalar, hash::poseidon2_hash},
note::utils::compute_note_hash_for_consumption, oracle::unsafe_rand::unsafe_rand,
Expand Down Expand Up @@ -100,6 +100,10 @@ impl TokenNoteHidingPoint {
self.inner = multi_scalar_mul([G_rnd], [from_field_unsafe(randomness)]) + self.inner;
}

fn add_slot(&mut self, slot: Field) {
self.inner = multi_scalar_mul([G_slot], [from_field_unsafe(slot)]) + self.inner;
}

fn finalize(self) -> Field {
self.inner.x
}
Expand Down

0 comments on commit 9aef14d

Please sign in to comment.