diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr index e98ec81c419..269ce6b3798 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr @@ -5,9 +5,7 @@ use crate::{ side_effect::{SideEffect, SideEffectLinkedToNoteHash}, }, contrakt::deployment_data::ContractDeploymentData, - hash::{ - pedersen_hash, - }, + hash::pedersen_hash, header::Header, }; use crate::constants::{ @@ -23,7 +21,7 @@ use crate::constants::{ PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS, }; -use crate::traits::{Hash, Serialize, Deserialize}; +use crate::traits::{Hash, Serialize}; struct PrivateCircuitPublicInputs { call_context: CallContext, @@ -61,12 +59,6 @@ struct PrivateCircuitPublicInputs { version: Field, } -impl Hash for PrivateCircuitPublicInputs { - fn hash(self) -> Field { - pedersen_hash(self.serialize(), GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS) - } -} - impl Serialize for PrivateCircuitPublicInputs { fn serialize(self) -> [Field; PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH] { let mut fields: BoundedVec = BoundedVec::new(0); @@ -102,6 +94,12 @@ impl Serialize for PrivateCircuitPublicInp } } +impl Hash for PrivateCircuitPublicInputs { + fn hash(self) -> Field { + pedersen_hash(self.serialize(), GENERATOR_INDEX__PRIVATE_CIRCUIT_PUBLIC_INPUTS) + } +} + #[test] fn serialization_smoke() { let pcpi: PrivateCircuitPublicInputs = dep::std::unsafe::zeroed(); diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr index 17acd93180d..138a9d0e17d 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr @@ -23,6 +23,7 @@ use crate::{ hash::pedersen_hash, header::Header, }; +use crate::traits::{Hash, Serialize, Deserialize}; struct PublicCircuitPublicInputs{ call_context: CallContext, @@ -52,8 +53,8 @@ struct PublicCircuitPublicInputs{ prover_address: AztecAddress, } -impl PublicCircuitPublicInputs{ - pub fn serialize(self) -> [Field; PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH] { +impl Serialize for PublicCircuitPublicInputs { + fn serialize(self) -> [Field; PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH] { let mut fields: BoundedVec = BoundedVec::new(0); fields.extend_from_array(self.call_context.serialize()); fields.push(self.args_hash); @@ -79,8 +80,22 @@ impl PublicCircuitPublicInputs{ fields.push(self.prover_address.to_field()); fields.storage } +} - fn hash(self) -> Field { +impl Hash for PublicCircuitPublicInputs { + fn hash(self) -> Field { pedersen_hash(self.serialize(), GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS) } } + +#[test] +fn serialization_smoke() { + let pcpi: PublicCircuitPublicInputs = dep::std::unsafe::zeroed(); + let _serialized = pcpi.serialize(); +} + +#[test] +fn hash_smoke() { + let pcpi: PublicCircuitPublicInputs = dep::std::unsafe::zeroed(); + let _hashed = pcpi.hash(); +}