From a5a66c191133c9c323d3350f3ea4d1e89115bccc Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:34:08 +0000 Subject: [PATCH 1/3] fix: avoid testing equality between unit values `a_val.sort()` returns `()` so this equality will always succeed --- crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 430d1180b6e..22aa76ff3e9 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -166,7 +166,9 @@ mod test { b_val.push(solved_witness[&b_wit[i]]); } // ensure the outputs are a permutation of the inputs - assert_eq!(a_val.sort(), b_val.sort()); + a_val.sort(); + b_val.sort(); + assert_eq!(a_val, b_val); } } } From f1c4502a926ab0248628905529f9f6d8f8b342de Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:39:34 +0000 Subject: [PATCH 2/3] chore: apply spellcheck fixes in sort.rs --- .../noirc_evaluator/src/ssa/acir_gen/operations/sort.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 22aa76ff3e9..12b77b55a56 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -20,7 +20,7 @@ pub fn evaluate_permutation( evaluator: &mut Evaluator, ) -> Vec { let (w, b) = permutation_layer(in_expr, evaluator); - // we contrain the network output to out_expr + // we constrain the network output to out_expr for (b, o) in b.iter().zip(out_expr) { evaluator.opcodes.push(AcirOpcode::Arithmetic(subtract(b, FieldElement::one(), o))); } @@ -45,7 +45,7 @@ pub fn permutation_layer( conf.push(evaluator.add_witness_to_cs()); } // compute expressions after the input switches - // If inputs are a1,a2, and the switch value is c, then we compute expresions b1,b2 where + // If inputs are a1,a2, and the switch value is c, then we compute expressions b1,b2 where // b1 = a1+q, b2 = a2-q, q = c(a2-a1) let mut in_sub1 = Vec::new(); let mut in_sub2 = Vec::new(); @@ -68,7 +68,7 @@ pub fn permutation_layer( // compute results for the sub networks let (w1, b1) = permutation_layer(&in_sub1, evaluator); let (w2, b2) = permutation_layer(&in_sub2, evaluator); - // apply the output swithces + // apply the output switches for i in 0..(n - 1) / 2 { let c = evaluator.add_witness_to_cs(); conf.push(c); @@ -152,7 +152,7 @@ mod test { for _i in 0..w.len() { c.push(rng.next_u32() % 2 != 0); } - // intialise bits + // intialize bits for i in 0..w.len() { solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); } From ad57c2ddcf7d97bd7f0dbe278e2e1e79f9a553b0 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 15 Feb 2023 15:31:24 +0000 Subject: [PATCH 3/3] Update crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs Co-authored-by: Blaine Bublitz --- crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 12b77b55a56..ff42c1307e8 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -152,7 +152,7 @@ mod test { for _i in 0..w.len() { c.push(rng.next_u32() % 2 != 0); } - // intialize bits + // initialize bits for i in 0..w.len() { solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); }