-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: constrain event encryption and unify note and event emit api (#…
- Loading branch information
Showing
30 changed files
with
278 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ mod incoming_body; | |
mod outgoing_body; | ||
mod payload; | ||
mod encrypted_note_emission; | ||
mod encrypted_event_emission; |
45 changes: 45 additions & 0 deletions
45
noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::{ | ||
context::PrivateContext, event::event_interface::EventInterface, | ||
encrypted_logs::payload::compute_encrypted_event_log, oracle::logs_traits::LensForEncryptedEvent | ||
}; | ||
use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint}; | ||
|
||
fn emit_with_keys<Event, NB, MB, OB>( | ||
context: &mut PrivateContext, | ||
randomness: Field, | ||
event: Event, | ||
ovpk: GrumpkinPoint, | ||
ivpk: GrumpkinPoint | ||
) where Event: EventInterface<NB, MB>, [u8; NB]: LensForEncryptedEvent<NB, OB> { | ||
let contract_address: AztecAddress = context.this_address(); | ||
let ovsk_app: Field = context.request_ovsk_app(ovpk.hash()); | ||
|
||
let encrypted_log: [u8; OB] = compute_encrypted_event_log(contract_address, randomness, ovsk_app, ovpk, ivpk, event); | ||
|
||
context.emit_raw_event_log_with_masked_address(randomness, encrypted_log); | ||
} | ||
|
||
pub fn encode_and_encrypt_event<Event, NB, MB, OB>( | ||
context: &mut PrivateContext, | ||
randomness: Field, | ||
ov: AztecAddress, | ||
iv: AztecAddress | ||
) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress, Field)](Event) -> () where Event: EventInterface<NB, MB>, [u8; NB]: LensForEncryptedEvent<NB, OB> { | ||
| e: Event | { | ||
let header = context.get_header(); | ||
let ovpk = header.get_ovpk_m(context, ov); | ||
let ivpk = header.get_ivpk_m(context, iv); | ||
emit_with_keys(context, randomness, e, ovpk, ivpk); | ||
} | ||
} | ||
|
||
pub fn encode_and_encrypt_event_with_keys<Event, NB, MB, OB>( | ||
context: &mut PrivateContext, | ||
randomness: Field, | ||
ovpk: GrumpkinPoint, | ||
ivpk: GrumpkinPoint | ||
) -> fn[(&mut PrivateContext, Field, GrumpkinPoint, GrumpkinPoint)](Event) -> () where Event: EventInterface<NB, MB>, [u8; NB]: LensForEncryptedEvent<NB, OB> { | ||
| e: Event | { | ||
emit_with_keys(context, randomness, e, ovpk, ivpk); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,6 +205,10 @@ mod test { | |
|
||
buffer | ||
} | ||
|
||
fn emit<Env>(self, _emit: fn[Env](Self) -> ()) { | ||
_emit(self); | ||
} | ||
} | ||
|
||
#[test] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.