Skip to content

Commit

Permalink
feat: various token note improvements (#8062)
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan authored Aug 19, 2024
1 parent 7f5517e commit 8f9dfd9
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,8 @@ impl NoteInterface<TOKEN_NOTE_LEN, TOKEN_NOTE_BYTES_LEN> for TokenNote {
}

fn compute_note_hiding_point(self) -> Point {
assert(self.header.storage_slot != 0, "Storage slot must be set before computing note hiding point");

// TODO(#7772): decompose amount with from_field_unsafe or constrain it fits into 1 limb
let amount_scalar = Scalar {
lo: self.amount.to_integer(),
hi: 0
};
// We use the unsafe version because the multi_scalar_mul will constrain the scalars.
let amount_scalar = from_field_unsafe(self.amount.to_integer());
let npk_m_hash_scalar = from_field_unsafe(self.npk_m_hash);
let randomness_scalar = from_field_unsafe(self.randomness);
let slot_scalar = from_field_unsafe(self.header.storage_slot);
Expand Down Expand Up @@ -88,9 +82,7 @@ impl TokenNoteHidingPoint {
}

fn add_amount(&mut self, amount: U128) {
// TODO(#7772): decompose amount with from_field_unsafe or constrain it fits into 1 limb
let amount_scalar = Scalar { lo: amount.to_integer(), hi: 0 };
self.inner = multi_scalar_mul([G_amt], [amount_scalar]) + self.inner;
self.inner = multi_scalar_mul([G_amt], [from_field_unsafe(amount.to_integer())]) + self.inner;
}

fn add_npk_m_hash(&mut self, npk_m_hash: Field) {
Expand Down

0 comments on commit 8f9dfd9

Please sign in to comment.