diff --git a/.aztec-sync-commit b/.aztec-sync-commit index 42ef1037b17..258eb260471 100644 --- a/.aztec-sync-commit +++ b/.aztec-sync-commit @@ -1 +1 @@ -b0d1bab1f02819e7efbe0db73c3c805b5927b66a +670af8a158633d106a3f1df82dbd28ef9a9e4ceb diff --git a/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs b/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs index 38895bb977e..3056fb5973d 100644 --- a/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs +++ b/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use super::FunctionBuilder; -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) enum DatabusVisibility { None, CallData(u32), @@ -214,34 +214,27 @@ impl FunctionBuilder { fn deflatten_databus_visibilities( &self, ssa_params: &[ValueId], - flattened_params_databus_visibility: Vec, + mut flattened_params_databus_visibility: Vec, ) -> Vec { - // To do so, create a vec the size of the flattened arguments where the items are the ssa param index they correspond to - let ssa_param_indices: Vec<_> = ssa_params + let ssa_param_sizes: Vec<_> = ssa_params .iter() - .enumerate() - .flat_map(|(ssa_param_index, ssa_param)| { - let flattened_size = - self.current_function.dfg[*ssa_param].get_type().flattened_size(); - std::iter::repeat(ssa_param_index).take(flattened_size) - }) + .map(|ssa_param| self.current_function.dfg[*ssa_param].get_type().flattened_size()) .collect(); let mut is_ssa_params_databus = Vec::with_capacity(ssa_params.len()); - assert!(flattened_params_databus_visibility.len() == ssa_param_indices.len()); - for (databus_visibility, ssa_index) in - flattened_params_databus_visibility.into_iter().zip(ssa_param_indices) - { - if let Some(previous_databus_visibility) = is_ssa_params_databus.get(ssa_index) { - assert!( - *previous_databus_visibility == databus_visibility, - "inconsistent databus visibility for ssa param" - ); - } else { - assert!(ssa_index == is_ssa_params_databus.len()); - is_ssa_params_databus.push(databus_visibility); - } + for size in ssa_param_sizes { + let visibilities: Vec = + flattened_params_databus_visibility.drain(0..size).collect(); + let visibility = visibilities.get(0).copied().unwrap_or(DatabusVisibility::None); + assert!( + visibilities.iter().all(|v| *v == visibility), + "inconsistent databus visibility for ssa param" + ); + is_ssa_params_databus.push(visibility); } + + assert_eq!(is_ssa_params_databus.len(), ssa_params.len()); + is_ssa_params_databus } } diff --git a/compiler/noirc_frontend/src/tests/unused_items.rs b/compiler/noirc_frontend/src/tests/unused_items.rs index a4d379b6358..4d8e504b705 100644 --- a/compiler/noirc_frontend/src/tests/unused_items.rs +++ b/compiler/noirc_frontend/src/tests/unused_items.rs @@ -188,58 +188,6 @@ fn errors_on_unused_type_alias() { assert_eq!(item.item_type(), "type alias"); } -#[test] -fn errors_if_type_alias_aliases_more_private_type() { - let src = r#" - struct Foo {} - pub type Bar = Foo; - pub fn no_unused_warnings(_b: Bar) { - let _ = Foo {}; - } - fn main() {} - "#; - - let errors = get_program_errors(src); - assert_eq!(errors.len(), 1); - - let CompilationError::ResolverError(ResolverError::TypeIsMorePrivateThenItem { - typ, item, .. - }) = &errors[0].0 - else { - panic!("Expected an unused item error"); - }; - - assert_eq!(typ, "Foo"); - assert_eq!(item, "Bar"); -} - -#[test] -fn errors_if_type_alias_aliases_more_private_type_in_generic() { - let src = r#" - pub struct Generic { value: T } - struct Foo {} - pub type Bar = Generic; - pub fn no_unused_warnings(_b: Bar) { - let _ = Foo {}; - let _ = Generic { value: 1 }; - } - fn main() {} - "#; - - let errors = get_program_errors(src); - assert_eq!(errors.len(), 1); - - let CompilationError::ResolverError(ResolverError::TypeIsMorePrivateThenItem { - typ, item, .. - }) = &errors[0].0 - else { - panic!("Expected an unused item error"); - }; - - assert_eq!(typ, "Foo"); - assert_eq!(item, "Bar"); -} - #[test] fn warns_on_unused_global() { let src = r#" diff --git a/compiler/noirc_frontend/src/tests/visibility.rs b/compiler/noirc_frontend/src/tests/visibility.rs index e6c2680ea19..bca1c9af829 100644 --- a/compiler/noirc_frontend/src/tests/visibility.rs +++ b/compiler/noirc_frontend/src/tests/visibility.rs @@ -28,17 +28,14 @@ fn errors_once_on_unused_import_that_is_not_accessible() { )) )); } - #[test] fn errors_if_type_alias_aliases_more_private_type() { let src = r#" struct Foo {} pub type Bar = Foo; - pub fn no_unused_warnings(_b: Bar) { let _ = Foo {}; } - fn main() {} "#; @@ -60,15 +57,12 @@ fn errors_if_type_alias_aliases_more_private_type() { fn errors_if_type_alias_aliases_more_private_type_in_generic() { let src = r#" pub struct Generic { value: T } - struct Foo {} pub type Bar = Generic; - pub fn no_unused_warnings(_b: Bar) { let _ = Foo {}; let _ = Generic { value: 1 }; } - fn main() {} "#; diff --git a/noir_stdlib/src/hash/mod.nr b/noir_stdlib/src/hash/mod.nr index 1b37a07f6c9..e8c0ce81a16 100644 --- a/noir_stdlib/src/hash/mod.nr +++ b/noir_stdlib/src/hash/mod.nr @@ -33,7 +33,7 @@ pub fn pedersen_commitment(input: [Field; N]) -> EmbeddedCurvePoint } pub fn pedersen_hash_with_separator(input: [Field; N], separator: u32) -> Field { - __pedersen_hash_with_separator(input, separator) + pedersen_hash_with_separator_noir(input, separator) } pub fn pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> EmbeddedCurvePoint { @@ -78,7 +78,7 @@ fn pedersen_hash_with_separator_noir(input: [Field; N], separator: u pub fn pedersen_hash(input: [Field; N]) -> Field // docs:end:pedersen_hash { - __pedersen_hash_with_separator(input, 0) + pedersen_hash_with_separator_noir(input, 0) } #[foreign(pedersen_hash)] diff --git a/test_programs/execution_success/aes128_encrypt/src/main.nr b/test_programs/execution_success/aes128_encrypt/src/main.nr index b937c801860..31d907fea10 100644 --- a/test_programs/execution_success/aes128_encrypt/src/main.nr +++ b/test_programs/execution_success/aes128_encrypt/src/main.nr @@ -21,29 +21,20 @@ unconstrained fn decode_hex(s: str) -> [u8; M] { } unconstrained fn cipher(plaintext: [u8; 12], iv: [u8; 16], key: [u8; 16]) -> [u8; 16] { - let slice_res = std::aes128::aes128_encrypt(plaintext, iv, key); - let mut result = [0; 16]; - for i in 0..16 { - result[i] = slice_res[i]; - } - result + let result = std::aes128::aes128_encrypt(plaintext, iv, key); + result.as_array() } fn main(inputs: str<12>, iv: str<16>, key: str<16>, output: str<32>) { - let result = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); + let result: [u8; 16] = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()).as_array(); let output_bytes: [u8; 16] = unsafe { - let output_bytes: [u8; 16] = decode_hex(output); - for i in 0..16 { - assert(result[i] == output_bytes[i]); - } - output_bytes + decode_hex(output) }; + assert(result == output_bytes); - unsafe { - let unconstrained_result = cipher(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); - for i in 0..16 { - assert(unconstrained_result[i] == output_bytes[i]); - } - } + let unconstrained_result = unsafe { + cipher(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()) + }; + assert(unconstrained_result == output_bytes); } diff --git a/test_programs/execution_success/databus_in_fn_with_empty_arr/Nargo.toml b/test_programs/execution_success/databus_in_fn_with_empty_arr/Nargo.toml new file mode 100644 index 00000000000..7c5caf7c771 --- /dev/null +++ b/test_programs/execution_success/databus_in_fn_with_empty_arr/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "databus_in_fn_with_empty_arr" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/execution_success/databus_in_fn_with_empty_arr/Prover.toml b/test_programs/execution_success/databus_in_fn_with_empty_arr/Prover.toml new file mode 100644 index 00000000000..e84e0dd7eec --- /dev/null +++ b/test_programs/execution_success/databus_in_fn_with_empty_arr/Prover.toml @@ -0,0 +1,3 @@ +_empty = [] +value_1 = "1" +value_2 = "2" diff --git a/test_programs/execution_success/databus_in_fn_with_empty_arr/src/main.nr b/test_programs/execution_success/databus_in_fn_with_empty_arr/src/main.nr new file mode 100644 index 00000000000..85671978a33 --- /dev/null +++ b/test_programs/execution_success/databus_in_fn_with_empty_arr/src/main.nr @@ -0,0 +1,3 @@ +fn main(_empty: [u32; 0], value_1: u32, value_2: call_data(0) u32) { + assert_eq(value_1 + 1, value_2); +} diff --git a/tooling/nargo_fmt/src/visitor/item.rs b/tooling/nargo_fmt/src/visitor/item.rs index 12ace814369..b71ea801752 100644 --- a/tooling/nargo_fmt/src/visitor/item.rs +++ b/tooling/nargo_fmt/src/visitor/item.rs @@ -276,6 +276,7 @@ impl super::FmtVisitor<'_> { self.push_rewrite(use_tree, span); self.last_position = span.end(); } + ItemKind::Struct(_) | ItemKind::Trait(_) | ItemKind::TypeAlias(_) diff --git a/tooling/noir_js_backend_barretenberg/src/backend.ts b/tooling/noir_js_backend_barretenberg/src/backend.ts index 2569c7d868d..785b0c73421 100644 --- a/tooling/noir_js_backend_barretenberg/src/backend.ts +++ b/tooling/noir_js_backend_barretenberg/src/backend.ts @@ -96,6 +96,7 @@ export class UltraHonkBackend implements Backend, VerifierBackend { async generateProof(compressedWitness: Uint8Array): Promise { const proofWithPublicInputs = await this.backend.generateProof(gunzip(compressedWitness)); + const proofAsStrings = deflattenFields(proofWithPublicInputs.slice(4)); const numPublicInputs = Number(proofAsStrings[1]); @@ -121,7 +122,6 @@ export class UltraHonkBackend implements Backend, VerifierBackend { async verifyProof(proofData: ProofData): Promise { const proof = reconstructProofWithPublicInputsHonk(proofData); - return this.backend.verifyProof(proof); }