Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Jul 9, 2024
1 parent 199487d commit d43f607
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/keys/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ mod getters;
mod point_to_symmetric_key;
mod public_keys;

use crate::keys::public_keys::PublicKeys;
use crate::keys::public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH};
14 changes: 9 additions & 5 deletions noir-projects/aztec-nr/aztec/src/keys/public_keys.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dep::protocol_types::{
};
use crate::keys::constants::{NUM_KEY_TYPES, NULLIFIER_INDEX, INCOMING_INDEX, OUTGOING_INDEX};

global PUBLIC_KEYS_LENGTH = 8;
global PUBLIC_KEYS_LENGTH = 12;

struct PublicKeys {
npk_m: Point,
Expand Down Expand Up @@ -79,23 +79,27 @@ impl Serialize<PUBLIC_KEYS_LENGTH> for PublicKeys {
[
self.npk_m.x,
self.npk_m.y,
self.npk_m.is_infinite as Field,
self.ivpk_m.x,
self.ivpk_m.y,
self.ivpk_m.is_infinite as Field,
self.ovpk_m.x,
self.ovpk_m.y,
self.ovpk_m.is_infinite as Field,
self.tpk_m.x,
self.tpk_m.y,
self.tpk_m.is_infinite as Field
]
}
}

impl Deserialize<PUBLIC_KEYS_LENGTH> for PublicKeys {
fn deserialize(serialized: [Field; PUBLIC_KEYS_LENGTH]) -> PublicKeys {
PublicKeys {
npk_m: Point { x: serialized[0], y: serialized[1], is_infinite: false },
ivpk_m: Point { x: serialized[2], y: serialized[3], is_infinite: false },
ovpk_m: Point { x: serialized[4], y: serialized[5], is_infinite: false },
tpk_m: Point { x: serialized[6], y: serialized[7], is_infinite: false },
npk_m: Point::new(serialized[0], serialized[1], serialized[2] as bool),
ivpk_m: Point::new(serialized[3], serialized[4], serialized[5] as bool),
ovpk_m: Point::new(serialized[6], serialized[7], serialized[8] as bool),
tpk_m: Point::new(serialized[9], serialized[10], serialized[11] as bool)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use dep::authwit::auth_witness;
use dep::aztec::{protocol_types::{address::PartialAddress, point::Point}, keys::PublicKeys};
use dep::aztec::{
protocol_types::{address::PartialAddress, point::Point, utils::arr_copy_slice},
keys::{PublicKeys, PUBLIC_KEYS_LENGTH}
};

struct AuthWitness {
keys: PublicKeys,
Expand All @@ -8,25 +11,20 @@ struct AuthWitness {
}

impl AuthWitness {
fn deserialize(values: [Field; 73]) -> Self {
fn deserialize(values: [Field; 77]) -> Self {
let mut signature = [0; 64];
for i in 0..64 {
signature[i] = values[i + 8] as u8;
signature[i] = values[i + PUBLIC_KEYS_LENGTH] as u8;
}
Self {
keys: PublicKeys {
npk_m: Point::new(values[0], values[1], false),
ivpk_m: Point::new(values[2], values[3], false),
ovpk_m: Point::new(values[4], values[5], false),
tpk_m: Point::new(values[6], values[7], false)
},
keys: PublicKeys::deserialize(arr_copy_slice(values, [0; PUBLIC_KEYS_LENGTH], 0)),
signature,
partial_address: PartialAddress::from_field(values[72])
partial_address: PartialAddress::from_field(values[76])
}
}
}

unconstrained pub fn get_auth_witness(message_hash: Field) -> AuthWitness {
let witness: [Field; 73] = auth_witness::get_auth_witness(message_hash);
let witness: [Field; 77] = auth_witness::get_auth_witness(message_hash);
AuthWitness::deserialize(witness)
}

0 comments on commit d43f607

Please sign in to comment.