Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 8, 2024
1 parent 6f02827 commit fff9108
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
6 changes: 2 additions & 4 deletions yarn-project/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::{
context::inputs::PrivateContextInputs,
key::nullifier_key::validate_nullifier_key_against_address,
messaging::{
process_l1_to_l2_message,
l2_to_l1_message::L2ToL1Message,
},
messaging::process_l1_to_l2_message,
oracle::{
arguments,
call_private_function::call_private_function_internal,
Expand Down Expand Up @@ -50,6 +47,7 @@ use dep::protocol_types::{
grumpkin_private_key::GrumpkinPrivateKey,
hash::hash_args,
header::Header,
messaging::l2_to_l1_message::L2ToL1Message,
utils::reader::Reader,
};
use dep::std::option::Option;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ impl Serialize<PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH> for PrivateCircuitPublicInp
}
fields.extend_from_array(self.private_call_stack_hashes);
fields.extend_from_array(self.public_call_stack_hashes);
fields.extend_from_array(self.new_l2_to_l1_msgs);
for i in 0..MAX_NEW_L2_TO_L1_MSGS_PER_CALL {
fields.extend_from_array(self.new_l2_to_l1_msgs[i].serialize());
}
fields.push(self.end_side_effect_counter as Field);
fields.extend_from_array(self.encrypted_logs_hash);
fields.extend_from_array(self.unencrypted_logs_hash);
Expand Down Expand Up @@ -149,7 +151,7 @@ impl Deserialize<PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH> for PrivateCircuitPublicI
new_nullifiers: reader.read_struct_array(SideEffectLinkedToNoteHash::deserialize, [SideEffectLinkedToNoteHash::empty(); MAX_NEW_NULLIFIERS_PER_CALL]),
private_call_stack_hashes: reader.read_array([0; MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL]),
public_call_stack_hashes: reader.read_array([0; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL]),
new_l2_to_l1_msgs: reader.read_array([0; MAX_NEW_L2_TO_L1_MSGS_PER_CALL]),
new_l2_to_l1_msgs: reader.read_struct_array(L2ToL1Message::deserialize, [L2ToL1Message::empty(); MAX_NEW_L2_TO_L1_MSGS_PER_CALL]),
end_side_effect_counter: reader.read() as u32,
encrypted_logs_hash: reader.read_array([0; NUM_FIELDS_PER_SHA256]),
unencrypted_logs_hash: reader.read_array([0; NUM_FIELDS_PER_SHA256]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{
address::EthAddress,
traits::Empty,
traits::{Deserialize, Empty, Serialize},
};

global L2_TO_L1_MESSAGE_LENGTH: Field = 2;

struct L2ToL1Message {
recipient: EthAddress,
content: Field,
Expand All @@ -22,3 +24,18 @@ impl Eq for L2ToL1Message {
(self.recipient == other.recipient) & (self.content == other.content)
}
}

impl Serialize<L2_TO_L1_MESSAGE_LENGTH> for L2ToL1Message {
fn serialize(self) -> [Field; L2_TO_L1_MESSAGE_LENGTH] {
[self.recipient.to_field(), self.content]
}
}

impl Deserialize<L2_TO_L1_MESSAGE_LENGTH> for L2ToL1Message {
fn deserialize(values: [Field; L2_TO_L1_MESSAGE_LENGTH]) -> Self {
Self {
recipient: EthAddress::from_field(values[0]),
content: values[1],
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
contrakt::deployment_data::ContractDeploymentData,
hash::{compute_constructor_hash, hash_args},
header::Header,
messaging::l2_to_l1_message::L2ToL1Message,
tests::{
fixtures,
testing_harness::build_contract_deployment_data,
Expand Down Expand Up @@ -42,7 +43,7 @@ struct PrivateCircuitPublicInputsBuilder {

private_call_stack_hashes: BoundedVec<Field, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL>,
public_call_stack_hashes: BoundedVec<Field, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>,
new_l2_to_l1_msgs: BoundedVec<Field, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,
new_l2_to_l1_msgs: BoundedVec<L2ToL1Message, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,

encrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256],
unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256],
Expand Down

0 comments on commit fff9108

Please sign in to comment.