-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: typing partial address, deduplicating Point
, Point
-> GrumpkinPoint
#3814
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
use crate::types::point::Point; | ||
use dep::protocol_types::{ | ||
address::AztecAddress, | ||
constants::NUM_FIELDS_PER_SHA256, | ||
grumpkin_point::GrumpkinPoint, | ||
}; | ||
|
||
// TODO: Should take encrypted data. | ||
#[oracle(emitEncryptedLog)] | ||
fn emit_encrypted_log_oracle<N>(_contract_address: AztecAddress, _storage_slot: Field, _encryption_pub_key: Point, _preimage: [Field; N]) -> Field {} | ||
fn emit_encrypted_log_oracle<N>( | ||
_contract_address: AztecAddress, | ||
_storage_slot: Field, | ||
_encryption_pub_key: GrumpkinPoint, | ||
_preimage: [Field; N] | ||
) -> Field {} | ||
|
||
unconstrained pub fn emit_encrypted_log<N>(contract_address: AztecAddress, storage_slot: Field, encryption_pub_key: Point, preimage: [Field; N]) -> [Field; NUM_FIELDS_PER_SHA256] { | ||
unconstrained pub fn emit_encrypted_log<N>( | ||
contract_address: AztecAddress, | ||
storage_slot: Field, | ||
encryption_pub_key: GrumpkinPoint, | ||
preimage: [Field; N] | ||
) -> [Field; NUM_FIELDS_PER_SHA256] { | ||
[emit_encrypted_log_oracle(contract_address, storage_slot, encryption_pub_key, preimage), 0] | ||
} | ||
|
||
#[oracle(emitUnencryptedLog)] | ||
fn emit_unencrypted_log_oracle<T>(_contract_address: AztecAddress, _event_selector: Field, _message: T) -> Field {} | ||
|
||
unconstrained pub fn emit_unencrypted_log<T>(contract_address: AztecAddress, event_selector: Field, message: T) -> [Field; NUM_FIELDS_PER_SHA256] { | ||
unconstrained pub fn emit_unencrypted_log<T>( | ||
contract_address: AztecAddress, | ||
event_selector: Field, | ||
message: T | ||
) -> [Field; NUM_FIELDS_PER_SHA256] { | ||
// https://github.com/AztecProtocol/aztec-packages/issues/885 | ||
[emit_unencrypted_log_oracle(contract_address, event_selector, message), 0] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
mod point; | ||
mod vec; // This can/should be moved out into an official noir library | ||
mod type_serialization; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
use crate::point::Point; | ||
use crate::address::AztecAddress; | ||
use crate::hash::{compute_partial_address,compute_contract_address_from_partial}; | ||
use crate::{ | ||
address::{ | ||
AztecAddress, | ||
PartialAddress, | ||
}, | ||
grumpkin_point::GrumpkinPoint, | ||
}; | ||
|
||
struct CompleteAddress{ | ||
struct CompleteAddress { | ||
address : AztecAddress, | ||
public_key : Point, | ||
// TODO(David): Can we type this as AztecAddress instead of Field? | ||
partial_address: Field, | ||
public_key : GrumpkinPoint, | ||
partial_address: PartialAddress, | ||
} | ||
|
||
impl CompleteAddress{ | ||
fn assert_is_zero(self) { | ||
self.address.assert_is_zero(); | ||
self.public_key.assert_is_zero(); | ||
assert(self.partial_address == 0); | ||
self.partial_address.assert_is_zero(); | ||
} | ||
|
||
pub fn compute(point : Point, contract_address_salt : Field, function_tree_root : Field, constructor_hash : Field) -> CompleteAddress { | ||
let partial_address = compute_partial_address(contract_address_salt, function_tree_root, constructor_hash); | ||
pub fn compute(point : GrumpkinPoint, contract_address_salt : Field, function_tree_root : Field, constructor_hash : Field) -> CompleteAddress { | ||
let partial_address = PartialAddress::compute(contract_address_salt, function_tree_root, constructor_hash); | ||
|
||
CompleteAddress{ | ||
address : compute_contract_address_from_partial(point, partial_address), | ||
address : AztecAddress::compute(point, partial_address), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, addressed in 10dcf22 |
||
public_key : point, | ||
partial_address, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.