diff --git a/boxes/boxes/react/src/contracts/src/main.nr b/boxes/boxes/react/src/contracts/src/main.nr index 6cbe8afbba8..16137655fff 100644 --- a/boxes/boxes/react/src/contracts/src/main.nr +++ b/boxes/boxes/react/src/contracts/src/main.nr @@ -1,6 +1,6 @@ contract BoxReact { use dep::aztec::prelude::{AztecAddress, PrivateMutable, Map, NoteInterface, NoteHeader}; - use dep::aztec::protocol_types::grumpkin_point::GrumpkinPoint; + use dep::aztec::protocol_types::embedded_curve_point::EmbeddedCurvePoint; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note_with_keys; use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; @@ -15,8 +15,8 @@ contract BoxReact { number: Field, owner: AztecAddress, owner_npk_m_hash: Field, - owner_ovpk_m: GrumpkinPoint, - owner_ivpk_m: GrumpkinPoint + owner_ovpk_m: EmbeddedCurvePoint, + owner_ivpk_m: EmbeddedCurvePoint ) { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner_npk_m_hash); @@ -28,8 +28,8 @@ contract BoxReact { number: Field, owner: AztecAddress, owner_npk_m_hash: Field, - owner_ovpk_m: GrumpkinPoint, - owner_ivpk_m: GrumpkinPoint + owner_ovpk_m: EmbeddedCurvePoint, + owner_ivpk_m: EmbeddedCurvePoint ) { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner_npk_m_hash); diff --git a/boxes/boxes/vanilla/src/contracts/src/main.nr b/boxes/boxes/vanilla/src/contracts/src/main.nr index c8090a00f88..ac9bc90479a 100644 --- a/boxes/boxes/vanilla/src/contracts/src/main.nr +++ b/boxes/boxes/vanilla/src/contracts/src/main.nr @@ -1,6 +1,6 @@ contract Vanilla { use dep::aztec::prelude::{AztecAddress, PrivateMutable, Map, NoteInterface, NoteHeader}; - use dep::aztec::protocol_types::grumpkin_point::GrumpkinPoint; + use dep::aztec::protocol_types::embedded_curve_point::EmbeddedCurvePoint; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note_with_keys; use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; @@ -15,8 +15,8 @@ contract Vanilla { number: Field, owner: AztecAddress, owner_npk_m_hash: Field, - owner_ovpk_m: GrumpkinPoint, - owner_ivpk_m: GrumpkinPoint + owner_ovpk_m: EmbeddedCurvePoint, + owner_ivpk_m: EmbeddedCurvePoint ) { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner_npk_m_hash); @@ -28,8 +28,8 @@ contract Vanilla { number: Field, owner: AztecAddress, owner_npk_m_hash: Field, - owner_ovpk_m: GrumpkinPoint, - owner_ivpk_m: GrumpkinPoint + owner_ovpk_m: EmbeddedCurvePoint, + owner_ivpk_m: EmbeddedCurvePoint ) { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner_npk_m_hash); diff --git a/noir-projects/aztec-nr/address-note/src/address_note.nr b/noir-projects/aztec-nr/address-note/src/address_note.nr index 26d494bed65..9bd3ce54961 100644 --- a/noir-projects/aztec-nr/address-note/src/address_note.nr +++ b/noir-projects/aztec-nr/address-note/src/address_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ protocol_types::{ address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - grumpkin_point::GrumpkinPoint, hash::poseidon2_hash + embedded_curve_point::EmbeddedCurvePoint, hash::poseidon2_hash }, note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app, context::PrivateContext diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr index f5366a16174..41cb5e3e741 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr @@ -3,14 +3,14 @@ use crate::{ encrypted_logs::payload::compute_encrypted_event_log, oracle::logs_traits::LensForEncryptedEvent, oracle::unsafe_rand::unsafe_rand }; -use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint, hash::sha256_to_field}; +use dep::protocol_types::{address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint, hash::sha256_to_field}; unconstrained fn compute_unconstrained( contract_address: AztecAddress, randomness: Field, ovsk_app: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, event: Event ) -> ([u8; OB], Field) where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { compute(contract_address, randomness, ovsk_app, ovpk, ivpk, event) @@ -20,8 +20,8 @@ fn compute( contract_address: AztecAddress, randomness: Field, ovsk_app: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, event: Event ) -> ([u8; OB], Field) where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { let encrypted_log: [u8; OB] = compute_encrypted_event_log(contract_address, randomness, ovsk_app, ovpk, ivpk, event); @@ -33,9 +33,9 @@ fn emit_with_keys( context: &mut PrivateContext, randomness: Field, event: Event, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, - inner_compute: fn(AztecAddress, Field, Field, GrumpkinPoint, GrumpkinPoint, Event) -> ([u8; OB], Field) + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, + inner_compute: fn(AztecAddress, Field, Field, EmbeddedCurvePoint, EmbeddedCurvePoint, Event) -> ([u8; OB], Field) ) where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { let contract_address: AztecAddress = context.this_address(); let ovsk_app: Field = context.request_ovsk_app(ovpk.hash()); @@ -101,9 +101,9 @@ pub fn encode_and_encrypt_event_with_randomness_unconstrained pub fn encode_and_encrypt_event_with_keys( context: &mut PrivateContext, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint -) -> fn[(&mut PrivateContext, GrumpkinPoint, GrumpkinPoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint +) -> fn[(&mut PrivateContext, EmbeddedCurvePoint, EmbeddedCurvePoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { | e: Event | { let randomness = unsafe_rand(); emit_with_keys(context, randomness, e, ovpk, ivpk, compute); @@ -112,9 +112,9 @@ pub fn encode_and_encrypt_event_with_keys( pub fn encode_and_encrypt_event_with_keys_unconstrained( context: &mut PrivateContext, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint -) -> fn[(&mut PrivateContext, GrumpkinPoint, GrumpkinPoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint +) -> fn[(&mut PrivateContext, EmbeddedCurvePoint, EmbeddedCurvePoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { | e: Event | { let randomness = unsafe_rand(); emit_with_keys(context, randomness, e, ovpk, ivpk, compute_unconstrained); @@ -124,9 +124,9 @@ pub fn encode_and_encrypt_event_with_keys_unconstrained( pub fn encode_and_encrypt_event_with_keys_with_randomness( context: &mut PrivateContext, randomness: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint -) -> fn[(&mut PrivateContext, Field, GrumpkinPoint, GrumpkinPoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint +) -> fn[(&mut PrivateContext, Field, EmbeddedCurvePoint, EmbeddedCurvePoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { | e: Event | { emit_with_keys(context, randomness, e, ovpk, ivpk, compute); } @@ -135,9 +135,9 @@ pub fn encode_and_encrypt_event_with_keys_with_randomness( pub fn encode_and_encrypt_event_with_keys_with_randomness_unconstrained( context: &mut PrivateContext, randomness: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint -) -> fn[(&mut PrivateContext, Field, GrumpkinPoint, GrumpkinPoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint +) -> fn[(&mut PrivateContext, Field, EmbeddedCurvePoint, EmbeddedCurvePoint)](Event) -> () where Event: EventInterface, [u8; NB]: LensForEncryptedEvent { | e: Event | { emit_with_keys(context, randomness, e, ovpk, ivpk, compute_unconstrained); } diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index 5c05dce4d20..289e961340f 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -3,7 +3,7 @@ use crate::{ encrypted_logs::payload::compute_encrypted_note_log, oracle::logs_traits::LensForEncryptedLog }; use dep::protocol_types::{ - hash::sha256_to_field, address::AztecAddress, grumpkin_point::GrumpkinPoint, + hash::sha256_to_field, address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint, abis::note_hash::NoteHash, constants::MAX_NOTE_HASHES_PER_CALL, utils::arrays::find_index }; @@ -11,8 +11,8 @@ unconstrained fn compute_unconstrained( contract_address: AztecAddress, storage_slot: Field, ovsk_app: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, note: Note ) -> ([u8; M], Field) where Note: NoteInterface, [Field; N]: LensForEncryptedLog { compute(contract_address, storage_slot, ovsk_app, ovpk, ivpk, note) @@ -22,8 +22,8 @@ fn compute( contract_address: AztecAddress, storage_slot: Field, ovsk_app: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, note: Note ) -> ([u8; M], Field) where Note: NoteInterface, [Field; N]: LensForEncryptedLog { let encrypted_log: [u8; M] = compute_encrypted_note_log(contract_address, storage_slot, ovsk_app, ovpk, ivpk, note); @@ -34,9 +34,9 @@ fn compute( fn emit_with_keys( context: &mut PrivateContext, note: Note, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, - inner_compute: fn(AztecAddress, Field, Field, GrumpkinPoint, GrumpkinPoint, Note) -> ([u8; M], Field) + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, + inner_compute: fn(AztecAddress, Field, Field, EmbeddedCurvePoint, EmbeddedCurvePoint, Note) -> ([u8; M], Field) ) where Note: NoteInterface, [Field; N]: LensForEncryptedLog { let note_header = note.get_header(); let note_hash_counter = note_header.note_hash_counter; @@ -86,9 +86,9 @@ pub fn encode_and_encrypt_note_unconstrained( pub fn encode_and_encrypt_note_with_keys( context: &mut PrivateContext, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint -) -> fn[(&mut PrivateContext, GrumpkinPoint, GrumpkinPoint)](NoteEmission) -> () where Note: NoteInterface, [Field; N]: LensForEncryptedLog { + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint +) -> fn[(&mut PrivateContext, EmbeddedCurvePoint, EmbeddedCurvePoint)](NoteEmission) -> () where Note: NoteInterface, [Field; N]: LensForEncryptedLog { | e: NoteEmission | { emit_with_keys(context, e.note, ovpk, ivpk, compute); } @@ -96,9 +96,9 @@ pub fn encode_and_encrypt_note_with_keys( pub fn encode_and_encrypt_note_with_keys_unconstrained( context: &mut PrivateContext, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint -) -> fn[(&mut PrivateContext, GrumpkinPoint, GrumpkinPoint)](NoteEmission) -> () where Note: NoteInterface, [Field; N]: LensForEncryptedLog { + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint +) -> fn[(&mut PrivateContext, EmbeddedCurvePoint, EmbeddedCurvePoint)](NoteEmission) -> () where Note: NoteInterface, [Field; N]: LensForEncryptedLog { | e: NoteEmission | { emit_with_keys(context, e.note, ovpk, ivpk, compute_unconstrained); } diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr index 3ab22f46ce8..a4fbe883934 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr @@ -1,4 +1,7 @@ -use dep::protocol_types::{address::AztecAddress, grumpkin_private_key::GrumpkinPrivateKey, grumpkin_point::GrumpkinPoint}; +use dep::protocol_types::{ + address::AztecAddress, grumpkin_private_key::GrumpkinPrivateKey, + embedded_curve_point::EmbeddedCurvePoint +}; use crate::keys::point_to_symmetric_key::point_to_symmetric_key; @@ -13,7 +16,7 @@ impl EncryptedLogHeader { EncryptedLogHeader { address } } - fn compute_ciphertext(self, secret: GrumpkinPrivateKey, point: GrumpkinPoint) -> [u8; 48] { + fn compute_ciphertext(self, secret: GrumpkinPrivateKey, point: EmbeddedCurvePoint) -> [u8; 48] { let full_key = point_to_symmetric_key(secret, point); let mut sym_key = [0; 16]; let mut iv = [0; 16]; @@ -36,9 +39,10 @@ fn test_encrypted_log_header() { 0x0000000000000000000000000000000023b3127c127b1f29a7adff5cccf8fb06, 0x00000000000000000000000000000000649e7ca01d9de27b21624098b897babd ); - let point = GrumpkinPoint::new( + let point = EmbeddedCurvePoint::new( 0x2688431c705a5ff3e6c6f2573c9e3ba1c1026d2251d0dbbf2d810aa53fd1d186, - 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e + 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e, + false ); let ciphertext = header.compute_ciphertext(secret, point); diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr index d8ce5b60133..a20b94c58d8 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/incoming_body.nr @@ -1,6 +1,6 @@ use crate::note::note_interface::NoteInterface; use crate::event::event_interface::EventInterface; -use dep::protocol_types::{grumpkin_private_key::GrumpkinPrivateKey, grumpkin_point::GrumpkinPoint}; +use dep::protocol_types::{grumpkin_private_key::GrumpkinPrivateKey, embedded_curve_point::EmbeddedCurvePoint}; use std::aes128::aes128_encrypt; use crate::keys::point_to_symmetric_key::point_to_symmetric_key; @@ -20,7 +20,7 @@ impl EncryptedLogIncomingBody { EncryptedLogIncomingBody { plaintext } } - pub fn compute_ciphertext(self, eph_sk: GrumpkinPrivateKey, ivpk_app: GrumpkinPoint) -> [u8] { + pub fn compute_ciphertext(self, eph_sk: GrumpkinPrivateKey, ivpk_app: EmbeddedCurvePoint) -> [u8] { let full_key = point_to_symmetric_key(eph_sk, ivpk_app); let mut sym_key = [0; 16]; let mut iv = [0; 16]; @@ -37,8 +37,8 @@ mod test { use crate::encrypted_logs::incoming_body::EncryptedLogIncomingBody; use dep::protocol_types::{ address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - grumpkin_private_key::GrumpkinPrivateKey, grumpkin_point::GrumpkinPoint, traits::Serialize, - abis::event_selector::EventSelector + grumpkin_private_key::GrumpkinPrivateKey, embedded_curve_point::EmbeddedCurvePoint, + traits::Serialize, abis::event_selector::EventSelector }; use crate::{ @@ -123,9 +123,10 @@ mod test { 0x0000000000000000000000000000000023b3127c127b1f29a7adff5cccf8fb06, 0x00000000000000000000000000000000649e7ca01d9de27b21624098b897babd ); - let ivpk_app = GrumpkinPoint::new( + let ivpk_app = EmbeddedCurvePoint::new( 0x2688431c705a5ff3e6c6f2573c9e3ba1c1026d2251d0dbbf2d810aa53fd1d186, - 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e + 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e, + false ); let body = EncryptedLogIncomingBody::from_note(note, storage_slot); @@ -222,9 +223,10 @@ mod test { 0x00000000000000000000000000000000649e7ca01d9de27b21624098b897babd ); - let ivpk_app = GrumpkinPoint::new( + let ivpk_app = EmbeddedCurvePoint::new( 0x2688431c705a5ff3e6c6f2573c9e3ba1c1026d2251d0dbbf2d810aa53fd1d186, - 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e + 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e, + false ); let randomness = 2; diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr index 76a009d56a6..dee4589ab0d 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/outgoing_body.nr @@ -1,6 +1,7 @@ use dep::protocol_types::{ - address::AztecAddress, grumpkin_private_key::GrumpkinPrivateKey, grumpkin_point::GrumpkinPoint, - constants::GENERATOR_INDEX__SYMMETRIC_KEY, hash::poseidon2_hash + address::AztecAddress, grumpkin_private_key::GrumpkinPrivateKey, + embedded_curve_point::EmbeddedCurvePoint, constants::GENERATOR_INDEX__SYMMETRIC_KEY, + hash::poseidon2_hash }; use std::aes128::aes128_encrypt; @@ -10,19 +11,23 @@ use crate::keys::point_to_symmetric_key::point_to_symmetric_key; struct EncryptedLogOutgoingBody { eph_sk: GrumpkinPrivateKey, recipient: AztecAddress, - recipient_ivpk_app: GrumpkinPoint, + recipient_ivpk_app: EmbeddedCurvePoint, } impl EncryptedLogOutgoingBody { pub fn new( eph_sk: GrumpkinPrivateKey, recipient: AztecAddress, - recipient_ivpk_app: GrumpkinPoint + recipient_ivpk_app: EmbeddedCurvePoint ) -> Self { Self { eph_sk, recipient, recipient_ivpk_app } } - pub fn compute_ciphertext(self, ovsk_app: GrumpkinPrivateKey, eph_pk: GrumpkinPoint) -> [u8; 176] { + pub fn compute_ciphertext( + self, + ovsk_app: GrumpkinPrivateKey, + eph_pk: EmbeddedCurvePoint + ) -> [u8; 176] { // Again, we could compute `eph_pk` here, but we keep the interface more similar // and also make it easier to optimise it later as we just pass it along @@ -68,7 +73,8 @@ mod test { use crate::encrypted_logs::outgoing_body::EncryptedLogOutgoingBody; use dep::protocol_types::{ address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - grumpkin_private_key::GrumpkinPrivateKey, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash + grumpkin_private_key::GrumpkinPrivateKey, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash }; use crate::context::PrivateContext; diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index 8227a9b072e..a905dfa8acd 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -1,5 +1,6 @@ use dep::protocol_types::{ - address::AztecAddress, grumpkin_private_key::GrumpkinPrivateKey, grumpkin_point::GrumpkinPoint, + address::AztecAddress, grumpkin_private_key::GrumpkinPrivateKey, + embedded_curve_point::EmbeddedCurvePoint, constants::{GENERATOR_INDEX__IVSK_M, GENERATOR_INDEX__OVSK_M}, hash::poseidon2_hash }; @@ -19,8 +20,8 @@ pub fn compute_encrypted_event_log( contract_address: AztecAddress, randomness: Field, ovsk_app: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, event: Event ) -> [u8; OB] where Event: EventInterface { // @todo Need to draw randomness from the full domain of Fq not only Fr @@ -76,8 +77,8 @@ pub fn compute_encrypted_note_log( contract_address: AztecAddress, storage_slot: Field, ovsk_app: Field, - ovpk: GrumpkinPoint, - ivpk: GrumpkinPoint, + ovpk: EmbeddedCurvePoint, + ivpk: EmbeddedCurvePoint, note: Note ) -> [u8; M] where Note: NoteInterface { // @todo Need to draw randomness from the full domain of Fq not only Fr @@ -146,7 +147,7 @@ fn fr_to_private_key(r: Field) -> GrumpkinPrivateKey { GrumpkinPrivateKey::new(high, low) } -fn compute_ivpk_app(ivpk: GrumpkinPoint, contract_address: AztecAddress) -> GrumpkinPoint { +fn compute_ivpk_app(ivpk: EmbeddedCurvePoint, contract_address: AztecAddress) -> EmbeddedCurvePoint { // It is useless to compute this, it brings no value to derive fully. // Issue(#6955) ivpk @@ -163,5 +164,5 @@ fn compute_ivpk_app(ivpk: GrumpkinPoint, contract_address: AztecAddress) -> Grum let embed_result = embedded_curve_add(embed_I, embed_ivpk); - GrumpkinPoint::new(embed_result.x, embed_result.y)*/ + EmbeddedCurvePoint::new(embed_result.x, embed_result.y)*/ } diff --git a/noir-projects/aztec-nr/aztec/src/event/event_interface.nr b/noir-projects/aztec-nr/aztec/src/event/event_interface.nr index 4505dedd1ab..63effd1a460 100644 --- a/noir-projects/aztec-nr/aztec/src/event/event_interface.nr +++ b/noir-projects/aztec-nr/aztec/src/event/event_interface.nr @@ -1,6 +1,6 @@ use crate::context::PrivateContext; use crate::note::note_header::NoteHeader; -use dep::protocol_types::{grumpkin_point::GrumpkinPoint, abis::event_selector::EventSelector}; +use dep::protocol_types::{embedded_curve_point::EmbeddedCurvePoint, abis::event_selector::EventSelector}; trait EventInterface { fn private_to_be_bytes(self, randomness: Field) -> [u8; NB]; diff --git a/noir-projects/aztec-nr/aztec/src/keys/getters.nr b/noir-projects/aztec-nr/aztec/src/keys/getters.nr index 8e56174ac83..52be4cb4cbb 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/getters.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/getters.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ header::Header, abis::validation_requests::KeyValidationRequest, address::AztecAddress, - constants::CANONICAL_KEY_REGISTRY_ADDRESS, grumpkin_point::GrumpkinPoint, + constants::CANONICAL_KEY_REGISTRY_ADDRESS, embedded_curve_point::EmbeddedCurvePoint, storage::map::derive_storage_slot_in_map }; use crate::{ @@ -14,27 +14,27 @@ global DELAY = 5; // docs:start:key-getters trait KeyGetters { - fn get_npk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint; - fn get_ivpk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint; - fn get_ovpk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint; - fn get_tpk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint; + fn get_npk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint; + fn get_ivpk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint; + fn get_ovpk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint; + fn get_tpk_m(header: Header, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint; fn get_npk_m_hash(header: Header, context: &mut PrivateContext, address: AztecAddress) -> Field; } impl KeyGetters for Header { - fn get_npk_m(self, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint { + fn get_npk_m(self, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint { get_master_key(context, address, NULLIFIER_INDEX, self) } - fn get_ivpk_m(self, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint { + fn get_ivpk_m(self, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint { get_master_key(context, address, INCOMING_INDEX, self) } - fn get_ovpk_m(self, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint { + fn get_ovpk_m(self, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint { get_master_key(context, address, OUTGOING_INDEX, self) } - fn get_tpk_m(self, context: &mut PrivateContext, address: AztecAddress) -> GrumpkinPoint { + fn get_tpk_m(self, context: &mut PrivateContext, address: AztecAddress) -> EmbeddedCurvePoint { get_master_key(context, address, TAGGING_INDEX, self) } @@ -49,9 +49,10 @@ fn get_master_key( address: AztecAddress, key_index: Field, header: Header -) -> GrumpkinPoint { +) -> EmbeddedCurvePoint { let key = fetch_key_from_registry(context, key_index, address, header); - if key.is_zero() { + // TODO(benesjan): re-introduce is-zero? + if (key.x == 0) & (key.y == 0) { // Keys were not registered in registry yet --> fetch key from PXE let keys = fetch_and_constrain_keys(address); // Return the corresponding to index @@ -67,7 +68,7 @@ fn fetch_key_from_registry( key_index: Field, address: AztecAddress, header: Header -) -> GrumpkinPoint { +) -> EmbeddedCurvePoint { let x_coordinate_map_slot = key_index * 2 + 1; let y_coordinate_map_slot = x_coordinate_map_slot + 1; let x_coordinate_derived_slot = derive_storage_slot_in_map(x_coordinate_map_slot, address); @@ -86,7 +87,7 @@ fn fetch_key_from_registry( let x_coordinate = x_coordinate_registry.get_value_in_private(header); let y_coordinate = y_coordinate_registry.get_value_in_private(header); - GrumpkinPoint::new(x_coordinate, y_coordinate) + EmbeddedCurvePoint::new(x_coordinate, y_coordinate, false) } // Passes only when keys were not rotated - is expected to be called only when keys were not registered yet diff --git a/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr b/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr index a6f72f546ef..480410d251a 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr @@ -1,18 +1,18 @@ use dep::protocol_types::{ constants::GENERATOR_INDEX__SYMMETRIC_KEY, grumpkin_private_key::GrumpkinPrivateKey, - grumpkin_point::GrumpkinPoint, utils::arr_copy_slice + embedded_curve_point::EmbeddedCurvePoint, utils::arr_copy_slice }; use std::{hash::sha256, embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul}}; // TODO(#5726): This function is called deriveAESSecret in TS. I don't like point_to_symmetric_key name much since // point is not the only input of the function. Unify naming with TS once we have a better name. -pub fn point_to_symmetric_key(secret: GrumpkinPrivateKey, point: GrumpkinPoint) -> [u8; 32] { +pub fn point_to_symmetric_key(secret: GrumpkinPrivateKey, point: EmbeddedCurvePoint) -> [u8; 32] { let shared_secret_fields = multi_scalar_mul( [EmbeddedCurvePoint { x: point.x, y: point.y, is_infinite: false }], [EmbeddedCurveScalar { lo: secret.low, hi: secret.high }] ); // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6061): make the func return Point struct directly - let shared_secret = GrumpkinPoint::new(shared_secret_fields[0], shared_secret_fields[1]); + let shared_secret = EmbeddedCurvePoint::new(shared_secret_fields[0], shared_secret_fields[1], false); let mut shared_secret_bytes_with_separator = [0 as u8; 65]; shared_secret_bytes_with_separator = arr_copy_slice(shared_secret.to_be_bytes(), shared_secret_bytes_with_separator, 0); shared_secret_bytes_with_separator[64] = GENERATOR_INDEX__SYMMETRIC_KEY; @@ -26,9 +26,10 @@ fn check_point_to_symmetric_key() { 0x0000000000000000000000000000000023b3127c127b1f29a7adff5cccf8fb06, 0x00000000000000000000000000000000649e7ca01d9de27b21624098b897babd ); - let point = GrumpkinPoint::new( + let point = EmbeddedCurvePoint::new( 0x2688431c705a5ff3e6c6f2573c9e3ba1c1026d2251d0dbbf2d810aa53fd1d186, - 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e + 0x1e96887b117afca01c00468264f4f80b5bb16d94c1808a448595f115556e5c8e, + false ); let key = point_to_symmetric_key(secret, point); diff --git a/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr b/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr index f723365df9e..a003c20f2c0 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/public_keys.nr @@ -1,25 +1,25 @@ use dep::protocol_types::{ address::PublicKeysHash, constants::GENERATOR_INDEX__PUBLIC_KEYS_HASH, hash::poseidon2_hash, - grumpkin_point::GrumpkinPoint, traits::{Deserialize, Serialize, Empty, is_empty} + embedded_curve_point::EmbeddedCurvePoint, traits::{Deserialize, Serialize, Empty, is_empty} }; use crate::keys::constants::{NUM_KEY_TYPES, NULLIFIER_INDEX, INCOMING_INDEX, OUTGOING_INDEX}; global PUBLIC_KEYS_LENGTH = 8; struct PublicKeys { - npk_m: GrumpkinPoint, - ivpk_m: GrumpkinPoint, - ovpk_m: GrumpkinPoint, - tpk_m: GrumpkinPoint, + npk_m: EmbeddedCurvePoint, + ivpk_m: EmbeddedCurvePoint, + ovpk_m: EmbeddedCurvePoint, + tpk_m: EmbeddedCurvePoint, } impl Empty for PublicKeys { fn empty() -> Self { PublicKeys { - npk_m : GrumpkinPoint::empty(), - ivpk_m : GrumpkinPoint::empty(), - ovpk_m : GrumpkinPoint::empty(), - tpk_m : GrumpkinPoint::empty() + npk_m : EmbeddedCurvePoint::point_at_infinity(), + ivpk_m : EmbeddedCurvePoint::point_at_infinity(), + ovpk_m : EmbeddedCurvePoint::point_at_infinity(), + tpk_m : EmbeddedCurvePoint::point_at_infinity() } } } @@ -56,7 +56,7 @@ impl PublicKeys { ) } - pub fn get_key_by_index(self, index: Field) -> GrumpkinPoint { + pub fn get_key_by_index(self, index: Field) -> EmbeddedCurvePoint { assert(index as u8 < NUM_KEY_TYPES, "Invalid key index"); if index == NULLIFIER_INDEX { self.npk_m @@ -88,10 +88,10 @@ impl Serialize for PublicKeys { impl Deserialize for PublicKeys { fn deserialize(serialized: [Field; PUBLIC_KEYS_LENGTH]) -> PublicKeys { PublicKeys { - npk_m: GrumpkinPoint { x: serialized[0], y: serialized[1] }, - ivpk_m: GrumpkinPoint { x: serialized[2], y: serialized[3] }, - ovpk_m: GrumpkinPoint { x: serialized[4], y: serialized[5] }, - tpk_m: GrumpkinPoint { x: serialized[6], y: serialized[7] }, + npk_m: EmbeddedCurvePoint { x: serialized[0], y: serialized[1], is_infinite: false }, + ivpk_m: EmbeddedCurvePoint { x: serialized[2], y: serialized[3], is_infinite: false }, + ovpk_m: EmbeddedCurvePoint { x: serialized[4], y: serialized[5], is_infinite: false }, + tpk_m: EmbeddedCurvePoint { x: serialized[6], y: serialized[7], is_infinite: false }, } } } @@ -99,10 +99,10 @@ impl Deserialize for PublicKeys { #[test] fn compute_public_keys_hash() { let keys = PublicKeys { - npk_m: GrumpkinPoint { x: 1, y: 2 }, - ivpk_m: GrumpkinPoint { x: 3, y: 4 }, - ovpk_m: GrumpkinPoint { x: 5, y: 6 }, - tpk_m: GrumpkinPoint { x: 7, y: 8 } + npk_m: EmbeddedCurvePoint { x: 1, y: 2, is_infinite: false }, + ivpk_m: EmbeddedCurvePoint { x: 3, y: 4, is_infinite: false }, + ovpk_m: EmbeddedCurvePoint { x: 5, y: 6, is_infinite: false }, + tpk_m: EmbeddedCurvePoint { x: 7, y: 8, is_infinite: false } }; let actual = keys.hash(); @@ -114,10 +114,10 @@ fn compute_public_keys_hash() { #[test] fn test_public_keys_serialization() { let keys = PublicKeys { - npk_m: GrumpkinPoint { x: 1, y: 2 }, - ivpk_m: GrumpkinPoint { x: 3, y: 4 }, - ovpk_m: GrumpkinPoint { x: 5, y: 6 }, - tpk_m: GrumpkinPoint { x: 7, y: 8 } + npk_m: EmbeddedCurvePoint { x: 1, y: 2, is_infinite: false }, + ivpk_m: EmbeddedCurvePoint { x: 3, y: 4, is_infinite: false }, + ovpk_m: EmbeddedCurvePoint { x: 5, y: 6, is_infinite: false }, + tpk_m: EmbeddedCurvePoint { x: 7, y: 8, is_infinite: false } }; let serialized = keys.serialize(); diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index e9b4ac556f6..41eaba032bd 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::grumpkin_point::GrumpkinPoint; +use dep::protocol_types::embedded_curve_point::EmbeddedCurvePoint; use crate::context::{PrivateContext, PublicContext}; use crate::note::{ note_header::NoteHeader, note_interface::NoteInterface, diff --git a/noir-projects/aztec-nr/aztec/src/note/note_interface.nr b/noir-projects/aztec-nr/aztec/src/note/note_interface.nr index 7206671e3dc..622c958d852 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_interface.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_interface.nr @@ -1,6 +1,6 @@ use crate::context::PrivateContext; use crate::note::note_header::NoteHeader; -use dep::protocol_types::grumpkin_point::GrumpkinPoint; +use dep::protocol_types::embedded_curve_point::EmbeddedCurvePoint; // docs:start:note_interface trait NoteInterface { diff --git a/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr b/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr index 77ab29f9e41..b4789b8f140 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr @@ -1,13 +1,10 @@ use dep::protocol_types::{ - grumpkin_point::GrumpkinPoint, + embedded_curve_point::EmbeddedCurvePoint, abis::validation_requests::{KeyValidationRequest, key_validation_request::KEY_VALIDATION_REQUEST_LENGTH} }; #[oracle(getKeyValidationRequest)] -unconstrained fn get_key_validation_request_oracle( - _pk_m_hash: Field, - _key_index: Field -) -> [Field; KEY_VALIDATION_REQUEST_LENGTH] {} +unconstrained fn get_key_validation_request_oracle(_pk_m_hash: Field, _key_index: Field) -> [Field; KEY_VALIDATION_REQUEST_LENGTH] {} unconstrained fn get_key_validation_request_internal(npk_m_hash: Field, key_index: Field) -> KeyValidationRequest { let result = get_key_validation_request_oracle(npk_m_hash, key_index); diff --git a/noir-projects/aztec-nr/aztec/src/oracle/keys.nr b/noir-projects/aztec-nr/aztec/src/oracle/keys.nr index aa83e4ec973..f98b079a524 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/keys.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/keys.nr @@ -1,5 +1,5 @@ use crate::keys::PublicKeys; -use dep::protocol_types::{address::{AztecAddress, PartialAddress}, grumpkin_point::GrumpkinPoint}; +use dep::protocol_types::{address::{AztecAddress, PartialAddress}, embedded_curve_point::EmbeddedCurvePoint}; #[oracle(getPublicKeysAndPartialAddress)] unconstrained fn get_public_keys_and_partial_address_oracle(_address: AztecAddress) -> [Field; 9] {} @@ -12,10 +12,10 @@ fn get_public_keys_and_partial_address(address: AztecAddress) -> (PublicKeys, Pa let result = get_public_keys_and_partial_address_oracle_wrapper(address); let keys = PublicKeys { - npk_m: GrumpkinPoint::new(result[0], result[1]), - ivpk_m: GrumpkinPoint::new(result[2], result[3]), - ovpk_m: GrumpkinPoint::new(result[4], result[5]), - tpk_m: GrumpkinPoint::new(result[6], result[7]) + npk_m: EmbeddedCurvePoint::new(result[0], result[1], false), + ivpk_m: EmbeddedCurvePoint::new(result[2], result[3], false), + ovpk_m: EmbeddedCurvePoint::new(result[4], result[5], false), + tpk_m: EmbeddedCurvePoint::new(result[6], result[7], false) }; let partial_address = PartialAddress::from_field(result[8]); diff --git a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr index e7bf8b0008d..694041986cd 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr @@ -1,8 +1,12 @@ -use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint}; +use dep::protocol_types::{address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint}; // = 480 + 32 * N bytes #[oracle(emitEncryptedNoteLog)] -unconstrained fn emit_encrypted_note_log_oracle(_note_hash_counter: u32, _encrypted_note: [u8; M], _counter: u32) {} +unconstrained fn emit_encrypted_note_log_oracle( + _note_hash_counter: u32, + _encrypted_note: [u8; M], + _counter: u32 +) {} unconstrained pub fn emit_encrypted_note_log( note_hash_counter: u32, @@ -13,7 +17,12 @@ unconstrained pub fn emit_encrypted_note_log( } #[oracle(emitEncryptedEventLog)] -unconstrained fn emit_encrypted_event_log_oracle(_contract_address: AztecAddress, _randomness: Field, _encrypted_event: [u8; M], _counter: u32) {} +unconstrained fn emit_encrypted_event_log_oracle( + _contract_address: AztecAddress, + _randomness: Field, + _encrypted_event: [u8; M], + _counter: u32 +) {} unconstrained pub fn emit_encrypted_event_log( contract_address: AztecAddress, @@ -31,8 +40,8 @@ unconstrained fn compute_encrypted_note_log_oracle( _storage_slot: Field, _note_type_id: Field, _ovsk_app: Field, - _ovpk_m: GrumpkinPoint, - _ivpk_m: GrumpkinPoint, + _ovpk_m: EmbeddedCurvePoint, + _ivpk_m: EmbeddedCurvePoint, _preimage: [Field; N] ) -> [u8; M] {} @@ -41,8 +50,8 @@ unconstrained pub fn compute_encrypted_note_log( storage_slot: Field, note_type_id: Field, ovsk_app: Field, - ovpk_m: GrumpkinPoint, - ivpk_m: GrumpkinPoint, + ovpk_m: EmbeddedCurvePoint, + ivpk_m: EmbeddedCurvePoint, preimage: [Field; N] ) -> [u8; M] { compute_encrypted_note_log_oracle( @@ -63,8 +72,8 @@ unconstrained fn compute_encrypted_event_log_oracle( _randomness: Field, _event_type_id: Field, _ovsk_app: Field, - _ovpk_m: GrumpkinPoint, - _ivpk_m: GrumpkinPoint, + _ovpk_m: EmbeddedCurvePoint, + _ivpk_m: EmbeddedCurvePoint, _preimage: [Field; N] ) -> [u8; M] {} @@ -73,8 +82,8 @@ unconstrained pub fn compute_encrypted_event_log( randomness: Field, event_type_id: Field, ovsk_app: Field, - ovpk_m: GrumpkinPoint, - ivpk_m: GrumpkinPoint, + ovpk_m: EmbeddedCurvePoint, + ivpk_m: EmbeddedCurvePoint, preimage: [Field; N] ) -> [u8; M] { compute_encrypted_event_log_oracle( @@ -89,7 +98,11 @@ unconstrained pub fn compute_encrypted_event_log( } #[oracle(emitUnencryptedLog)] -unconstrained fn emit_unencrypted_log_oracle_private(_contract_address: AztecAddress, _message: T, _counter: u32) -> Field {} +unconstrained fn emit_unencrypted_log_oracle_private( + _contract_address: AztecAddress, + _message: T, + _counter: u32 +) -> Field {} unconstrained pub fn emit_unencrypted_log_private_internal( contract_address: AztecAddress, diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr index cb909e64a4b..1d31ff270d9 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr @@ -1,5 +1,5 @@ use dep::protocol_types::{ - address::AztecAddress, grumpkin_point::GrumpkinPoint, + address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, hash::pedersen_hash }; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr index d36c5af8b3a..c72d9dee8c6 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, - grumpkin_point::GrumpkinPoint, hash::pedersen_hash + embedded_curve_point::EmbeddedCurvePoint, hash::pedersen_hash }; use crate::context::{PrivateContext, UnconstrainedContext}; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr index 61f142c1161..d2a1e2b6d72 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint}; +use dep::protocol_types::{address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint}; use crate::{context::PrivateContext, state_vars::private_mutable::PrivateMutable}; use crate::test::{mocks::mock_note::MockNote, helpers::{cheatcodes, test_environment::TestEnvironment}}; use std::{unsafe::zeroed, test::OracleMock}; @@ -23,8 +23,8 @@ fn test_initialize_or_replace_without_nullifier() { let mut env = setup(); let state_var = in_private(&mut env); - let ovpk_m: GrumpkinPoint = zeroed(); - let ivpk_m: GrumpkinPoint = zeroed(); + let ovpk_m: EmbeddedCurvePoint = zeroed(); + let ivpk_m: EmbeddedCurvePoint = zeroed(); let value = 42; let mut note = MockNote::new(value).contract_address(cheatcodes::get_contract_address()).storage_slot(storage_slot).build(); diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr index 1e9125d9bb7..e2a5fb6c998 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, abis::read_request::ReadRequest, - grumpkin_point::GrumpkinPoint + embedded_curve_point::EmbeddedCurvePoint }; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; use crate::note::{ diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr index f4c53c95c20..b703c9330a1 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr @@ -1,11 +1,11 @@ use dep::protocol_types::{ address::AztecAddress, storage::map::derive_storage_slot_in_map, - constants::CANONICAL_KEY_REGISTRY_ADDRESS, grumpkin_point::GrumpkinPoint + constants::CANONICAL_KEY_REGISTRY_ADDRESS, embedded_curve_point::EmbeddedCurvePoint }; use crate::test::helpers::cheatcodes; -pub fn store_master_key(key_index: Field, address: AztecAddress, key: GrumpkinPoint) { +pub fn store_master_key(key_index: Field, address: AztecAddress, key: EmbeddedCurvePoint) { let x_coordinate_map_slot = key_index * 2 + 1; let y_coordinate_map_slot = x_coordinate_map_slot + 1; let x_coordinate_derived_slot = derive_storage_slot_in_map(x_coordinate_map_slot, address); diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr index e045ca4b8bc..d9931e5c9a7 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr @@ -1,7 +1,8 @@ use dep::protocol_types::{ abis::{function_selector::FunctionSelector, private_circuit_public_inputs::PrivateCircuitPublicInputs}, address::{AztecAddress, PartialAddress}, storage::map::derive_storage_slot_in_map, - constants::CANONICAL_KEY_REGISTRY_ADDRESS, grumpkin_point::GrumpkinPoint, traits::Deserialize + constants::CANONICAL_KEY_REGISTRY_ADDRESS, embedded_curve_point::EmbeddedCurvePoint, + traits::Deserialize }; use crate::context::inputs::{PublicContextInputs, PrivateContextInputs}; diff --git a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr index 3e320ec6559..dca0ff0d29f 100644 --- a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr +++ b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr @@ -1,6 +1,6 @@ use crate::{context::PrivateContext, note::{note_header::NoteHeader, note_interface::NoteInterface}}; -use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint, traits::Eq}; +use dep::protocol_types::{address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint, traits::Eq}; global MOCK_NOTE_LENGTH = 1; // MOCK_NOTE_LENGTH * 32 + 32(storage_slot as bytes) + 32(note_type_id as bytes) diff --git a/noir-projects/aztec-nr/aztec/src/unencrypted_logs/unencrypted_event_emission.nr b/noir-projects/aztec-nr/aztec/src/unencrypted_logs/unencrypted_event_emission.nr index f374a2a1195..ccac6b5ab84 100644 --- a/noir-projects/aztec-nr/aztec/src/unencrypted_logs/unencrypted_event_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/unencrypted_logs/unencrypted_event_emission.nr @@ -2,7 +2,7 @@ use crate::{ context::{PrivateContext, PublicContext}, event::event_interface::EventInterface, encrypted_logs::payload::compute_encrypted_event_log, oracle::logs_traits::LensForEncryptedEvent }; -use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint, traits::Serialize}; +use dep::protocol_types::{address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint, traits::Serialize}; fn emit( context: &mut PublicContext, diff --git a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr index 1a84b86acba..9187faabdcf 100644 --- a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr +++ b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr @@ -1,5 +1,6 @@ use dep::aztec::{ - context::PrivateContext, protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint}, + context::PrivateContext, + protocol_types::{address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint}, note::note_getter_options::NoteGetterOptions, state_vars::PrivateSet, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note }; diff --git a/noir-projects/aztec-nr/value-note/src/utils.nr b/noir-projects/aztec-nr/value-note/src/utils.nr index 44094999c76..9b2596411c8 100644 --- a/noir-projects/aztec-nr/value-note/src/utils.nr +++ b/noir-projects/aztec-nr/value-note/src/utils.nr @@ -1,6 +1,6 @@ use dep::aztec::prelude::{AztecAddress, PrivateContext, PrivateSet, NoteGetterOptions}; use dep::aztec::note::note_getter_options::SortOrder; -use dep::aztec::protocol_types::grumpkin_point::GrumpkinPoint; +use dep::aztec::protocol_types::embedded_curve_point::EmbeddedCurvePoint; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; use crate::{filter::filter_notes_min_sum, value_note::{ValueNote, VALUE_NOTE_LEN, VALUE_NOTE_BYTES_LEN}}; diff --git a/noir-projects/aztec-nr/value-note/src/value_note.nr b/noir-projects/aztec-nr/value-note/src/value_note.nr index 409d6aaa9dc..507fe5366cb 100644 --- a/noir-projects/aztec-nr/value-note/src/value_note.nr +++ b/noir-projects/aztec-nr/value-note/src/value_note.nr @@ -1,6 +1,6 @@ use dep::aztec::{ protocol_types::{ - address::AztecAddress, grumpkin_point::GrumpkinPoint, traits::{Deserialize, Serialize}, + address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint, traits::{Deserialize, Serialize}, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash }, note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr index 5721632d542..29ce3be98bc 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr @@ -10,7 +10,7 @@ contract AppSubscription { SharedImmutable }, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - protocol_types::{traits::is_empty, grumpkin_point::GrumpkinPoint} + protocol_types::{traits::is_empty, embedded_curve_point::EmbeddedCurvePoint} }; use authwit::{auth_witness::get_auth_witness, auth::assert_current_call_valid_authwit}; use gas_token::GasToken; diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr index fb19b8a912e..59f6fe84b26 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr @@ -1,6 +1,9 @@ use dep::aztec::prelude::{AztecAddress, PrivateContext, NoteHeader, NoteInterface}; use dep::aztec::{ - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash}, + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +}, note::utils::compute_note_hash_for_consumption, keys::getters::get_nsk_app }; diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index 4560fbf6151..57a47d9a999 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -24,11 +24,14 @@ contract AvmTest { global big_field_136_bits: Field = 0x991234567890abcdef1234567890abcdef; // Libs - use std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul}; + use std::embedded_curve_ops::{EmbeddedCurveScalar, multi_scalar_mul}; use dep::aztec::protocol_types::constants::CONTRACT_INSTANCE_LENGTH; use dep::aztec::prelude::{Map, Deserialize}; use dep::aztec::state_vars::PublicMutable; - use dep::aztec::protocol_types::{address::{AztecAddress, EthAddress}, constants::L1_TO_L2_MESSAGE_LENGTH}; + use dep::aztec::protocol_types::{ + address::{AztecAddress, EthAddress}, constants::L1_TO_L2_MESSAGE_LENGTH, + embedded_curve_point::EmbeddedCurvePoint + }; use dep::aztec::oracle::get_contract_instance::{get_contract_instance_avm, get_contract_instance_internal_avm}; use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; use dep::aztec::context::gas::GasOpts; diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index a7c265c4528..75e95647d21 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -3,7 +3,7 @@ use dep::aztec::prelude::{AztecAddress, FunctionSelector, PrivateContext, NoteHe use dep::aztec::{ context::UnconstrainedContext, protocol_types::{ - traits::{ToField, Serialize, FromField}, grumpkin_point::GrumpkinPoint, + traits::{ToField, Serialize, FromField}, embedded_curve_point::EmbeddedCurvePoint, constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL }, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note_with_keys, diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index bd7220461a1..37118ac615a 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -4,7 +4,7 @@ contract Child { use dep::aztec::{ context::gas::GasOpts, - protocol_types::{abis::call_context::CallContext, grumpkin_point::GrumpkinPoint}, + protocol_types::{abis::call_context::CallContext, embedded_curve_point::EmbeddedCurvePoint}, note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader}, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note }; diff --git a/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr b/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr index 7a848446055..86d73281ce4 100644 --- a/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr @@ -5,7 +5,7 @@ contract DelegatedOn { PrivateSet, PrivateContext, Map }; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; - use dep::aztec::{protocol_types::grumpkin_point::GrumpkinPoint}; + use dep::aztec::{protocol_types::embedded_curve_point::EmbeddedCurvePoint}; use dep::value_note::value_note::ValueNote; #[aztec(storage)] diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index 22242e9404a..6b57f4be688 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -20,7 +20,7 @@ contract DocsExample { }; use dep::aztec::encrypted_logs::encrypted_note_emission::{encode_and_encrypt_note, encode_and_encrypt_note_with_keys}; use dep::aztec::note::note_getter_options::Comparator; - use dep::aztec::protocol_types::grumpkin_point::GrumpkinPoint; + use dep::aztec::protocol_types::embedded_curve_point::EmbeddedCurvePoint; // how to import methods from other files/folders within your workspace use crate::types::{card_note::{CardNote, CARD_NOTE_LEN}, leader::Leader}; diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index f1c3bd6f080..c6dbfa26566 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -2,7 +2,7 @@ use dep::aztec::prelude::{AztecAddress, NoteInterface, NoteHeader, PrivateContex use dep::aztec::{ note::{utils::compute_note_hash_for_consumption}, keys::getters::get_nsk_app, protocol_types::{ - traits::{Empty, Serialize}, grumpkin_point::GrumpkinPoint, + traits::{Empty, Serialize}, embedded_curve_point::EmbeddedCurvePoint, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash } }; diff --git a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index 1ca27ba7cdd..80760975db2 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -2,7 +2,10 @@ use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, NoteInterf use dep::aztec::{ note::utils::compute_note_hash_for_consumption, keys::getters::get_nsk_app, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash} + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +} }; global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5; diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 35f5a5aace6..b80a24a090d 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -6,7 +6,7 @@ contract InclusionProofs { }; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; - use dep::aztec::protocol_types::{grumpkin_point::GrumpkinPoint, contract_class_id::ContractClassId, header::Header}; + use dep::aztec::protocol_types::{embedded_curve_point::EmbeddedCurvePoint, contract_class_id::ContractClassId, header::Header}; use dep::aztec::{note::note_getter_options::NoteStatus}; // docs:start:imports // Imports are not needed as inclusion / non_inclusion proofs are accessible on the header. diff --git a/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr b/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr index f51631c1f1c..04b0acbb59d 100644 --- a/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr @@ -3,7 +3,7 @@ contract KeyRegistry { use dep::aztec::{ keys::PublicKeys, state_vars::{SharedMutable, Map}, - protocol_types::{grumpkin_point::GrumpkinPoint, address::{AztecAddress, PartialAddress}} + protocol_types::{embedded_curve_point::EmbeddedCurvePoint, address::{AztecAddress, PartialAddress}} }; global KEY_ROTATION_DELAY = 5; @@ -27,7 +27,7 @@ contract KeyRegistry { } #[aztec(public)] - fn rotate_npk_m(address: AztecAddress, new_npk_m: GrumpkinPoint, nonce: Field) { + fn rotate_npk_m(address: AztecAddress, new_npk_m: EmbeddedCurvePoint, nonce: Field) { // TODO: (#6137) if (!address.eq(context.msg_sender())) { assert_current_call_valid_authwit_public(&mut context, address); diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index a3ecd0781a2..e3c194b0ab0 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -6,7 +6,7 @@ contract PendingNoteHashes { // Libs use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, NoteGetterOptions, PrivateContext, Map, PrivateSet}; use dep::value_note::{balance_utils, filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}}; - use dep::aztec::protocol_types::grumpkin_point::GrumpkinPoint; + use dep::aztec::protocol_types::embedded_curve_point::EmbeddedCurvePoint; use dep::aztec::protocol_types::constants::{MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL}; use dep::aztec::encrypted_logs::encrypted_note_emission::{encode_and_encrypt_note, encode_and_encrypt_note_with_keys}; use dep::aztec::note::note_emission::NoteEmission; diff --git a/noir-projects/noir-contracts/contracts/private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/private_token_contract/src/main.nr index 18873a6e027..7e9d8258bf9 100644 --- a/noir-projects/noir-contracts/contracts/private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/private_token_contract/src/main.nr @@ -8,14 +8,15 @@ contract PrivateToken { use dep::aztec::{ note::utils::compute_inner_note_hash_from_preimage, hash::compute_secret_hash, prelude::{NoteGetterOptions, Map, PublicMutable, SharedImmutable, PrivateSet, AztecAddress}, - protocol_types::{abis::function_selector::FunctionSelector, hash::pedersen_hash}, + protocol_types::{ + abis::function_selector::FunctionSelector, embedded_curve_point::EmbeddedCurvePoint, + hash::pedersen_hash + }, oracle::unsafe_rand::unsafe_rand, encrypted_logs::encrypted_note_emission::{encode_and_encrypt_note, encode_and_encrypt_note_with_keys} }; use dep::authwit::{auth::{assert_current_call_valid_authwit, assert_current_call_valid_authwit_public}}; use crate::types::{token_note::{TokenNote, TOKEN_NOTE_LEN}, balances_map::BalancesMap}; - use dep::std::embedded_curve_ops::EmbeddedCurvePoint; - use dep::std::ec::tecurve::affine::Point; #[aztec(storage)] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/private_token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/private_token_contract/src/types/token_note.nr index d41b70934b6..8b33df1380d 100644 --- a/noir-projects/noir-contracts/contracts/private_token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/private_token_contract/src/types/token_note.nr @@ -1,11 +1,14 @@ use dep::aztec::{ prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash}, + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +}, note::utils::compute_note_hash_for_consumption, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app, note::note_getter_options::PropertySelector }; use dep::std::field::bn254::decompose; -use dep::std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul, fixed_base_scalar_mul}; +use dep::std::embedded_curve_ops::{EmbeddedCurveScalar, multi_scalar_mul, fixed_base_scalar_mul}; trait OwnedNote { fn new(amount: U128, owner_npk_m_hash: Field) -> Self; diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index 33a50fb05fd..9dec7c62a22 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -1,7 +1,10 @@ use dep::aztec::prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext}; use dep::aztec::{ note::utils::compute_note_hash_for_consumption, keys::getters::get_nsk_app, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash} + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +} }; global PUBLIC_KEY_NOTE_LEN: Field = 3; diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr index d316d870f4d..9c98a4e620a 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr @@ -1,5 +1,5 @@ use dep::authwit::auth_witness; -use dep::aztec::{protocol_types::{address::PartialAddress, grumpkin_point::GrumpkinPoint}, keys::PublicKeys}; +use dep::aztec::{protocol_types::{address::PartialAddress, embedded_curve_point::EmbeddedCurvePoint}, keys::PublicKeys}; struct AuthWitness { keys: PublicKeys, @@ -15,10 +15,10 @@ impl AuthWitness { } Self { keys: PublicKeys { - npk_m: GrumpkinPoint::new(values[0], values[1]), - ivpk_m: GrumpkinPoint::new(values[2], values[3]), - ovpk_m: GrumpkinPoint::new(values[4], values[5]), - tpk_m: GrumpkinPoint::new(values[6], values[7]) + npk_m: EmbeddedCurvePoint::new(values[0], values[1]), + ivpk_m: EmbeddedCurvePoint::new(values[2], values[3]), + ovpk_m: EmbeddedCurvePoint::new(values[4], values[5]), + tpk_m: EmbeddedCurvePoint::new(values[6], values[7]) }, signature, partial_address: PartialAddress::from_field(values[72]) diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index fbf10bc1806..29ad9f01276 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -13,7 +13,7 @@ contract Test { use dep::aztec::protocol_types::{ abis::private_circuit_public_inputs::PrivateCircuitPublicInputs, constants::{MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, CANONICAL_KEY_REGISTRY_ADDRESS}, - traits::{Serialize, ToField, FromField}, grumpkin_point::GrumpkinPoint, + traits::{Serialize, ToField, FromField}, embedded_curve_point::EmbeddedCurvePoint, grumpkin_private_key::GrumpkinPrivateKey, storage::map::derive_storage_slot_in_map }; @@ -404,7 +404,10 @@ contract Test { } #[aztec(private)] - fn compute_note_header_ciphertext(secret: GrumpkinPrivateKey, point: GrumpkinPoint) -> [u8; 48] { + fn compute_note_header_ciphertext( + secret: GrumpkinPrivateKey, + point: EmbeddedCurvePoint + ) -> [u8; 48] { EncryptedLogHeader::new(context.this_address()).compute_ciphertext(secret, point) } @@ -412,7 +415,7 @@ contract Test { #[aztec(private)] fn compute_incoming_log_body_ciphertext( secret: GrumpkinPrivateKey, - point: GrumpkinPoint, + point: EmbeddedCurvePoint, storage_slot: Field, value: Field ) -> [u8; 112] { @@ -424,7 +427,7 @@ contract Test { fn compute_outgoing_log_body_ciphertext( eph_sk: GrumpkinPrivateKey, recipient: AztecAddress, - recipient_ivpk_app: GrumpkinPoint, + recipient_ivpk_app: EmbeddedCurvePoint, ovsk_app: GrumpkinPrivateKey ) -> [u8; 176] { let eph_pk = eph_sk.derive_public_key(); @@ -519,7 +522,10 @@ contract Test { } #[aztec(private)] - fn test_nullifier_key_freshness(address: AztecAddress, public_nullifying_key: GrumpkinPoint) { + fn test_nullifier_key_freshness( + address: AztecAddress, + public_nullifying_key: EmbeddedCurvePoint + ) { assert_eq(context.get_header().get_npk_m(&mut context, address), public_nullifying_key); } diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr index 5fc660079a4..afd69ccd769 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr @@ -1,6 +1,6 @@ use dep::aztec::{ note::{note_header::NoteHeader, note_interface::NoteInterface}, hash::pedersen_hash, - context::PrivateContext, protocol_types::grumpkin_point::GrumpkinPoint + context::PrivateContext, protocol_types::embedded_curve_point::EmbeddedCurvePoint }; global TEST_NOTE_LEN: Field = 1; diff --git a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr index 46489bf2b5c..91ae1b08364 100644 --- a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr @@ -1,8 +1,8 @@ contract TestLog { use dep::aztec::prelude::PrivateSet; use dep::aztec::protocol_types::{ - traits::Serialize, grumpkin_point::GrumpkinPoint, grumpkin_private_key::GrumpkinPrivateKey, - address::AztecAddress + traits::Serialize, embedded_curve_point::EmbeddedCurvePoint, + grumpkin_private_key::GrumpkinPrivateKey, address::AztecAddress }; use dep::value_note::value_note::ValueNote; use dep::aztec::encrypted_logs::incoming_body::EncryptedLogIncomingBody; @@ -33,7 +33,7 @@ contract TestLog { #[aztec(private)] fn compute_incoming_log_body_ciphertext( secret: GrumpkinPrivateKey, - point: GrumpkinPoint, + point: EmbeddedCurvePoint, randomness: Field, event_type_id: Field, preimage: [Field; 2] diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index e3919f717d3..602f8a0957c 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -1,6 +1,9 @@ use dep::aztec::{ prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash}, + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +}, note::utils::compute_note_hash_for_consumption, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app }; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 1eada65f821..06843604b25 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -2,7 +2,10 @@ use dep::aztec::{ note::{note_getter_options::PropertySelector, utils::compute_note_hash_for_consumption}, prelude::{NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash} + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +} }; global TRANSPARENT_NOTE_LEN: Field = 2; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr index e3919f717d3..602f8a0957c 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -1,6 +1,9 @@ use dep::aztec::{ prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash}, + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +}, note::utils::compute_note_hash_for_consumption, oracle::unsafe_rand::unsafe_rand, keys::getters::get_nsk_app }; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index 1eada65f821..06843604b25 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -2,7 +2,10 @@ use dep::aztec::{ note::{note_getter_options::PropertySelector, utils::compute_note_hash_for_consumption}, prelude::{NoteHeader, NoteInterface, PrivateContext}, - protocol_types::{constants::GENERATOR_INDEX__NOTE_NULLIFIER, grumpkin_point::GrumpkinPoint, hash::poseidon2_hash} + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, embedded_curve_point::EmbeddedCurvePoint, + hash::poseidon2_hash +} }; global TRANSPARENT_NOTE_LEN: Field = 2; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr index 02af30ae549..4a420ba0584 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr @@ -107,7 +107,7 @@ mod tests { }, address::AztecAddress, grumpkin_private_key::GrumpkinPrivateKey, tests::{fixture_builder::FixtureBuilder}, utils::{arrays::{array_eq, array_length}}, - traits::{Empty, is_empty, is_empty_array}, grumpkin_point::GrumpkinPoint + traits::{Empty, is_empty, is_empty_array}, embedded_curve_point::EmbeddedCurvePoint }; struct PrivateKernelResetInputsBuilder { @@ -283,7 +283,7 @@ mod tests { let remaining_nullifier_rr_index = builder.previous_kernel.add_read_request_for_pending_nullifier(1); let nullifier_rr = builder.previous_kernel.nullifier_read_requests.storage[remaining_nullifier_rr_index]; - let key_validation_index = builder.previous_kernel.add_request_for_key_validation(GrumpkinPoint::new(1, 2), 27, GENERATOR_INDEX__OVSK_M); + let key_validation_index = builder.previous_kernel.add_request_for_key_validation(EmbeddedCurvePoint::new(1, 2), 27, GENERATOR_INDEX__OVSK_M); let key_validation = builder.previous_kernel.scoped_key_validation_requests_and_generators.storage[key_validation_index]; // Check that they have been propagated to the next kernel diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr index 496be7841d0..1a982954d0a 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr @@ -50,7 +50,7 @@ mod tests { compute_siloed_unencrypted_log_hash }, tests::fixture_builder::FixtureBuilder, utils::{arrays::array_length}, - traits::{Empty, is_empty}, grumpkin_point::GrumpkinPoint + traits::{Empty, is_empty}, embedded_curve_point::EmbeddedCurvePoint }; // TODO: Reduce the duplicated code/tests for PrivateKernelTailInputs and PrivateKernelTailToPublicInputs. @@ -316,7 +316,11 @@ mod tests { #[test(should_fail_with="Non empty key validation requests")] fn non_empty_key_validations() { let mut builder = PrivateKernelTailInputsBuilder::new(); - let _void = builder.previous_kernel.add_request_for_key_validation(GrumpkinPoint::new(1, 2), 27, GENERATOR_INDEX__IVSK_M); + let _void = builder.previous_kernel.add_request_for_key_validation( + EmbeddedCurvePoint::new(1, 2, false), + 27, + GENERATOR_INDEX__IVSK_M + ); builder.failed(); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr index fe914554ef0..a7e32593a24 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr @@ -47,7 +47,8 @@ mod tests { log_hash::{LogHash, NoteLogHash} }, address::{AztecAddress, EthAddress}, hash::{silo_note_hash, silo_nullifier}, - tests::fixture_builder::FixtureBuilder, utils::{arrays::array_eq}, grumpkin_point::GrumpkinPoint + tests::fixture_builder::FixtureBuilder, utils::{arrays::array_eq}, + embedded_curve_point::EmbeddedCurvePoint }; // TODO: Reduce the duplicated code/tests for PrivateKernelTailToPublicInputs and PrivateKernelTailInputs. @@ -299,7 +300,7 @@ mod tests { #[test(should_fail_with="Non empty key validation requests")] fn non_empty_key_validations() { let mut builder = PrivateKernelTailToPublicInputsBuilder::new(); - let _void = builder.previous_kernel.add_request_for_key_validation(GrumpkinPoint::new(1, 2), 27, GENERATOR_INDEX__TSK_M); + let _void = builder.previous_kernel.add_request_for_key_validation(EmbeddedCurvePoint::new(1, 2), 27, GENERATOR_INDEX__TSK_M); builder.failed(); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr index a54a78a2f79..2768cd18311 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr @@ -1,10 +1,10 @@ use crate::{ constants::KEY_VALIDATION_REQUEST_LENGTH, traits::{Empty, Serialize, Deserialize}, - grumpkin_point::GrumpkinPoint + embedded_curve_point::EmbeddedCurvePoint }; struct KeyValidationRequest { - pk_m: GrumpkinPoint, + pk_m: EmbeddedCurvePoint, sk_app: Field, // not a grumpkin scalar because it's output of poseidon2 } @@ -18,7 +18,7 @@ impl Eq for KeyValidationRequest { impl Empty for KeyValidationRequest { fn empty() -> Self { KeyValidationRequest { - pk_m: GrumpkinPoint::zero(), + pk_m: EmbeddedCurvePoint::point_at_infinity(), sk_app: 0, } } @@ -37,7 +37,7 @@ impl Serialize for KeyValidationRequest { impl Deserialize for KeyValidationRequest { fn deserialize(fields: [Field; KEY_VALIDATION_REQUEST_LENGTH]) -> Self { Self { - pk_m: GrumpkinPoint::new(fields[0], fields[1]), + pk_m: EmbeddedCurvePoint::new(fields[0], fields[1], false), sk_app: fields[2], } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr index 6c91a609990..d2847dbeaf9 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr @@ -1,7 +1,7 @@ use crate::{ crate::address::{eth_address::EthAddress, partial_address::PartialAddress, public_keys_hash::PublicKeysHash}, constants::{AZTEC_ADDRESS_LENGTH, GENERATOR_INDEX__CONTRACT_ADDRESS_V1}, - contract_class_id::ContractClassId, hash::poseidon2_hash, grumpkin_point::GrumpkinPoint, + contract_class_id::ContractClassId, hash::poseidon2_hash, traits::{Empty, FromField, ToField, Serialize, Deserialize}, utils }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/embedded_curve_point.nr b/noir-projects/noir-protocol-circuits/crates/types/src/embedded_curve_point.nr new file mode 100644 index 00000000000..0e393d89cca --- /dev/null +++ b/noir-projects/noir-protocol-circuits/crates/types/src/embedded_curve_point.nr @@ -0,0 +1,16 @@ +use dep::std::embedded_curve_ops::EmbeddedCurvePoint; +use crate::{traits::{Serialize, Hash}, hash::poseidon2_hash}; + +global EMBEDDED_CURVE_POINT_LENGTH: Field = 3; + +impl Serialize for EmbeddedCurvePoint { + fn serialize(self: Self) -> [Field; EMBEDDED_CURVE_POINT_LENGTH] { + [self.x, self.y, self.is_infinite as Field] + } +} + +impl Hash for EmbeddedCurvePoint { + fn hash(self) -> Field { + poseidon2_hash(self.serialize()) + } +} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_point.nr b/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_point.nr deleted file mode 100644 index a996a0df6fe..00000000000 --- a/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_point.nr +++ /dev/null @@ -1,79 +0,0 @@ -use crate::{traits::{Serialize, Deserialize, Hash, Empty}, hash::poseidon2_hash}; - -global GRUMPKIN_POINT_SERIALIZED_LEN: Field = 2; - -// TODO(https://github.com/noir-lang/noir/issues/4931) -struct GrumpkinPoint { - x: Field, - y: Field, -} - -impl Serialize for GrumpkinPoint { - fn serialize(self) -> [Field; GRUMPKIN_POINT_SERIALIZED_LEN] { - [self.x, self.y] - } -} - -impl Deserialize for GrumpkinPoint { - fn deserialize(serialized: [Field; GRUMPKIN_POINT_SERIALIZED_LEN]) -> Self { - Self { - x: serialized[0], - y: serialized[1], - } - } -} - -impl Eq for GrumpkinPoint { - fn eq(self, point: GrumpkinPoint) -> bool { - (point.x == self.x) & (point.y == self.y) - } -} - -impl Hash for GrumpkinPoint { - fn hash(self) -> Field { - poseidon2_hash(self.serialize()) - } -} - -impl Empty for GrumpkinPoint { - fn empty() -> Self { - GrumpkinPoint { - x: 0, - y: 0 - } - } -} - -impl GrumpkinPoint { - pub fn new(x: Field, y: Field) -> Self { - Self { x, y } - } - - pub fn zero() -> Self { - Self { x: 0, y: 0 } - } - - pub fn is_zero(self) -> bool { - (self.x == 0) & (self.y == 0) - } - - // TODO(David): Would be quite careful here as (0,0) is not a point - // on the curve. A boolean flag may be the better approach here, - // would also cost less constraints. It seems like we don't need to - // group arithmetic either. - fn assert_is_zero(self) { - assert(self.x == 0); - assert(self.y == 0); - } - - pub fn to_be_bytes(self: Self) -> [u8; 64] { - let mut result = [0 as u8; 64]; - let x_bytes = self.x.to_be_bytes(32); - let y_bytes = self.y.to_be_bytes(32); - for i in 0..32 { - result[i] = x_bytes[i]; - result[i + 32] = y_bytes[i]; - } - result - } -} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr b/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr index f00d3d8ddf1..7be718512e4 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr @@ -1,5 +1,5 @@ use std::{cmp::Eq, embedded_curve_ops::fixed_base_scalar_mul}; -use crate::{grumpkin_point::GrumpkinPoint, traits::Empty}; +use crate::{embedded_curve_point::EmbeddedCurvePoint, traits::Empty}; global GRUMPKIN_PRIVATE_KEY_SERIALIZED_LEN: Field = 2; @@ -37,8 +37,8 @@ impl GrumpkinPrivateKey { [self.high, self.low] } - pub fn derive_public_key(self) -> GrumpkinPoint { + pub fn derive_public_key(self) -> EmbeddedCurvePoint { let public_key = fixed_base_scalar_mul(self.low, self.high); - GrumpkinPoint { x: public_key[0], y: public_key[1] } + EmbeddedCurvePoint { x: public_key[0], y: public_key[1], is_infinite: false } } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr b/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr index d7d84cb6b27..a967a7e7242 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr @@ -1,7 +1,7 @@ mod utils; mod address; mod debug_log; -mod grumpkin_point; +mod embedded_curve_point; mod grumpkin_private_key; // This is intentionally spelled like this // since contract is a reserved keyword, so it cannot diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr index fa3397e73b4..15cb87af936 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr @@ -41,7 +41,7 @@ use crate::{ partial_state_reference::PartialStateReference, tests::fixtures, transaction::{tx_context::TxContext, tx_request::TxRequest}, traits::Empty, recursion::{verification_key::VerificationKey, proof::{NestedRecursiveProof, RecursiveProof}}, - grumpkin_point::GrumpkinPoint + embedded_curve_point::EmbeddedCurvePoint }; fn subarray(arr: [T; N]) -> [T; M] { @@ -669,7 +669,7 @@ impl FixtureBuilder { new_read_request_index } - pub fn add_request_for_key_validation(&mut self, pk_m: GrumpkinPoint, sk_app: Field, sk_app_generator: Field) -> u32 { + pub fn add_request_for_key_validation(&mut self, pk_m: EmbeddedCurvePoint, sk_app: Field, sk_app_generator: Field) -> u32 { let new_request_index = self.scoped_key_validation_requests_and_generators.len(); let request = KeyValidationRequest { pk_m, sk_app }; let request_and_generator = KeyValidationRequestAndGenerator { request, sk_app_generator }; @@ -948,7 +948,10 @@ impl FixtureBuilder { fn mock_key_validation_request(self, index: u32) -> KeyValidationRequestAndGenerator { let value_offset = 3030 + self.value_offset + index as Field; - let request = KeyValidationRequest { pk_m: GrumpkinPoint { x: value_offset, y: 1 + value_offset }, sk_app: 2 + value_offset }; + let request = KeyValidationRequest { + pk_m: EmbeddedCurvePoint { x: value_offset, y: 1 + value_offset, is_infinite: false }, + sk_app: 2 + value_offset + }; KeyValidationRequestAndGenerator { request, sk_app_generator: 3 + value_offset } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr index d30e18d7056..35cf5b438a0 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr @@ -1,11 +1,11 @@ mod contract_functions; mod contracts; -use crate::{address::AztecAddress, grumpkin_point::GrumpkinPoint}; +use crate::{address::AztecAddress, embedded_curve_point::EmbeddedCurvePoint}; global MSG_SENDER = AztecAddress { inner: 27 }; -global PUBLIC_KEY = GrumpkinPoint { x: 123456789, y: 123456789 }; +global PUBLIC_KEY = EmbeddedCurvePoint { x: 123456789, y: 123456789, is_infinite: false }; global CHAIN_ID = 1; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr index 5d804fa5d0a..23dc96300ab 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr @@ -77,7 +77,8 @@ mod tests { gas::Gas, gas_fees::GasFees }, address::{AztecAddress, EthAddress}, contract_class_id::ContractClassId, - grumpkin_point::GrumpkinPoint, transaction::{tx_request::TxRequest, tx_context::TxContext} + embedded_curve_point::EmbeddedCurvePoint, + transaction::{tx_request::TxRequest, tx_context::TxContext} }; #[test] diff --git a/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr b/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr index c5617094c0a..7018f5fdbbd 100644 --- a/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr +++ b/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr @@ -1,7 +1,6 @@ use crate::ops::arith::{Add, Sub, Neg}; use crate::cmp::Eq; -// TODO(https://github.com/noir-lang/noir/issues/4931) struct EmbeddedCurvePoint { x: Field, y: Field, @@ -9,6 +8,10 @@ struct EmbeddedCurvePoint { } impl EmbeddedCurvePoint { + fn new(x: Field, y: Field, is_infinite: bool) -> Self { + Self { x, y, is_infinite } + } + fn double(self) -> EmbeddedCurvePoint { embedded_curve_add(self, self) } @@ -16,6 +19,17 @@ impl EmbeddedCurvePoint { fn point_at_infinity() -> EmbeddedCurvePoint { EmbeddedCurvePoint { x: 0, y: 0, is_infinite: true } } + + pub fn to_be_bytes(self: Self) -> [u8; 64] { + let mut result = [0 as u8; 64]; + let x_bytes = self.x.to_be_bytes(32); + let y_bytes = self.y.to_be_bytes(32); + for i in 0..32 { + result[i] = x_bytes[i]; + result[i + 32] = y_bytes[i]; + } + result + } } impl Add for EmbeddedCurvePoint {