Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Aug 31, 2023
1 parent 5dc320c commit 9d3329c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/abis/ecdsa_account_contract.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use dep::std::hash::pedersen;
use dep::aztec::note::note_interface::NoteInterface;
use dep::aztec::note::note_header::NoteHeader;
use dep::aztec::note::utils::compute_unique_siloed_note_hash;
use dep::aztec::oracle::get_secret_key::get_secret_key;
use dep::aztec::oracle::{
get_secret_key::get_secret_key,
get_public_key::get_public_key,
};

global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5;

Expand Down Expand Up @@ -54,6 +57,14 @@ impl EcdsaPublicKeyNote {
fn compute_nullifier(self) -> Field {
let unique_siloed_note_hash = compute_unique_siloed_note_hash(EcdsaPublicKeyNoteInterface, self);
let secret = get_secret_key(self.owner);

// Constrain the owner - Nullifier secret key is currently just the encryption private key so we can constrain
// the owner by deriving the public key from the secret key and checking the result.
let owner_public_key = get_public_key(self.owner);
let computed_public_key = dep::std::scalar_mul::fixed_base(secret);
assert(owner_public_key.x == computed_public_key[0]);
assert(owner_public_key.y == computed_public_key[1]);

// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
unique_siloed_note_hash,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use dep::std::hash::pedersen;
use dep::aztec::note::note_interface::NoteInterface;
use dep::aztec::note::note_header::NoteHeader;
use dep::aztec::oracle::get_secret_key::get_secret_key;
use dep::aztec::note::utils::compute_siloed_note_hash;
use dep::aztec::oracle::{
get_secret_key::get_secret_key,
get_public_key::get_public_key,
};

global ADDRESS_NOTE_LEN: Field = 2;

Expand All @@ -29,6 +32,14 @@ impl AddressNote {
fn compute_nullifier(self) -> Field {
let siloed_note_hash = compute_siloed_note_hash(AddressNoteMethods, self);
let secret = get_secret_key(self.owner);

// Constrain the owner - Nullifier secret key is currently just the encryption private key so we can constrain
// the owner by deriving the public key from the secret key and checking the result.
let owner_public_key = get_public_key(self.owner);
let computed_public_key = dep::std::scalar_mul::fixed_base(secret);
assert(owner_public_key.x == computed_public_key[0]);
assert(owner_public_key.y == computed_public_key[1]);

// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
siloed_note_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use dep::std::hash::pedersen;
use dep::aztec::note::note_interface::NoteInterface;
use dep::aztec::note::note_header::NoteHeader;
use dep::aztec::note::utils::compute_unique_siloed_note_hash;
use dep::aztec::oracle::get_secret_key::get_secret_key;
use dep::aztec::oracle::{
get_secret_key::get_secret_key,
get_public_key::get_public_key,
};

global ADDRESS_NOTE_LEN: Field = 1;

Expand All @@ -28,6 +31,14 @@ impl AddressNote {
fn compute_nullifier(self) -> Field {
let unique_siloed_note_hash = compute_unique_siloed_note_hash(AddressNoteMethods, self);
let secret = get_secret_key(self.address);

// Constrain the owner - Nullifier secret key is currently just the encryption private key so we can constrain
// the owner by deriving the public key from the secret key and checking the result.
let owner_public_key = get_public_key(self.address);
let computed_public_key = dep::std::scalar_mul::fixed_base(secret);
assert(owner_public_key.x == computed_public_key[0]);
assert(owner_public_key.y == computed_public_key[1]);

// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
unique_siloed_note_hash,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use dep::std::hash::pedersen;
use dep::aztec::note::note_interface::NoteInterface;
use dep::aztec::note::note_header::NoteHeader;
use dep::aztec::oracle::get_secret_key::get_secret_key;
use dep::aztec::note::utils::compute_unique_siloed_note_hash;
use dep::aztec::oracle::{
get_secret_key::get_secret_key,
get_public_key::get_public_key,
};

global PUBLIC_KEY_NOTE_LEN: Field = 3;

Expand Down Expand Up @@ -33,6 +36,14 @@ impl PublicKeyNote {
fn compute_nullifier(self) -> Field {
let unique_siloed_note_hash = compute_unique_siloed_note_hash(PublicKeyNoteMethods, self);
let secret = get_secret_key(self.owner);

// Constrain the owner - Nullifier secret key is currently just the encryption private key so we can constrain
// the owner by deriving the public key from the secret key and checking the result.
let owner_public_key = get_public_key(self.owner);
let computed_public_key = dep::std::scalar_mul::fixed_base(secret);
assert(owner_public_key.x == computed_public_key[0]);
assert(owner_public_key.y == computed_public_key[1]);

// TODO(#1205) Should use a non-zero generator index.
dep::std::hash::pedersen([
unique_siloed_note_hash,
Expand Down

0 comments on commit 9d3329c

Please sign in to comment.