diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr b/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr index 68300d1fd44..185d82f453f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr @@ -166,19 +166,17 @@ impl Deserialize for i64 { } } -impl Serialize for [T; M] +impl Serialize for [T; N] where - T: Serialize, + T: Serialize, { - let N = M * O; - - fn serialize(self) -> [Field; Self::N] { - let mut result: [Field; Self::N] = std::mem::zeroed(); - let mut serialized: [Field; O] = std::mem::zeroed(); - for i in 0..M { + fn serialize(self) -> [Field; N * M] { + let mut result: [Field; N * M] = std::mem::zeroed(); + let mut serialized: [Field; M] = std::mem::zeroed(); + for i in 0..N { serialized = self[i].serialize(); - for j in 0..O { - result[i * O + j] = serialized[j]; + for j in 0..M { + result[i * M + j] = serialized[j]; } } result