-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
393 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
noir-projects/noir-contracts/contracts/token_contract/src/types.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod transparent_note; | ||
mod balances_map; | ||
mod token_note; | ||
mod partial_note; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
noir-projects/noir-contracts/contracts/token_contract/src/types/partial_note.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use dep::aztec::protocol_types::{hash::pedersen_hash, traits::{ToField, Serialize, Deserialize}, address::AztecAddress}; | ||
|
||
// helper struct to constrain a pair of partial notes to add up to a known amount | ||
// it's a struct so that it implements ToField and can be used as a map key | ||
struct PartialNotesHash { | ||
inner: Field | ||
} | ||
|
||
impl ToField for PartialNotesHash { | ||
fn to_field(self) -> Field { | ||
self.inner | ||
} | ||
} | ||
|
||
impl Serialize<1> for PartialNotesHash { | ||
fn serialize(self) -> [Field; 1] { | ||
[self.inner] | ||
} | ||
} | ||
|
||
impl Deserialize<1> for PartialNotesHash { | ||
fn deserialize(data: [Field; 1]) -> PartialNotesHash { | ||
PartialNotesHash { | ||
inner: data[0] | ||
} | ||
} | ||
} | ||
|
||
pub fn compute_partial_notes_pair_hash( | ||
partial_note_1: Field, | ||
partial_note_2: Field, | ||
completer: AztecAddress, | ||
amount: Field | ||
) -> PartialNotesHash { | ||
let inner = pedersen_hash( | ||
[partial_note_1, partial_note_2, completer.to_field(), amount], | ||
0 | ||
); | ||
|
||
PartialNotesHash { inner } | ||
} |
Oops, something went wrong.