Skip to content

Commit

Permalink
removing ownednote from value note and uint note
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Aug 29, 2024
1 parent d06c0b7 commit 32c4c4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 45 deletions.
30 changes: 5 additions & 25 deletions noir-projects/aztec-nr/uint-note/src/uint_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ use dep::aztec::{
};
use dep::std::{embedded_curve_ops::multi_scalar_mul, hash::from_field_unsafe};

trait OwnedNote {
fn new(amount: U128, owner_npk_m_hash: Field) -> Self;
fn get_amount(self) -> U128;
}

global UINT_NOTE_LEN: Field = 3; // 3 plus a header.
global UINT_NOTE_BYTES_LEN: Field = 3 * 32 + 64;

Expand Down Expand Up @@ -65,16 +60,16 @@ impl NoteInterface<UINT_NOTE_LEN, UINT_NOTE_BYTES_LEN> for UintNote {
impl UintNote {
// TODO: Merge this func with `compute_note_hiding_point`. I (benesjan) didn't do it in the initial PR to not have
// to modify macros and all the related funcs in it.
fn to_note_hiding_point(self) -> IntNoteHidingPoint {
IntNoteHidingPoint::new(self.compute_note_hiding_point())
fn to_note_hiding_point(self) -> UintNoteHidingPoint {
UintNoteHidingPoint::new(self.compute_note_hiding_point())
}
}

struct IntNoteHidingPoint {
struct UintNoteHidingPoint {
inner: Point
}

impl IntNoteHidingPoint {
impl UintNoteHidingPoint {
fn new(point: Point) -> Self {
Self { inner: point }
}
Expand All @@ -100,7 +95,7 @@ impl IntNoteHidingPoint {
}
}

impl Serialize<POINT_LENGTH> for IntNoteHidingPoint {
impl Serialize<POINT_LENGTH> for UintNoteHidingPoint {
fn serialize(self) -> [Field; POINT_LENGTH] {
self.inner.serialize()
}
Expand All @@ -113,18 +108,3 @@ impl Eq for UintNote {
(self.randomness == other.randomness)
}
}

impl OwnedNote for UintNote {
fn new(amount: U128, owner_npk_m_hash: Field) -> Self {
Self {
value: amount,
npk_m_hash: owner_npk_m_hash,
randomness: unsafe_rand(),
header: NoteHeader::empty(),
}
}

fn get_amount(self) -> U128 {
self.value
}
}
20 changes: 0 additions & 20 deletions noir-projects/aztec-nr/value-note/src/value_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ global VALUE_NOTE_LEN: Field = 3; // 3 plus a header.
// VALUE_NOTE_LEN * 32 + 32(storage_slot as bytes) + 32(note_type_id as bytes)
global VALUE_NOTE_BYTES_LEN: Field = 3 * 32 + 64;

trait OwnedNote {
fn new(amount: U128, owner_npk_m_hash: Field) -> Self;
fn get_amount(self) -> U128;
}

// docs:start:value-note-def
#[aztec(note)]
struct ValueNote {
Expand Down Expand Up @@ -105,21 +100,6 @@ impl Eq for ValueNote {
}
}

impl OwnedNote for ValueNote {
fn new(value: U128, owner_npk_m_hash: Field) -> Self {
Self {
value: value.to_field(),
npk_m_hash: owner_npk_m_hash,
randomness: unsafe_rand(),
header: NoteHeader::empty(),
}
}

fn get_amount(self) -> U128 {
U128::from_field(self.value)
}
}

struct ValueNoteHidingPoint {
inner: Point
}
Expand Down

0 comments on commit 32c4c4a

Please sign in to comment.