From ee70cc41ca3babb22d27f1e1e3742d6851c95065 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Wed, 29 Nov 2023 14:29:23 +0000 Subject: [PATCH 01/19] allow lowercase field type --- compiler/noirc_frontend/src/lexer/token.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index b16de42c0ba..c7253d6274a 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -692,7 +692,7 @@ impl fmt::Display for Keyword { Keyword::Dep => write!(f, "dep"), Keyword::Distinct => write!(f, "distinct"), Keyword::Else => write!(f, "else"), - Keyword::Field => write!(f, "Field"), + Keyword::Field => write!(f, "field"), Keyword::Fn => write!(f, "fn"), Keyword::For => write!(f, "for"), Keyword::FormatString => write!(f, "fmtstr"), @@ -735,7 +735,11 @@ impl Keyword { "dep" => Keyword::Dep, "distinct" => Keyword::Distinct, "else" => Keyword::Else, + // Currently we allow both uppercase and lowercase + // Fields. This will be used as a transition solution + // where we eventually deprecate the uppercase variant. "Field" => Keyword::Field, + "field" => Keyword::Field, "fn" => Keyword::Fn, "for" => Keyword::For, "fmtstr" => Keyword::FormatString, From 06e5dda44d7b1375431815ab7dc7e3d0d43ee495 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Wed, 29 Nov 2023 15:24:35 +0000 Subject: [PATCH 02/19] change field to field_element --- .../src/{field.nr => field_element.nr} | 22 +++++++++---------- noir_stdlib/src/lib.nr | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) rename noir_stdlib/src/{field.nr => field_element.nr} (83%) diff --git a/noir_stdlib/src/field.nr b/noir_stdlib/src/field_element.nr similarity index 83% rename from noir_stdlib/src/field.nr rename to noir_stdlib/src/field_element.nr index b4cb9b64e3c..d351b73f716 100644 --- a/noir_stdlib/src/field.nr +++ b/noir_stdlib/src/field_element.nr @@ -1,4 +1,4 @@ -impl Field { +impl field { pub fn to_le_bits(self: Self, bit_size: u32) -> [u1] { crate::assert_constant(bit_size); self.__to_le_bits(bit_size) @@ -50,25 +50,25 @@ impl Field { // Returns self to the power of the given exponent value. // Caution: we assume the exponent fits into 32 bits // using a bigger bit size impacts negatively the performance and should be done only if the exponent does not fit in 32 bits - pub fn pow_32(self, exponent: Field) -> Field { - let mut r: Field = 1; + pub fn pow_32(self, exponent: field) -> field { + let mut r: field = 1; let b = exponent.to_le_bits(32); for i in 1..33 { r *= r; - r = (b[32-i] as Field) * (r * self) + (1 - b[32-i] as Field) * r; + r = (b[32-i] as field) * (r * self) + (1 - b[32-i] as field) * r; } r } - // Parity of (prime) Field element, i.e. sgn0(x mod p) = 0 if x ∈ {0, ..., p-1} is even, otherwise sgn0(x mod p) = 1. + // Parity of (prime) field element, i.e. sgn0(x mod p) = 0 if x ∈ {0, ..., p-1} is even, otherwise sgn0(x mod p) = 1. pub fn sgn0(self) -> u1 { self as u1 } } #[builtin(modulus_num_bits)] -pub fn modulus_num_bits() -> Field {} +pub fn modulus_num_bits() -> field {} #[builtin(modulus_be_bits)] pub fn modulus_be_bits() -> [u1] {} @@ -82,15 +82,15 @@ pub fn modulus_be_bytes() -> [u8] {} #[builtin(modulus_le_bytes)] pub fn modulus_le_bytes() -> [u8] {} // Convert a 32 byte array to a field element -pub fn bytes32_to_field(bytes32: [u8; 32]) -> Field { +pub fn bytes32_to_field(bytes32: [u8; 32]) -> field { // Convert it to a field element let mut v = 1; - let mut high = 0 as Field; - let mut low = 0 as Field; + let mut high = 0 as field; + let mut low = 0 as field; for i in 0..16 { - high = high + (bytes32[15 - i] as Field) * v; - low = low + (bytes32[16 + 15 - i] as Field) * v; + high = high + (bytes32[15 - i] as field) * v; + low = low + (bytes32[16 + 15 - i] as field) * v; v = v * 256; } // Abuse that a % p + b % p = (a + b) % p and that low < p diff --git a/noir_stdlib/src/lib.nr b/noir_stdlib/src/lib.nr index 8d878eecbb3..ca5e65dc07f 100644 --- a/noir_stdlib/src/lib.nr +++ b/noir_stdlib/src/lib.nr @@ -11,7 +11,7 @@ mod grumpkin_scalar_mul; mod scalar_mul; mod sha256; mod sha512; -mod field; +mod field_element; mod ec; mod unsafe; mod collections; From 8746c283ca75bf5ac0627eacf8d83b87dab6abba Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 30 Nov 2023 14:39:13 +0000 Subject: [PATCH 03/19] chore: update import of `bytes32_to_field` --- noir_stdlib/src/hash.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir_stdlib/src/hash.nr b/noir_stdlib/src/hash.nr index 157d6518367..3e9cb988467 100644 --- a/noir_stdlib/src/hash.nr +++ b/noir_stdlib/src/hash.nr @@ -42,7 +42,7 @@ pub fn hash_to_field(_input: [Field; N]) -> Field { } let hashed_input = blake2s(inputs_as_bytes); - crate::field::bytes32_to_field(hashed_input) + crate::field_element::bytes32_to_field(hashed_input) } #[foreign(keccak256)] From a9049bd0a53941fea15bc775dad8b477022e46e4 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 30 Nov 2023 14:46:48 +0000 Subject: [PATCH 04/19] chore: fix remaining instances of `crate::field::` --- noir_stdlib/src/ec.nr | 4 ++-- noir_stdlib/src/ec/swcurve.nr | 2 +- noir_stdlib/src/ec/tecurve.nr | 2 +- noir_stdlib/src/hash/poseidon.nr | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/noir_stdlib/src/ec.nr b/noir_stdlib/src/ec.nr index 86fb201408f..be2ba8c1ccf 100644 --- a/noir_stdlib/src/ec.nr +++ b/noir_stdlib/src/ec.nr @@ -153,10 +153,10 @@ pub fn is_square(x: Field) -> bool { v * (v - 1) == 0 } // Power function of two Field arguments of arbitrary size. -// Adapted from std::field::pow_32. +// Adapted from std::field_element::pow_32. pub fn pow(x: Field, y: Field) -> Field { // As in tests with minor modifications - let N_BITS = crate::field::modulus_num_bits(); + let N_BITS = crate::field_element::modulus_num_bits(); let mut r = 1 as Field; let b = y.to_le_bits(N_BITS as u32); diff --git a/noir_stdlib/src/ec/swcurve.nr b/noir_stdlib/src/ec/swcurve.nr index e9b6f661843..299ce52c820 100644 --- a/noir_stdlib/src/ec/swcurve.nr +++ b/noir_stdlib/src/ec/swcurve.nr @@ -339,7 +339,7 @@ mod curvegroup { // Scalar multiplication (p + ... + p n times) pub fn mul(self, n: Field, p: Point) -> Point { - let N_BITS = crate::field::modulus_num_bits(); + let N_BITS = crate::field_element::modulus_num_bits(); // TODO: temporary workaround until issue 1354 is solved let mut n_as_bits: [u1; 254] = [0; 254]; diff --git a/noir_stdlib/src/ec/tecurve.nr b/noir_stdlib/src/ec/tecurve.nr index 849b45ff012..48a8c32b31b 100644 --- a/noir_stdlib/src/ec/tecurve.nr +++ b/noir_stdlib/src/ec/tecurve.nr @@ -346,7 +346,7 @@ mod curvegroup { // Scalar multiplication (p + ... + p n times) pub fn mul(self, n: Field, p: Point) -> Point { - let N_BITS = crate::field::modulus_num_bits(); + let N_BITS = crate::field_element::modulus_num_bits(); // TODO: temporary workaround until issue 1354 is solved let mut n_as_bits: [u1; 254] = [0; 254]; diff --git a/noir_stdlib/src/hash/poseidon.nr b/noir_stdlib/src/hash/poseidon.nr index 3f4de73c0db..755641936b8 100644 --- a/noir_stdlib/src/hash/poseidon.nr +++ b/noir_stdlib/src/hash/poseidon.nr @@ -1,5 +1,5 @@ mod bn254; // Instantiations of Poseidon for prime field of the same order as BN254 -use crate::field::modulus_num_bits; +use crate::field_element::modulus_num_bits; struct PoseidonConfig { t: Field, // Width, i.e. state size From 71abc61e272fb276fe5df9bf6315bd188e937ec2 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 30 Nov 2023 15:01:40 +0000 Subject: [PATCH 05/19] chore: handle `std::field` references --- .../brillig_to_bytes_integration/src/main.nr | 8 ++++---- test_programs/execution_success/modulus/src/main.nr | 10 +++++----- .../execution_success/to_bytes_integration/src/main.nr | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr index e8e5b9db9ca..dad13706ba8 100644 --- a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr @@ -13,15 +13,15 @@ unconstrained fn main(x: Field, _y: Field) { assert(le_byte_array[2] == be_byte_array[28]); let z = 0 - 1; - let p_bytes = std::field::modulus_le_bytes(); + let p_bytes = std::field_element::modulus_le_bytes(); let z_bytes = z.to_le_bytes(32); assert(p_bytes[10] == z_bytes[10]); assert(p_bytes[0] == z_bytes[0] as u8 + 1 as u8); - let p_bits = std::field::modulus_le_bits(); - let z_bits = z.to_le_bits(std::field::modulus_num_bits() as u32); + let p_bits = std::field_element::modulus_le_bits(); + let z_bits = z.to_le_bits(std::field_element::modulus_num_bits() as u32); assert(z_bits[0] == 0); assert(p_bits[100] == z_bits[100]); - _y.to_le_bits(std::field::modulus_num_bits() as u32); + _y.to_le_bits(std::field_element::modulus_num_bits() as u32); } diff --git a/test_programs/execution_success/modulus/src/main.nr b/test_programs/execution_success/modulus/src/main.nr index 35f63fdc8c5..8afe8dc2496 100644 --- a/test_programs/execution_success/modulus/src/main.nr +++ b/test_programs/execution_success/modulus/src/main.nr @@ -1,24 +1,24 @@ use dep::std; fn main(bn254_modulus_be_bytes: [u8; 32], bn254_modulus_be_bits: [u1; 254]) { - let modulus_size = std::field::modulus_num_bits(); + let modulus_size = std::field_element::modulus_num_bits(); // NOTE: The constraints used in this circuit will only work when testing nargo with the plonk bn254 backend assert(modulus_size == 254); - let modulus_be_byte_array = std::field::modulus_be_bytes(); + let modulus_be_byte_array = std::field_element::modulus_be_bytes(); for i in 0..32 { assert(modulus_be_byte_array[i] == bn254_modulus_be_bytes[i]); } - let modulus_le_byte_array = std::field::modulus_le_bytes(); + let modulus_le_byte_array = std::field_element::modulus_le_bytes(); for i in 0..32 { assert(modulus_le_byte_array[i] == bn254_modulus_be_bytes[31 - i]); } - let modulus_be_bits = std::field::modulus_be_bits(); + let modulus_be_bits = std::field_element::modulus_be_bits(); for i in 0..254 { assert(modulus_be_bits[i] == bn254_modulus_be_bits[i]); } - let modulus_le_bits = std::field::modulus_le_bits(); + let modulus_le_bits = std::field_element::modulus_le_bits(); for i in 0..254 { assert(modulus_le_bits[i] == bn254_modulus_be_bits[253 - i]); } diff --git a/test_programs/execution_success/to_bytes_integration/src/main.nr b/test_programs/execution_success/to_bytes_integration/src/main.nr index 3c43caf1806..d6a757c6f55 100644 --- a/test_programs/execution_success/to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/to_bytes_integration/src/main.nr @@ -11,15 +11,15 @@ fn main(x: Field, a: Field) { assert(le_byte_array[2] == be_byte_array[28]); let z = 0 - 1; - let p_bytes = std::field::modulus_le_bytes(); + let p_bytes = std::field_element::modulus_le_bytes(); let z_bytes = z.to_le_bytes(32); assert(p_bytes[10] == z_bytes[10]); assert(p_bytes[0] == z_bytes[0] as u8 + 1 as u8); - let p_bits = std::field::modulus_le_bits(); - let z_bits = z.to_le_bits(std::field::modulus_num_bits() as u32); + let p_bits = std::field_element::modulus_le_bits(); + let z_bits = z.to_le_bits(std::field_element::modulus_num_bits() as u32); assert(z_bits[0] == 0); assert(p_bits[100] == z_bits[100]); - a.to_le_bits(std::field::modulus_num_bits() as u32); + a.to_le_bits(std::field_element::modulus_num_bits() as u32); } From 5fb072ea3498bfa75e303cfb104f668f93fc15a3 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 30 Nov 2023 15:16:12 +0000 Subject: [PATCH 06/19] chore: fix variable name collision with `field` --- .../compile_success_empty/brillig_to_bits/src/main.nr | 6 +++--- test_programs/compile_success_empty/to_bits/src/main.nr | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test_programs/compile_success_empty/brillig_to_bits/src/main.nr b/test_programs/compile_success_empty/brillig_to_bits/src/main.nr index 7ff3d2467b5..7595f1800cf 100644 --- a/test_programs/compile_success_empty/brillig_to_bits/src/main.nr +++ b/test_programs/compile_success_empty/brillig_to_bits/src/main.nr @@ -1,9 +1,9 @@ use dep::std; unconstrained fn main() { - let field = 1000; - let be_bits = field.to_be_bits(16); - let le_bits = field.to_le_bits(16); + let val = 1000; + let be_bits = val.to_be_bits(16); + let le_bits = val.to_le_bits(16); for i in 0..16 { let x = be_bits[i]; diff --git a/test_programs/compile_success_empty/to_bits/src/main.nr b/test_programs/compile_success_empty/to_bits/src/main.nr index 84ace83903a..f4d82e28fbd 100644 --- a/test_programs/compile_success_empty/to_bits/src/main.nr +++ b/test_programs/compile_success_empty/to_bits/src/main.nr @@ -1,7 +1,7 @@ fn main() { - let field = 1000; - let be_bits = field.to_be_bits(16); - let le_bits = field.to_le_bits(16); + let val = 1000; + let be_bits = val.to_be_bits(16); + let le_bits = val.to_le_bits(16); for i in 0..16 { let x = be_bits[i]; From b7d1d822c08869b8afdac8ead0e14cb7c6528050 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 26 Feb 2024 21:10:49 +0000 Subject: [PATCH 07/19] chore: fix tests --- .../compile_success_empty/field_comparisons/src/main.nr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_programs/compile_success_empty/field_comparisons/src/main.nr b/test_programs/compile_success_empty/field_comparisons/src/main.nr index 48cca6c89fc..ed71093698d 100644 --- a/test_programs/compile_success_empty/field_comparisons/src/main.nr +++ b/test_programs/compile_success_empty/field_comparisons/src/main.nr @@ -1,8 +1,8 @@ -use dep::std::field::bn254::{PLO, PHI, TWO_POW_128, decompose, decompose_unsafe, lt_unsafe, lte_unsafe, assert_gt, gt}; +use dep::std::field_element::bn254::{PLO, PHI, TWO_POW_128, decompose, decompose_unsafe, lt_unsafe, lte_unsafe, assert_gt, gt}; fn check_plo_phi() { assert_eq(PLO + PHI * TWO_POW_128, 0); - let p_bytes = dep::std::field::modulus_le_bytes(); + let p_bytes = dep::std::field_element::modulus_le_bytes(); let mut p_low: Field = 0; let mut p_high: Field = 0; From b6689e4c57a16818e6ba36608c2f57099405a3f8 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 26 Feb 2024 21:14:29 +0000 Subject: [PATCH 08/19] feat: format `Field` into `field` --- tooling/nargo_fmt/src/rewrite/expr.rs | 6 +++++- tooling/nargo_fmt/src/rewrite/typ.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tooling/nargo_fmt/src/rewrite/expr.rs b/tooling/nargo_fmt/src/rewrite/expr.rs index 32d104f559b..c3d42fd2b2e 100644 --- a/tooling/nargo_fmt/src/rewrite/expr.rs +++ b/tooling/nargo_fmt/src/rewrite/expr.rs @@ -42,7 +42,11 @@ pub(crate) fn rewrite( format!("{op}{}", rewrite_sub_expr(visitor, shape, prefix.rhs)) } ExpressionKind::Cast(cast) => { - format!("{} as {}", rewrite_sub_expr(visitor, shape, cast.lhs), cast.r#type) + format!( + "{} as {}", + rewrite_sub_expr(visitor, shape, cast.lhs), + super::typ(visitor, Shape::default(), cast.r#type) + ) } kind @ ExpressionKind::Infix(_) => { super::infix(visitor.fork(), Expression { kind, span }, shape) diff --git a/tooling/nargo_fmt/src/rewrite/typ.rs b/tooling/nargo_fmt/src/rewrite/typ.rs index aaa77b0bea5..f027589d24a 100644 --- a/tooling/nargo_fmt/src/rewrite/typ.rs +++ b/tooling/nargo_fmt/src/rewrite/typ.rs @@ -56,8 +56,8 @@ pub(crate) fn rewrite(visitor: &FmtVisitor, _shape: Shape, typ: UnresolvedType) format!("fn{env}({args}) -> {return_type}") } UnresolvedTypeData::Unspecified => todo!(), - UnresolvedTypeData::FieldElement - | UnresolvedTypeData::Integer(_, _) + UnresolvedTypeData::FieldElement => "field".to_owned(), + UnresolvedTypeData::Integer(_, _) | UnresolvedTypeData::Bool | UnresolvedTypeData::Named(_, _, _) | UnresolvedTypeData::Unit From a9f014b50b9f734dae74f0b02f71642020e8a6d8 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 26 Feb 2024 21:49:53 +0000 Subject: [PATCH 09/19] chore: run formatter --- noir_stdlib/src/field_element.nr | 4 +-- noir_stdlib/src/uint128.nr | 6 ++-- .../src/main.nr | 8 +++--- .../closure_explicit_types/src/main.nr | 12 ++++---- .../comptime_recursion_regression/src/main.nr | 2 +- .../conditional_regression_547/src/main.nr | 4 +-- .../generators/src/main.nr | 6 ++-- .../higher_order_fn_selector/src/main.nr | 6 ++-- .../instruction_deduplication/src/main.nr | 2 +- .../intrinsic_die/src/main.nr | 2 +- .../main_return/src/main.nr | 2 +- .../numeric_generics/src/main.nr | 4 +-- .../references_aliasing/src/main.nr | 2 +- .../ret_fn_ret_cl/src/main.nr | 8 +++--- .../simple_array_param/src/main.nr | 2 +- .../simple_program_no_body/src/main.nr | 2 +- .../simple_range/src/main.nr | 2 +- .../specialization/src/main.nr | 4 +-- .../src/main.nr | 2 +- .../trait_default_implementation/src/main.nr | 2 +- .../trait_generics/src/main.nr | 4 +-- .../trait_override_implementation/src/main.nr | 2 +- .../trait_where_clause/src/main.nr | 2 +- .../compile_success_empty/traits/src/main.nr | 2 +- .../unused_variables/src/main.nr | 2 +- .../compile_success_empty/vectors/src/main.nr | 2 +- .../1327_concrete_in_generic/src/main.nr | 6 ++-- .../execution_success/7_function/src/main.nr | 22 +++++++-------- .../arithmetic_binary_operations/src/main.nr | 2 +- .../array_dynamic/src/main.nr | 10 +++---- .../array_dynamic_main_output/src/main.nr | 2 +- .../src/main.nr | 2 +- .../execution_success/array_eq/src/main.nr | 2 +- .../execution_success/array_len/src/main.nr | 6 ++-- .../execution_success/array_neq/src/main.nr | 2 +- .../execution_success/assert/src/main.nr | 2 +- .../assert_statement/src/main.nr | 2 +- .../assert_statement_recursive/src/main.nr | 2 +- .../execution_success/assign_ex/src/main.nr | 2 +- .../execution_success/bit_and/src/main.nr | 2 +- .../brillig_array_eq/src/main.nr | 2 +- .../brillig_arrays/src/main.nr | 6 ++-- .../brillig_assert/src/main.nr | 4 +-- .../brillig_conditional/src/main.nr | 4 +-- .../execution_success/brillig_cow/src/main.nr | 6 ++-- .../brillig_cow_regression/src/main.nr | 6 ++-- .../brillig_hash_to_field/src/main.nr | 4 +-- .../brillig_identity_function/src/main.nr | 6 ++-- .../brillig_keccak/src/main.nr | 2 +- .../brillig_nested_arrays/src/main.nr | 8 +++--- .../execution_success/brillig_not/src/main.nr | 2 +- .../brillig_oracle/src/main.nr | 8 +++--- .../brillig_pedersen/src/main.nr | 2 +- .../brillig_references/src/main.nr | 6 ++-- .../brillig_scalar_mul/src/main.nr | 12 ++++---- .../brillig_schnorr/src/main.nr | 6 ++-- .../brillig_sha256/src/main.nr | 4 +-- .../brillig_slices/src/main.nr | 14 +++++----- .../brillig_to_be_bytes/src/main.nr | 2 +- .../brillig_to_bytes_integration/src/main.nr | 2 +- .../brillig_to_le_bytes/src/main.nr | 2 +- .../brillig_top_level/src/main.nr | 2 +- .../brillig_unitialised_arrays/src/main.nr | 6 ++-- .../execution_success/cast_bool/src/main.nr | 2 +- .../closures_mut_ref/src/main.nr | 2 +- .../conditional_2/src/main.nr | 2 +- .../src/main.nr | 2 +- .../custom_entry/src/foobarbaz.nr | 2 +- .../execution_success/debug_logs/src/main.nr | 2 +- .../diamond_deps_0/src/main.nr | 2 +- .../distinct_keyword/src/main.nr | 2 +- .../double_verify_proof/src/main.nr | 10 +++---- .../execution_success/eddsa/src/main.nr | 2 +- .../execution_success/generics/src/main.nr | 6 ++-- .../global_consts/src/baz.nr | 2 +- .../global_consts/src/foo.nr | 2 +- .../global_consts/src/foo/bar.nr | 2 +- .../global_consts/src/main.nr | 16 +++++------ .../hash_to_field/src/main.nr | 2 +- .../higher_order_functions/src/main.nr | 6 ++-- .../execution_success/import/src/import.nr | 2 +- .../execution_success/import/src/main.nr | 2 +- .../integer_array_indexing/src/main.nr | 2 +- .../execution_success/keccak256/src/main.nr | 2 +- .../merkle_insert/src/main.nr | 14 +++++----- .../missing_closure_env/src/main.nr | 2 +- .../execution_success/mock_oracle/src/main.nr | 2 +- .../execution_success/modules/src/foo.nr | 2 +- .../execution_success/modules/src/main.nr | 2 +- .../execution_success/modules_more/src/foo.nr | 2 +- .../modules_more/src/foo/bar.nr | 2 +- .../modules_more/src/main.nr | 2 +- .../nested_array_dynamic/src/main.nr | 2 +- .../nested_array_in_slice/src/main.nr | 2 +- .../nested_arrays_from_brillig/src/main.nr | 6 ++-- .../pedersen_check/src/main.nr | 2 +- .../pedersen_commitment/src/main.nr | 2 +- .../pedersen_hash/src/main.nr | 2 +- .../poseidon_bn254_hash/src/main.nr | 2 +- .../poseidonsponge_x5_254/src/main.nr | 2 +- .../execution_success/pred_eq/src/main.nr | 2 +- .../execution_success/references/src/main.nr | 20 ++++++------- .../execution_success/regression/src/main.nr | 6 ++-- .../regression_3889/src/main.nr | 2 +- .../regression_4088/src/main.nr | 2 +- .../regression_4124/src/main.nr | 6 ++-- .../regression_mem_op_predicate/src/main.nr | 2 +- .../execution_success/scalar_mul/src/main.nr | 12 ++++---- .../execution_success/schnorr/src/main.nr | 6 ++-- .../execution_success/sha256/src/main.nr | 2 +- .../execution_success/sha2_byte/src/main.nr | 2 +- .../simple_2d_array/src/main.nr | 2 +- .../simple_add_and_ret_arr/src/main.nr | 2 +- .../simple_comparison/src/main.nr | 2 +- .../execution_success/simple_mut/src/main.nr | 2 +- .../simple_print/src/main.nr | 2 +- .../simple_program_addition/src/main.nr | 2 +- .../simple_radix/src/main.nr | 2 +- .../simple_shield/src/main.nr | 14 +++++----- .../slice_dynamic_index/src/main.nr | 28 +++++++++---------- .../execution_success/slices/src/main.nr | 24 ++++++++-------- .../execution_success/strings/src/main.nr | 4 +-- .../execution_success/struct/src/main.nr | 8 +++--- .../struct_array_inputs/src/main.nr | 2 +- .../struct_inputs/src/main.nr | 2 +- .../execution_success/to_be_bytes/src/main.nr | 2 +- .../to_bytes_consistent/src/main.nr | 2 +- .../to_bytes_integration/src/main.nr | 2 +- .../execution_success/to_le_bytes/src/main.nr | 2 +- .../trait_as_return_type/src/main.nr | 2 +- .../traits_in_crates_1/src/main.nr | 2 +- .../traits_in_crates_2/src/main.nr | 2 +- .../tuple_inputs/src/main.nr | 2 +- .../execution_success/tuples/src/main.nr | 2 +- .../type_aliases/src/main.nr | 2 +- .../unsafe_range_constraint/src/main.nr | 2 +- .../field_comparisons/src/main.nr | 2 +- 137 files changed, 289 insertions(+), 289 deletions(-) diff --git a/noir_stdlib/src/field_element.nr b/noir_stdlib/src/field_element.nr index 278a187c17a..2069d9a0828 100644 --- a/noir_stdlib/src/field_element.nr +++ b/noir_stdlib/src/field_element.nr @@ -101,8 +101,8 @@ pub fn modulus_le_bytes() -> [u8] {} pub fn bytes32_to_field(bytes32: [u8; 32]) -> field { // Convert it to a field element let mut v = 1; - let mut high = 0 as plain::field; - let mut low = 0 as plain::field; + let mut high = 0 as field; + let mut low = 0 as field; for i in 0..16 { high = high + (bytes32[15 - i] as field) * v; diff --git a/noir_stdlib/src/uint128.nr b/noir_stdlib/src/uint128.nr index d6f0b1e2232..1bf285fecac 100644 --- a/noir_stdlib/src/uint128.nr +++ b/noir_stdlib/src/uint128.nr @@ -12,7 +12,7 @@ impl U128 { pub fn from_u64s_le(lo: u64, hi: u64) -> U128 { // in order to handle multiplication, we need to represent the product of two u64 without overflow - assert(crate::field::modulus_num_bits() as u32 > 128); + assert(crate::field_element::modulus_num_bits() as u32 > 128); U128 { lo: lo as Field, hi: hi as Field } } @@ -129,7 +129,7 @@ impl U128 { let low = self.lo * b.lo; let lo = low as u64 as Field; let carry = (low - lo) / pow64; - let high = if crate::field::modulus_num_bits() as u32 > 196 { + let high = if crate::field_element::modulus_num_bits() as u32 > 196 { (self.lo + self.hi) * (b.lo + b.hi) - low + carry } else { self.lo * b.hi + self.hi * b.lo + carry @@ -175,7 +175,7 @@ impl Mul for U128 { let low = self.lo*b.lo; let lo = low as u64 as Field; let carry = (low - lo) / pow64; - let high = if crate::field::modulus_num_bits() as u32 > 196 { + let high = if crate::field_element::modulus_num_bits() as u32 > 196 { (self.lo+self.hi)*(b.lo+b.hi) - low + carry } else { self.lo*b.hi + self.hi*b.lo + carry diff --git a/test_programs/compile_success_empty/brillig_field_binary_operations/src/main.nr b/test_programs/compile_success_empty/brillig_field_binary_operations/src/main.nr index 54f06858846..8111af5e765 100644 --- a/test_programs/compile_success_empty/brillig_field_binary_operations/src/main.nr +++ b/test_programs/compile_success_empty/brillig_field_binary_operations/src/main.nr @@ -8,18 +8,18 @@ fn main() { assert((x / y) == div(x, y)); } -unconstrained fn add(x: Field, y: Field) -> Field { +unconstrained fn add(x: field, y: field) -> field { x + y } -unconstrained fn sub(x: Field, y: Field) -> Field { +unconstrained fn sub(x: field, y: field) -> field { x - y } -unconstrained fn mul(x: Field, y: Field) -> Field { +unconstrained fn mul(x: field, y: field) -> field { x * y } -unconstrained fn div(x: Field, y: Field) -> Field { +unconstrained fn div(x: field, y: field) -> field { x / y } diff --git a/test_programs/compile_success_empty/closure_explicit_types/src/main.nr b/test_programs/compile_success_empty/closure_explicit_types/src/main.nr index b6c8a6b7b3c..e5441c9c9aa 100644 --- a/test_programs/compile_success_empty/closure_explicit_types/src/main.nr +++ b/test_programs/compile_success_empty/closure_explicit_types/src/main.nr @@ -1,13 +1,13 @@ -fn ret_normal_lambda1() -> fn() -> Field { +fn ret_normal_lambda1() -> fn() -> field { || 10 } // return lamda that captures a thing -fn ret_closure1() -> fn[(Field,)]() -> Field { +fn ret_closure1() -> fn[(field,)]() -> field { let x = 20; || x + 10 } // return lamda that captures two things -fn ret_closure2() -> fn[(Field, Field)]() -> Field { +fn ret_closure2() -> fn[(field, field)]() -> field { let x = 20; let y = 10; || x + y + 10 @@ -19,11 +19,11 @@ fn ret_closure3() -> fn[(u32, u64)]() -> u64 { || x as u64 + y + 10 } // accepts closure that has 1 thing in its env, calls it and returns the result -fn accepts_closure1(f: fn[(Field,)]() -> Field) -> Field { +fn accepts_closure1(f: fn[(field,)]() -> field) -> field { f() } // accepts closure that has 1 thing in its env and returns it -fn accepts_closure2(f: fn[(Field,)]() -> Field) -> fn[(Field,)]() -> Field { +fn accepts_closure2(f: fn[(field,)]() -> field) -> fn[(field,)]() -> field { f } // accepts closure with different types in the capture group @@ -31,7 +31,7 @@ fn accepts_closure3(f: fn[(u32, u64)]() -> u64) -> u64 { f() } // generic over closure environments -fn add_results(f1: fn[Env1]() -> Field, f2: fn[Env2]() -> Field) -> Field { +fn add_results(f1: fn[Env1]() -> field, f2: fn[Env2]() -> field) -> field { f1() + f2() } // a *really* generic function diff --git a/test_programs/compile_success_empty/comptime_recursion_regression/src/main.nr b/test_programs/compile_success_empty/comptime_recursion_regression/src/main.nr index 0461fd9c4cb..dd015297034 100644 --- a/test_programs/compile_success_empty/comptime_recursion_regression/src/main.nr +++ b/test_programs/compile_success_empty/comptime_recursion_regression/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let flag = (x == 1) | (y == 2); assert(flag | false == flag); } diff --git a/test_programs/compile_success_empty/conditional_regression_547/src/main.nr b/test_programs/compile_success_empty/conditional_regression_547/src/main.nr index e47d23516a5..8aa4dee22b3 100644 --- a/test_programs/compile_success_empty/conditional_regression_547/src/main.nr +++ b/test_programs/compile_success_empty/conditional_regression_547/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field) -> pub Field { +fn main(x: field) -> pub field { // Regression test for issue #547 // Warning: it must be kept at the start of main let arr: [u8; 2] = [1, 2]; @@ -11,6 +11,6 @@ fn main(x: Field) -> pub Field { x + safe_inverse(0) } -fn safe_inverse(n: Field) -> Field { +fn safe_inverse(n: field) -> field { if n == 0 { 0 } else { 1 / n } } diff --git a/test_programs/compile_success_empty/generators/src/main.nr b/test_programs/compile_success_empty/generators/src/main.nr index 20bdedee50f..951e06bf6fb 100644 --- a/test_programs/compile_success_empty/generators/src/main.nr +++ b/test_programs/compile_success_empty/generators/src/main.nr @@ -2,7 +2,7 @@ // the syntax for these return types is very difficult to get right :/ // for arguments this can be handled with a generic Env (or with Fn traits when we add them) // but for return types neither fo these will help, you need to type out the exact type -fn make_counter() -> fn[(&mut Field,)]() -> Field { +fn make_counter() -> fn[(&mut field,)]() -> field { let mut x = &mut 0; || { @@ -11,7 +11,7 @@ fn make_counter() -> fn[(&mut Field,)]() -> Field { } } -fn fibonacci_generator() -> fn[(&mut Field, &mut Field)]() -> Field { +fn fibonacci_generator() -> fn[(&mut field, &mut field)]() -> field { let mut x = &mut 1; let mut y = &mut 2; @@ -26,7 +26,7 @@ fn fibonacci_generator() -> fn[(&mut Field, &mut Field)]() -> Field { } } // we'll be able to un-hardcode the array length if we have the ::<> syntax proposed in https://github.com/noir-lang/noir/issues/2458 -fn get_some(generator: fn[Env]() -> Field) -> [Field; 5] { +fn get_some(generator: fn[Env]() -> field) -> [field; 5] { [0, 0, 0, 0, 0].map(|_| generator()) } diff --git a/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr b/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr index 99093c581b5..1ba16506cb1 100644 --- a/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr +++ b/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr @@ -1,12 +1,12 @@ -fn g(x: &mut Field) -> () { +fn g(x: &mut field) -> () { *x *= 2; } -fn h(x: &mut Field) -> () { +fn h(x: &mut field) -> () { *x *= 3; } -fn selector(flag: &mut bool) -> fn(&mut Field) -> () { +fn selector(flag: &mut bool) -> fn(&mut field) -> () { let my_func = if *flag { g } else { h }; // Flip the flag for the next function call *flag = !(*flag); diff --git a/test_programs/compile_success_empty/instruction_deduplication/src/main.nr b/test_programs/compile_success_empty/instruction_deduplication/src/main.nr index 43c0a382185..3363e228660 100644 --- a/test_programs/compile_success_empty/instruction_deduplication/src/main.nr +++ b/test_programs/compile_success_empty/instruction_deduplication/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field) { +fn main(x: field) { // This is a regression test for #2450. // The compiler should recognize that the `(x as u32)` instructions are duplicates and so have the same output. assert(x as u32 == x as u32); diff --git a/test_programs/compile_success_empty/intrinsic_die/src/main.nr b/test_programs/compile_success_empty/intrinsic_die/src/main.nr index 8cac707dfea..d54f164b3fd 100644 --- a/test_programs/compile_success_empty/intrinsic_die/src/main.nr +++ b/test_programs/compile_success_empty/intrinsic_die/src/main.nr @@ -1,6 +1,6 @@ use dep::std; // This test checks that we perform dead-instruction-elimination on intrinsic functions. -fn main(x: Field) { +fn main(x: field) { let hash = std::hash::pedersen_commitment([x]); let _p1 = std::scalar_mul::fixed_base_embedded_curve(x, 0); } diff --git a/test_programs/compile_success_empty/main_return/src/main.nr b/test_programs/compile_success_empty/main_return/src/main.nr index 06347eb0919..3fd228d3c8a 100644 --- a/test_programs/compile_success_empty/main_return/src/main.nr +++ b/test_programs/compile_success_empty/main_return/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: pub Field) -> pub Field { +fn main(x: pub field) -> pub field { x } diff --git a/test_programs/compile_success_empty/numeric_generics/src/main.nr b/test_programs/compile_success_empty/numeric_generics/src/main.nr index 1e03a382fed..c3583f4c3fe 100644 --- a/test_programs/compile_success_empty/numeric_generics/src/main.nr +++ b/test_programs/compile_success_empty/numeric_generics/src/main.nr @@ -14,7 +14,7 @@ fn main() { assert(foo(itWorks2).data[0] == itWorks2.data[0] + 1); } -fn id(x: [Field; I]) -> [Field; I] { +fn id(x: [field; I]) -> [field; I] { x } @@ -23,7 +23,7 @@ struct MyStruct { } impl MyStruct { - fn insert(mut self: Self, index: Field, elem: Field) -> Self { + fn insert(mut self: Self, index: field, elem: field) -> Self { // Regression test for numeric generics on impls assert(index as u64 < S as u64); diff --git a/test_programs/compile_success_empty/references_aliasing/src/main.nr b/test_programs/compile_success_empty/references_aliasing/src/main.nr index 0d96bc2a734..fa96aab0f25 100644 --- a/test_programs/compile_success_empty/references_aliasing/src/main.nr +++ b/test_programs/compile_success_empty/references_aliasing/src/main.nr @@ -7,7 +7,7 @@ fn main() { regression_2445(); } -fn increment(mut r: &mut Field) { +fn increment(mut r: &mut field) { *r = *r + 1; } // If aliasing within arrays and constant folding within the mem2reg pass aren't diff --git a/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr b/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr index 89083b076b6..a3644f9ceb7 100644 --- a/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr +++ b/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr @@ -1,8 +1,8 @@ -fn f(x: Field) -> Field { +fn f(x: field) -> field { x + 1 } -fn ret_fn() -> fn(Field) -> Field { +fn ret_fn() -> fn(field) -> field { f } // TODO: in the advanced implicitly generic function with closures branch @@ -16,14 +16,14 @@ fn ret_fn() -> fn(Field) -> Field { // }; // inner_closure // } -fn ret_lambda() -> fn(Field) -> Field { +fn ret_lambda() -> fn(field) -> field { let cl = |z: Field| -> Field { z + 1 }; cl } -fn main(x: Field) { +fn main(x: field) { let result_fn = ret_fn(); assert(result_fn(x) == x + 1); // let result_closure = ret_closure(); diff --git a/test_programs/compile_success_empty/simple_array_param/src/main.nr b/test_programs/compile_success_empty/simple_array_param/src/main.nr index 6dd7c34dab5..465aae5ec8a 100644 --- a/test_programs/compile_success_empty/simple_array_param/src/main.nr +++ b/test_programs/compile_success_empty/simple_array_param/src/main.nr @@ -1,6 +1,6 @@ // This program tests: // - the allocation of virtual arrays for array params to main // - load instructions for such arrays -fn main(xs: [Field; 2]) -> pub Field { +fn main(xs: [field; 2]) -> pub field { xs[1] } diff --git a/test_programs/compile_success_empty/simple_program_no_body/src/main.nr b/test_programs/compile_success_empty/simple_program_no_body/src/main.nr index 21719018f3f..b6cc281ab6e 100644 --- a/test_programs/compile_success_empty/simple_program_no_body/src/main.nr +++ b/test_programs/compile_success_empty/simple_program_no_body/src/main.nr @@ -6,4 +6,4 @@ // // This program will never fail since there are // no assertions being applied. -fn main(_x: Field, _y: pub Field) {} +fn main(_x: field, _y: pub field) {} diff --git a/test_programs/compile_success_empty/simple_range/src/main.nr b/test_programs/compile_success_empty/simple_range/src/main.nr index 3f595cfd817..eb1afe7bf57 100644 --- a/test_programs/compile_success_empty/simple_range/src/main.nr +++ b/test_programs/compile_success_empty/simple_range/src/main.nr @@ -1,6 +1,6 @@ // Tests a very simple program. // // The features being tested is casting to an integer -fn main(x: Field) { +fn main(x: field) { let _z = x as u32; } diff --git a/test_programs/compile_success_empty/specialization/src/main.nr b/test_programs/compile_success_empty/specialization/src/main.nr index 30116330a86..3ed698cf9e4 100644 --- a/test_programs/compile_success_empty/specialization/src/main.nr +++ b/test_programs/compile_success_empty/specialization/src/main.nr @@ -1,13 +1,13 @@ struct Foo {} impl Foo { - fn foo(_self: Self) -> Field { + fn foo(_self: Self) -> field { 1 } } impl Foo { - fn foo(_self: Self) -> Field { + fn foo(_self: Self) -> field { 2 } } diff --git a/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr b/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr index 412a75010f6..e4baa324692 100644 --- a/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr +++ b/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr @@ -10,7 +10,7 @@ struct Struct1 { } impl Struct1 { - fn tralala() -> Field { + fn tralala() -> field { 123456 } } diff --git a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr index 2f5bff8c40c..a8729d8dc40 100644 --- a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr @@ -19,7 +19,7 @@ impl MyDefault for Foo { } } -fn main(x: Field) { +fn main(x: field) { let first = Foo::method2(x); assert(first == x); } diff --git a/test_programs/compile_success_empty/trait_generics/src/main.nr b/test_programs/compile_success_empty/trait_generics/src/main.nr index 30b2e79d579..0709a22d617 100644 --- a/test_programs/compile_success_empty/trait_generics/src/main.nr +++ b/test_programs/compile_success_empty/trait_generics/src/main.nr @@ -44,13 +44,13 @@ impl Serializable<2> for Data { } } -fn sum(data: T) -> Field where T: Serializable { +fn sum(data: T) -> field where T: Serializable { let serialized = data.serialize(); serialized.fold(0, |acc, elem| acc + elem) } // Test static trait method syntax -fn sum_static(data: T) -> Field where T: Serializable { +fn sum_static(data: T) -> field where T: Serializable { let serialized = Serializable::serialize(data); serialized.fold(0, |acc, elem| acc + elem) } diff --git a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr index 85528291870..56c059bf71d 100644 --- a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr @@ -43,7 +43,7 @@ impl F for Bar { // fn f1(self) -> Field { 101 } // fn f5(self) -> Field { 505 } // } -fn main(x: Field) { +fn main(x: field) { let first = Foo::method2(x); assert(first == 3 * x); diff --git a/test_programs/compile_success_empty/trait_where_clause/src/main.nr b/test_programs/compile_success_empty/trait_where_clause/src/main.nr index 5fd7e78abf4..9c483bbf082 100644 --- a/test_programs/compile_success_empty/trait_where_clause/src/main.nr +++ b/test_programs/compile_success_empty/trait_where_clause/src/main.nr @@ -36,7 +36,7 @@ fn assert_asd_eq_100(t: T) where T: crate::the_trait::Asd { assert(t.asd() == 100); } -fn add_one_to_static_function(t: T) -> Field where T: StaticTrait { +fn add_one_to_static_function(t: T) -> field where T: StaticTrait { T::static_function(t) + 1 } diff --git a/test_programs/compile_success_empty/traits/src/main.nr b/test_programs/compile_success_empty/traits/src/main.nr index ed804559fed..15942057c55 100644 --- a/test_programs/compile_success_empty/traits/src/main.nr +++ b/test_programs/compile_success_empty/traits/src/main.nr @@ -15,7 +15,7 @@ impl MyDefault for Foo { } } -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let first = Foo::my_default(x, y); assert(first.bar == x); } diff --git a/test_programs/compile_success_empty/unused_variables/src/main.nr b/test_programs/compile_success_empty/unused_variables/src/main.nr index f82cace0509..7e6d7d28f93 100644 --- a/test_programs/compile_success_empty/unused_variables/src/main.nr +++ b/test_programs/compile_success_empty/unused_variables/src/main.nr @@ -1 +1 @@ -fn main(x: Field, y: pub Field) {} +fn main(x: field, y: pub field) {} diff --git a/test_programs/compile_success_empty/vectors/src/main.nr b/test_programs/compile_success_empty/vectors/src/main.nr index 28187a4f619..cc026ba38fc 100644 --- a/test_programs/compile_success_empty/vectors/src/main.nr +++ b/test_programs/compile_success_empty/vectors/src/main.nr @@ -1,6 +1,6 @@ use dep::std::collections::vec::Vec; -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let mut vector = Vec::new(); assert(vector.len() == 0); diff --git a/test_programs/execution_success/1327_concrete_in_generic/src/main.nr b/test_programs/execution_success/1327_concrete_in_generic/src/main.nr index 8250b31789b..4fd9ceebff5 100644 --- a/test_programs/execution_success/1327_concrete_in_generic/src/main.nr +++ b/test_programs/execution_success/1327_concrete_in_generic/src/main.nr @@ -30,7 +30,7 @@ impl C { C { t_d_interface } } - fn call_method_of_t_d(self, t_d: T_D) -> Field { + fn call_method_of_t_d(self, t_d: T_D) -> field { let some_method_on_t_d = self.t_d_interface.some_method_on_t_d; some_method_on_t_d(t_d) } @@ -45,7 +45,7 @@ struct D { d: Field, } -fn d_method(input: D) -> Field { +fn d_method(input: D) -> field { input.d * input.d } @@ -53,7 +53,7 @@ fn get_d_method_interface() -> MethodInterface { MethodInterface { some_method_on_t_d: d_method } } // --- -fn main(input: Field) -> pub Field { +fn main(input: field) -> pub field { let b: B> = B::new(new_concrete_c_over_d); let c: C = b.get_t_c(); // Singleton let d: D = D { d: input }; // Note diff --git a/test_programs/execution_success/7_function/src/main.nr b/test_programs/execution_success/7_function/src/main.nr index 95568dd4ccd..ff7f1f8ae52 100644 --- a/test_programs/execution_success/7_function/src/main.nr +++ b/test_programs/execution_success/7_function/src/main.nr @@ -1,33 +1,33 @@ //Tests for function calling -fn f1(mut x: Field) -> Field { +fn f1(mut x: field) -> field { x = x + 1; x = f2(x); x } -fn f2(mut x: Field) -> Field { +fn f2(mut x: field) -> field { x += 2; x } // Simple example -fn test0(mut a: Field) { +fn test0(mut a: field) { a = f2(a); assert(a == 3); } // Nested call -fn test1(mut a: Field) { +fn test1(mut a: field) { a = f1(a); assert(a == 4); } -fn test2(z: Field, t: u32) { +fn test2(z: field, t: u32) { let a = z + t as Field; assert(a == 64); let e = pow(z, t as Field); assert(e == 714924299); } -fn pow(base: Field, exponent: Field) -> Field { +fn pow(base: field, exponent: field) -> field { let mut r = 1 as Field; let b = exponent.to_le_bits(32 as u32); for i in 1..33 { @@ -82,15 +82,15 @@ fn test_multiple6(a: my2, b: my_struct, c: (my2, my_struct)) { assert(c.0.aa.a == c.1.a); } -fn foo(a: [Field; N]) -> [Field; N] { +fn foo(a: [field; N]) -> [field; N] { a } -fn bar() -> [Field; 1] { +fn bar() -> [field; 1] { foo([0]) } -fn main(x: u32, y: u32, a: Field, arr1: [u32; 9], arr2: [u32; 9]) { +fn main(x: u32, y: u32, a: field, arr1: [u32; 9], arr2: [u32; 9]) { let mut ss: my_struct = my_struct { b: x, a: x + 2 }; test_multiple4(ss); test_multiple5((ss.a, ss.b)); @@ -126,7 +126,7 @@ fn main(x: u32, y: u32, a: Field, arr1: [u32; 9], arr2: [u32; 9]) { assert(result[0] == arr1[0] as Field); } // Issue #628 -fn arr_to_field(arr: [u32; 9]) -> [Field; 9] { +fn arr_to_field(arr: [u32; 9]) -> [field; 9] { let mut as_field: [Field; 9] = [0 as Field; 9]; for i in 0..9 { as_field[i] = arr[i] as Field; @@ -134,6 +134,6 @@ fn arr_to_field(arr: [u32; 9]) -> [Field; 9] { as_field } -fn first(a: [Field; 9], _b: [Field; 9]) -> [Field; 9] { +fn first(a: [field; 9], _b: [field; 9]) -> [field; 9] { a } diff --git a/test_programs/execution_success/arithmetic_binary_operations/src/main.nr b/test_programs/execution_success/arithmetic_binary_operations/src/main.nr index 69554f413a4..3ae28d75e56 100644 --- a/test_programs/execution_success/arithmetic_binary_operations/src/main.nr +++ b/test_programs/execution_success/arithmetic_binary_operations/src/main.nr @@ -3,7 +3,7 @@ // The features being tested are: // Binary addition, multiplication, division, constant modulo // x = 3, y = 4, z = 5 -fn main(x: Field, y: Field, z: Field) -> pub Field { +fn main(x: field, y: field, z: field) -> pub field { //cast assert(y as u1 == 0); diff --git a/test_programs/execution_success/array_dynamic/src/main.nr b/test_programs/execution_success/array_dynamic/src/main.nr index 6b51095bd8c..1a182d92415 100644 --- a/test_programs/execution_success/array_dynamic/src/main.nr +++ b/test_programs/execution_success/array_dynamic/src/main.nr @@ -2,10 +2,10 @@ fn main( x: [u32; 5], mut z: u32, t: u32, - index: [Field; 5], - index2: [Field; 5], - offset: Field, - sublen: Field + index: [field; 5], + index2: [field; 5], + offset: field, + sublen: field ) { let idx = (z - 5 * t - 5) as Field; //dynamic array test @@ -23,7 +23,7 @@ fn main( } } -fn dyn_array(mut x: [u32; 5], y: Field, z: Field) { +fn dyn_array(mut x: [u32; 5], y: field, z: field) { assert(x[y] == 111); assert(x[z] == 101); x[z] = 0; diff --git a/test_programs/execution_success/array_dynamic_main_output/src/main.nr b/test_programs/execution_success/array_dynamic_main_output/src/main.nr index 50feb71f983..fe03560c95b 100644 --- a/test_programs/execution_success/array_dynamic_main_output/src/main.nr +++ b/test_programs/execution_success/array_dynamic_main_output/src/main.nr @@ -1,4 +1,4 @@ -fn main(mut x: [Field; 10], index: u8) -> pub [Field; 10] { +fn main(mut x: [field; 10], index: u8) -> pub [field; 10] { x[index] = 0; x } diff --git a/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr b/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr index 8faaf69dfc8..c6bdd3cbb1a 100644 --- a/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr +++ b/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr @@ -8,7 +8,7 @@ struct Foo { bar: Bar, } -fn main(mut x: [Foo; 3], y: pub Field, hash_result: pub [u8; 32]) { +fn main(mut x: [Foo; 3], y: pub field, hash_result: pub [u8; 32]) { // Simple dynamic array set for entire inner most array x[y - 1].bar.inner = [106, 107, 10]; let mut hash_input = x[y - 1].bar.inner; diff --git a/test_programs/execution_success/array_eq/src/main.nr b/test_programs/execution_success/array_eq/src/main.nr index 5bbd595898c..9e817e9f948 100644 --- a/test_programs/execution_success/array_eq/src/main.nr +++ b/test_programs/execution_success/array_eq/src/main.nr @@ -1,4 +1,4 @@ // Simple example of checking where two arrays are equal -fn main(a: [Field; 32], b: [Field; 32]) { +fn main(a: [field; 32], b: [field; 32]) { assert(a == b); } diff --git a/test_programs/execution_success/array_len/src/main.nr b/test_programs/execution_success/array_len/src/main.nr index f846cfb9844..b1ef2375210 100644 --- a/test_programs/execution_success/array_len/src/main.nr +++ b/test_programs/execution_success/array_len/src/main.nr @@ -2,15 +2,15 @@ fn len_plus_1(array: [T; N]) -> u64 { array.len() + 1 } -fn add_lens(a: [T; N], b: [Field; M]) -> u64 { +fn add_lens(a: [T; N], b: [field; M]) -> u64 { a.len() + b.len() } -fn nested_call(b: [Field; N]) -> u64 { +fn nested_call(b: [field; N]) -> u64 { len_plus_1(b) } -fn main(x: Field, len3: [u8; 3], len4: [Field; 4]) { +fn main(x: field, len3: [u8; 3], len4: [field; 4]) { assert(len_plus_1(len3) == 4); assert(len_plus_1(len4) == 5); assert(add_lens(len3, len4) == 7); diff --git a/test_programs/execution_success/array_neq/src/main.nr b/test_programs/execution_success/array_neq/src/main.nr index a3e51dc5066..93bb11183c6 100644 --- a/test_programs/execution_success/array_neq/src/main.nr +++ b/test_programs/execution_success/array_neq/src/main.nr @@ -1,4 +1,4 @@ // Simple example of checking where two arrays are different -fn main(a: [Field; 32], b: [Field; 32]) { +fn main(a: [field; 32], b: [field; 32]) { assert(a != b); } diff --git a/test_programs/execution_success/assert/src/main.nr b/test_programs/execution_success/assert/src/main.nr index 00e94414c0b..63916c93978 100644 --- a/test_programs/execution_success/assert/src/main.nr +++ b/test_programs/execution_success/assert/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field) { +fn main(x: field) { assert(x == 1); } diff --git a/test_programs/execution_success/assert_statement/src/main.nr b/test_programs/execution_success/assert_statement/src/main.nr index 2646a0b85c2..51c06be1fcf 100644 --- a/test_programs/execution_success/assert_statement/src/main.nr +++ b/test_programs/execution_success/assert_statement/src/main.nr @@ -1,7 +1,7 @@ // Tests a very simple program. // // The features being tested is assertion -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x == y, "x and y are not equal"); assert_eq(x, y, "x and y are not equal"); } diff --git a/test_programs/execution_success/assert_statement_recursive/src/main.nr b/test_programs/execution_success/assert_statement_recursive/src/main.nr index d89ea3d35bb..9f5057d1876 100644 --- a/test_programs/execution_success/assert_statement_recursive/src/main.nr +++ b/test_programs/execution_success/assert_statement_recursive/src/main.nr @@ -5,7 +5,7 @@ // that the backend should use a prover which will construct proofs // friendly to recursive verification in another SNARK. #[recursive] -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x == y, "x and y are not equal"); assert_eq(x, y, "x and y are not equal"); } diff --git a/test_programs/execution_success/assign_ex/src/main.nr b/test_programs/execution_success/assign_ex/src/main.nr index b5cfc162cc4..80130df69db 100644 --- a/test_programs/execution_success/assign_ex/src/main.nr +++ b/test_programs/execution_success/assign_ex/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let mut z = x + y; assert(z == 3); z = x * y; diff --git a/test_programs/execution_success/bit_and/src/main.nr b/test_programs/execution_success/bit_and/src/main.nr index 5a0aa17e3ed..24b42308a94 100644 --- a/test_programs/execution_success/bit_and/src/main.nr +++ b/test_programs/execution_success/bit_and/src/main.nr @@ -1,6 +1,6 @@ // You can only do bit operations with integers. // (Kobi/Daira/Circom/#37) https://github.com/iden3/circom/issues/37 -fn main(x: Field, y: Field, a: Field, b: Field) { +fn main(x: field, y: field, a: field, b: field) { let x_as_u8 = x as u8; let y_as_u8 = y as u8; diff --git a/test_programs/execution_success/brillig_array_eq/src/main.nr b/test_programs/execution_success/brillig_array_eq/src/main.nr index 90f631dbed8..4daff32258b 100644 --- a/test_programs/execution_success/brillig_array_eq/src/main.nr +++ b/test_programs/execution_success/brillig_array_eq/src/main.nr @@ -1,4 +1,4 @@ // Simple example of checking where two arrays are equal -unconstrained fn main(a: [Field; 32], b: [Field; 32]) { +unconstrained fn main(a: [field; 32], b: [field; 32]) { assert(a == b); } diff --git a/test_programs/execution_success/brillig_arrays/src/main.nr b/test_programs/execution_success/brillig_arrays/src/main.nr index e535b6001a4..30b203f43ad 100644 --- a/test_programs/execution_success/brillig_arrays/src/main.nr +++ b/test_programs/execution_success/brillig_arrays/src/main.nr @@ -1,19 +1,19 @@ // Tests a very simple program. // // The features being tested are array reads and writes -fn main(x: [Field; 3]) { +fn main(x: [field; 3]) { read_array(x); read_write_array(x); } -unconstrained fn read_array(x: [Field; 3]) { +unconstrained fn read_array(x: [field; 3]) { assert(x[0] == 1); let y = [1, 5, 27]; assert(y[x[0]] == 5); } -unconstrained fn read_write_array(x: [Field; 3]) { +unconstrained fn read_write_array(x: [field; 3]) { let mut y = x; y[0] = 5; diff --git a/test_programs/execution_success/brillig_assert/src/main.nr b/test_programs/execution_success/brillig_assert/src/main.nr index 16fe7b29061..cc398c71ade 100644 --- a/test_programs/execution_success/brillig_assert/src/main.nr +++ b/test_programs/execution_success/brillig_assert/src/main.nr @@ -1,11 +1,11 @@ // Tests a very simple program. // // The features being tested is using assert on brillig -fn main(x: Field) { +fn main(x: field) { assert(1 == conditional(x as bool)); } -unconstrained fn conditional(x: bool) -> Field { +unconstrained fn conditional(x: bool) -> field { assert(x, f"Expected x to be false but got {x}"); assert_eq(x, true, f"Expected x to be false but got {x}"); 1 diff --git a/test_programs/execution_success/brillig_conditional/src/main.nr b/test_programs/execution_success/brillig_conditional/src/main.nr index a59336a877b..9935f690ebe 100644 --- a/test_programs/execution_success/brillig_conditional/src/main.nr +++ b/test_programs/execution_success/brillig_conditional/src/main.nr @@ -1,10 +1,10 @@ // Tests a very simple program. // // The features being tested is basic conditonal on brillig -fn main(x: Field) { +fn main(x: field) { assert(4 == conditional(x == 1)); } -unconstrained fn conditional(x: bool) -> Field { +unconstrained fn conditional(x: bool) -> field { if x { 4 } else { 5 } } diff --git a/test_programs/execution_success/brillig_cow/src/main.nr b/test_programs/execution_success/brillig_cow/src/main.nr index 52ce8b8be3c..78615cb893b 100644 --- a/test_programs/execution_success/brillig_cow/src/main.nr +++ b/test_programs/execution_success/brillig_cow/src/main.nr @@ -16,7 +16,7 @@ impl ExecutionResult { } } -fn modify_in_inlined_constrained(original: [Field; ARRAY_SIZE], index: u64) -> ExecutionResult { +fn modify_in_inlined_constrained(original: [field; ARRAY_SIZE], index: u64) -> ExecutionResult { let mut modified = original; modified[index] = 27; @@ -29,7 +29,7 @@ fn modify_in_inlined_constrained(original: [Field; ARRAY_SIZE], index: u64) -> E } unconstrained fn modify_in_unconstrained( - original: [Field; ARRAY_SIZE], + original: [field; ARRAY_SIZE], index: u64 ) -> ExecutionResult { let mut modified = original; @@ -43,7 +43,7 @@ unconstrained fn modify_in_unconstrained( ExecutionResult { original, modified_once, modified_twice: modified } } -unconstrained fn main(original: [Field; ARRAY_SIZE], index: u64, expected_result: ExecutionResult) { +unconstrained fn main(original: [field; ARRAY_SIZE], index: u64, expected_result: ExecutionResult) { assert(expected_result.is_equal(modify_in_unconstrained(original, index))); assert(expected_result.is_equal(modify_in_inlined_constrained(original, index))); } diff --git a/test_programs/execution_success/brillig_cow_regression/src/main.nr b/test_programs/execution_success/brillig_cow_regression/src/main.nr index 7f3dd766480..2df2a02ee56 100644 --- a/test_programs/execution_success/brillig_cow_regression/src/main.nr +++ b/test_programs/execution_success/brillig_cow_regression/src/main.nr @@ -24,7 +24,7 @@ struct NewContractData { } impl NewContractData { - fn hash(self) -> Field { + fn hash(self) -> field { dep::std::hash::pedersen_hash([self.contract_address, self.portal_contract_address]) } } @@ -88,7 +88,7 @@ impl U256 { U256 { inner: [high_0, high_1, low_0, low_1] } } - pub fn to_u128_limbs(self) -> [Field; 2] { + pub fn to_u128_limbs(self) -> [field; 2] { let two_pow_64 = 2.pow_32(64); let high = (self.inner[0] as Field) * two_pow_64 + self.inner[1] as Field; @@ -98,7 +98,7 @@ impl U256 { } } -unconstrained fn main(kernel_data: DataToHash) -> pub [Field; NUM_FIELDS_PER_SHA256] { +unconstrained fn main(kernel_data: DataToHash) -> pub [field; NUM_FIELDS_PER_SHA256] { let mut calldata_hash_inputs = [0; CALLDATA_HASH_INPUT_SIZE]; let new_commitments = kernel_data.new_commitments; diff --git a/test_programs/execution_success/brillig_hash_to_field/src/main.nr b/test_programs/execution_success/brillig_hash_to_field/src/main.nr index 4b4177a521e..952ed90f0fe 100644 --- a/test_programs/execution_success/brillig_hash_to_field/src/main.nr +++ b/test_programs/execution_success/brillig_hash_to_field/src/main.nr @@ -2,10 +2,10 @@ use dep::std; // Tests a very simple program. // // The features being tested is hash_to_field in brillig -fn main(input: Field) -> pub Field { +fn main(input: field) -> pub field { hash_to_field(input) } -unconstrained fn hash_to_field(input: Field) -> Field { +unconstrained fn hash_to_field(input: field) -> field { std::hash::hash_to_field([input]) } diff --git a/test_programs/execution_success/brillig_identity_function/src/main.nr b/test_programs/execution_success/brillig_identity_function/src/main.nr index f41188b1f0d..720a5ee62d7 100644 --- a/test_programs/execution_success/brillig_identity_function/src/main.nr +++ b/test_programs/execution_success/brillig_identity_function/src/main.nr @@ -5,7 +5,7 @@ struct myStruct { // Tests a very simple program. // // The features being tested is the identity function in Brillig -fn main(x: Field) { +fn main(x: field) { assert(x == identity(x)); // TODO: add support for array comparison let arr = identity_array([x, x]); @@ -19,11 +19,11 @@ fn main(x: Field) { assert(x == identity_struct.foo_arr[1]); } -unconstrained fn identity(x: Field) -> Field { +unconstrained fn identity(x: field) -> field { x } -unconstrained fn identity_array(arr: [Field; 2]) -> [Field; 2] { +unconstrained fn identity_array(arr: [field; 2]) -> [field; 2] { arr } diff --git a/test_programs/execution_success/brillig_keccak/src/main.nr b/test_programs/execution_success/brillig_keccak/src/main.nr index 1e9b65a6eb4..41725125aba 100644 --- a/test_programs/execution_success/brillig_keccak/src/main.nr +++ b/test_programs/execution_success/brillig_keccak/src/main.nr @@ -2,7 +2,7 @@ use dep::std; // Tests a very simple program. // // The features being tested is keccak256 in brillig -fn main(x: Field, result: [u8; 32]) { +fn main(x: field, result: [u8; 32]) { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field // The padding is taken care of by the program let digest = keccak256([x as u8], 1); diff --git a/test_programs/execution_success/brillig_nested_arrays/src/main.nr b/test_programs/execution_success/brillig_nested_arrays/src/main.nr index 5a5657246a8..46f774e9f86 100644 --- a/test_programs/execution_success/brillig_nested_arrays/src/main.nr +++ b/test_programs/execution_success/brillig_nested_arrays/src/main.nr @@ -8,7 +8,7 @@ struct MyNote { header: Header, } -unconstrained fn access_nested(notes: [MyNote; 2], x: Field, y: Field) -> Field { +unconstrained fn access_nested(notes: [MyNote; 2], x: field, y: field) -> field { notes[x].array[y] + notes[y].array[x] + notes[x].plain + notes[y].header.params[x] } @@ -19,15 +19,15 @@ unconstrained fn create_inside_brillig() -> [MyNote; 2] { [note0, note1] } -unconstrained fn assert_inside_brillig(notes: [MyNote; 2], x: Field, y: Field) { +unconstrained fn assert_inside_brillig(notes: [MyNote; 2], x: field, y: field) { assert(access_nested(notes, x, y) == (2 + 4 + 3 + 1)); } -unconstrained fn create_and_assert_inside_brillig(x: Field, y: Field) { +unconstrained fn create_and_assert_inside_brillig(x: field, y: field) { assert_inside_brillig(create_inside_brillig(), x, y); } -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let header = Header { params: [1, 2, 3] }; let note0 = MyNote { array: [1, 2], plain: 3, header }; let note1 = MyNote { array: [4, 5], plain: 6, header }; diff --git a/test_programs/execution_success/brillig_not/src/main.nr b/test_programs/execution_success/brillig_not/src/main.nr index d34b3edb4b6..b5e10f2b1b4 100644 --- a/test_programs/execution_success/brillig_not/src/main.nr +++ b/test_programs/execution_success/brillig_not/src/main.nr @@ -1,7 +1,7 @@ // Tests a very simple Brillig function. // // The features being tested is not instruction on brillig -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { assert(false == not_operator(x as bool)); assert(true == not_operator(y as bool)); } diff --git a/test_programs/execution_success/brillig_oracle/src/main.nr b/test_programs/execution_success/brillig_oracle/src/main.nr index 6a9e5806621..760fa3ae2d8 100644 --- a/test_programs/execution_success/brillig_oracle/src/main.nr +++ b/test_programs/execution_success/brillig_oracle/src/main.nr @@ -2,7 +2,7 @@ use dep::std::slice; use dep::std::test::OracleMock; // Tests oracle usage in brillig/unconstrained functions -fn main(_x: Field) { +fn main(_x: field) { let size = 20; // TODO: Add a method along the lines of `(0..size).to_array()`. let mut mock_oracle_response = [0; 20]; @@ -22,12 +22,12 @@ fn main(_x: Field) { // Define oracle functions which we have mocked above #[oracle(get_number_sequence)] -unconstrained fn get_number_sequence(_size: Field) -> [Field] {} +unconstrained fn get_number_sequence(_size: field) -> [field] {} #[oracle(get_reverse_number_sequence)] -unconstrained fn get_reverse_number_sequence(_size: Field) -> [Field] {} +unconstrained fn get_reverse_number_sequence(_size: field) -> [field] {} -unconstrained fn get_number_sequence_wrapper(size: Field) { +unconstrained fn get_number_sequence_wrapper(size: field) { let slice = get_number_sequence(size); for i in 0..20 as u32 { assert(slice[i] == i as Field); diff --git a/test_programs/execution_success/brillig_pedersen/src/main.nr b/test_programs/execution_success/brillig_pedersen/src/main.nr index 2379818c454..812f89d1473 100644 --- a/test_programs/execution_success/brillig_pedersen/src/main.nr +++ b/test_programs/execution_success/brillig_pedersen/src/main.nr @@ -1,6 +1,6 @@ use dep::std; -unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { +unconstrained fn main(x: field, y: field, salt: field, out_x: field, out_y: field, out_hash: field) { let res = std::hash::pedersen_commitment_with_separator([x, y], 0); assert(res.x == out_x); assert(res.y == out_y); diff --git a/test_programs/execution_success/brillig_references/src/main.nr b/test_programs/execution_success/brillig_references/src/main.nr index e1f906beb0a..e6b39f2ddcd 100644 --- a/test_programs/execution_success/brillig_references/src/main.nr +++ b/test_programs/execution_success/brillig_references/src/main.nr @@ -1,4 +1,4 @@ -unconstrained fn main(mut x: Field) { +unconstrained fn main(mut x: field) { add1(&mut x); assert(x == 3); // https://github.com/noir-lang/noir/issues/1899 @@ -21,7 +21,7 @@ unconstrained fn main(mut x: Field) { assert(arr[1] == 4); } -unconstrained fn add1(x: &mut Field) { +unconstrained fn add1(x: &mut field) { *x += 1; } @@ -44,6 +44,6 @@ impl S { } } -unconstrained fn mutate_copy(mut a: Field) { +unconstrained fn mutate_copy(mut a: field) { a = 7; } diff --git a/test_programs/execution_success/brillig_scalar_mul/src/main.nr b/test_programs/execution_success/brillig_scalar_mul/src/main.nr index c7c3a85a4ff..7245af3f3db 100644 --- a/test_programs/execution_success/brillig_scalar_mul/src/main.nr +++ b/test_programs/execution_success/brillig_scalar_mul/src/main.nr @@ -1,12 +1,12 @@ use dep::std; unconstrained fn main( - a: Field, - a_pub_x: pub Field, - a_pub_y: pub Field, - b: Field, - b_pub_x: pub Field, - b_pub_y: pub Field + a: field, + a_pub_x: pub field, + a_pub_y: pub field, + b: field, + b_pub_x: pub field, + b_pub_y: pub field ) { let mut priv_key = a; let mut pub_x: Field = a_pub_x; diff --git a/test_programs/execution_success/brillig_schnorr/src/main.nr b/test_programs/execution_success/brillig_schnorr/src/main.nr index 4cc79ae7e07..4f17d4fa0fe 100644 --- a/test_programs/execution_success/brillig_schnorr/src/main.nr +++ b/test_programs/execution_success/brillig_schnorr/src/main.nr @@ -3,9 +3,9 @@ use dep::std; // to figure out the circuit instance unconstrained fn main( message: [u8; 10], - message_field: Field, - pub_key_x: Field, - pub_key_y: Field, + message_field: field, + pub_key_x: field, + pub_key_y: field, signature: [u8; 64] ) { // Regression for issue #2421 diff --git a/test_programs/execution_success/brillig_sha256/src/main.nr b/test_programs/execution_success/brillig_sha256/src/main.nr index e76109df9c3..7bd19c7ff44 100644 --- a/test_programs/execution_success/brillig_sha256/src/main.nr +++ b/test_programs/execution_success/brillig_sha256/src/main.nr @@ -2,11 +2,11 @@ use dep::std; // Tests a very simple program. // // The features being tested is sha256 in brillig -fn main(x: Field, result: [u8; 32]) { +fn main(x: field, result: [u8; 32]) { assert(result == sha256(x)); } -unconstrained fn sha256(x: Field) -> [u8; 32] { +unconstrained fn sha256(x: field) -> [u8; 32] { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field // The padding is taken care of by the program std::hash::sha256([x as u8]) diff --git a/test_programs/execution_success/brillig_slices/src/main.nr b/test_programs/execution_success/brillig_slices/src/main.nr index 847c41de25c..bc31cdc8075 100644 --- a/test_programs/execution_success/brillig_slices/src/main.nr +++ b/test_programs/execution_success/brillig_slices/src/main.nr @@ -1,5 +1,5 @@ use dep::std::slice; -unconstrained fn main(x: Field, y: Field) { +unconstrained fn main(x: field, y: field) { let mut slice: [Field] = [y, x]; assert(slice.len() == 2); @@ -73,12 +73,12 @@ unconstrained fn push_front_to_slice(slice: [T], item: T) -> [T] { slice.push_front(item) } // The parameters to this function must come from witness values (inputs to main) -unconstrained fn regression_merge_slices(x: Field, y: Field) { +unconstrained fn regression_merge_slices(x: field, y: field) { merge_slices_if(x, y); merge_slices_else(x); } -unconstrained fn merge_slices_if(x: Field, y: Field) { +unconstrained fn merge_slices_if(x: field, y: field) { let slice = merge_slices_return(x, y); assert(slice[2] == 10); assert(slice.len() == 3); @@ -92,7 +92,7 @@ unconstrained fn merge_slices_if(x: Field, y: Field) { assert(slice.len() == 7); } -unconstrained fn merge_slices_else(x: Field) { +unconstrained fn merge_slices_else(x: field) { let slice = merge_slices_return(x, 5); assert(slice[0] == 0); assert(slice[1] == 0); @@ -107,7 +107,7 @@ unconstrained fn merge_slices_else(x: Field) { assert(slice.len() == 3); } // Test returning a merged slice without a mutation -unconstrained fn merge_slices_return(x: Field, y: Field) -> [Field] { +unconstrained fn merge_slices_return(x: field, y: field) -> [field] { let slice = [0; 2]; if x != y { if x != 20 { slice.push_back(y) } else { slice } @@ -116,7 +116,7 @@ unconstrained fn merge_slices_return(x: Field, y: Field) -> [Field] { } } // Test mutating a slice inside of an if statement -unconstrained fn merge_slices_mutate(x: Field, y: Field) -> [Field] { +unconstrained fn merge_slices_mutate(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { slice = slice.push_back(y); @@ -127,7 +127,7 @@ unconstrained fn merge_slices_mutate(x: Field, y: Field) -> [Field] { slice } // Test mutating a slice inside of a loop in an if statement -unconstrained fn merge_slices_mutate_in_loop(x: Field, y: Field) -> [Field] { +unconstrained fn merge_slices_mutate_in_loop(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { for i in 0..5 { diff --git a/test_programs/execution_success/brillig_to_be_bytes/src/main.nr b/test_programs/execution_success/brillig_to_be_bytes/src/main.nr index 9d78411f060..799bc6314b6 100644 --- a/test_programs/execution_success/brillig_to_be_bytes/src/main.nr +++ b/test_programs/execution_success/brillig_to_be_bytes/src/main.nr @@ -1,4 +1,4 @@ -unconstrained fn main(x: Field) -> pub [u8; 31] { +unconstrained fn main(x: field) -> pub [u8; 31] { // The result of this byte array will be big-endian let byte_array = x.to_be_bytes(31); let mut bytes = [0; 31]; diff --git a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr index dad13706ba8..a5def2611ba 100644 --- a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr @@ -1,6 +1,6 @@ use dep::std; -unconstrained fn main(x: Field, _y: Field) { +unconstrained fn main(x: field, _y: field) { // The result of this byte array will be big-endian let y: Field = 2040124; let be_byte_array = y.to_be_bytes(31); diff --git a/test_programs/execution_success/brillig_to_le_bytes/src/main.nr b/test_programs/execution_success/brillig_to_le_bytes/src/main.nr index 77d292cf01b..6d3f46b5ab4 100644 --- a/test_programs/execution_success/brillig_to_le_bytes/src/main.nr +++ b/test_programs/execution_success/brillig_to_le_bytes/src/main.nr @@ -1,4 +1,4 @@ -unconstrained fn main(x: Field) -> pub [u8; 31] { +unconstrained fn main(x: field) -> pub [u8; 31] { // The result of this byte array will be little-endian let byte_array = x.to_le_bytes(31); assert(byte_array.len() == 31); diff --git a/test_programs/execution_success/brillig_top_level/src/main.nr b/test_programs/execution_success/brillig_top_level/src/main.nr index 6dfd98b2c3e..fecb6db280f 100644 --- a/test_programs/execution_success/brillig_top_level/src/main.nr +++ b/test_programs/execution_success/brillig_top_level/src/main.nr @@ -1,6 +1,6 @@ // Tests a very simple program. // // The feature being tested is brillig as the entry point. -unconstrained fn main(array: [Field; 3], x: pub Field) -> pub [Field; 2] { +unconstrained fn main(array: [field; 3], x: pub field) -> pub [field; 2] { [array[x], array[x + 1]] } diff --git a/test_programs/execution_success/brillig_unitialised_arrays/src/main.nr b/test_programs/execution_success/brillig_unitialised_arrays/src/main.nr index 5ec657b0d35..72243fedac0 100644 --- a/test_programs/execution_success/brillig_unitialised_arrays/src/main.nr +++ b/test_programs/execution_success/brillig_unitialised_arrays/src/main.nr @@ -1,12 +1,12 @@ -fn main(x: Field, y: Field) -> pub Field { +fn main(x: field, y: field) -> pub field { let notes = create_notes(x, y); sum_x(notes, x, y) } -fn sum_x(notes: [Field; 2], x: Field, y: Field) -> Field { +fn sum_x(notes: [field; 2], x: field, y: field) -> field { notes[x] + notes[y] } -unconstrained fn create_notes(x: Field, y: Field) -> [Field; 2] { +unconstrained fn create_notes(x: field, y: field) -> [field; 2] { [x, y] } diff --git a/test_programs/execution_success/cast_bool/src/main.nr b/test_programs/execution_success/cast_bool/src/main.nr index 422d3b98f83..a1b2726de95 100644 --- a/test_programs/execution_success/cast_bool/src/main.nr +++ b/test_programs/execution_success/cast_bool/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let z = x == y; let t = z as u8; assert(t == 1); diff --git a/test_programs/execution_success/closures_mut_ref/src/main.nr b/test_programs/execution_success/closures_mut_ref/src/main.nr index 5a743d1b633..d1af471273c 100644 --- a/test_programs/execution_success/closures_mut_ref/src/main.nr +++ b/test_programs/execution_success/closures_mut_ref/src/main.nr @@ -1,4 +1,4 @@ -fn main(mut x: Field) { +fn main(mut x: field) { let one = 1; let add1 = |z| { *z = *z + one; diff --git a/test_programs/execution_success/conditional_2/src/main.nr b/test_programs/execution_success/conditional_2/src/main.nr index 5b3f64f6be5..0778a3285fe 100644 --- a/test_programs/execution_success/conditional_2/src/main.nr +++ b/test_programs/execution_success/conditional_2/src/main.nr @@ -46,6 +46,6 @@ fn test5(a: u32) { } } -fn foo2() -> Field { +fn foo2() -> field { 3 } diff --git a/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr b/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr index d260fa49dc3..ea95ccfc693 100644 --- a/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr +++ b/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr @@ -19,7 +19,7 @@ fn foo() { x /= 0; } -fn bar(x: Field) { +fn bar(x: field) { if x == 15 { foo(); } diff --git a/test_programs/execution_success/custom_entry/src/foobarbaz.nr b/test_programs/execution_success/custom_entry/src/foobarbaz.nr index 00e94414c0b..63916c93978 100644 --- a/test_programs/execution_success/custom_entry/src/foobarbaz.nr +++ b/test_programs/execution_success/custom_entry/src/foobarbaz.nr @@ -1,3 +1,3 @@ -fn main(x: Field) { +fn main(x: field) { assert(x == 1); } diff --git a/test_programs/execution_success/debug_logs/src/main.nr b/test_programs/execution_success/debug_logs/src/main.nr index ec24b0cc8e8..8afd3a2055e 100644 --- a/test_programs/execution_success/debug_logs/src/main.nr +++ b/test_programs/execution_success/debug_logs/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let string = "i: {i}, j: {j}"; println(string); diff --git a/test_programs/execution_success/diamond_deps_0/src/main.nr b/test_programs/execution_success/diamond_deps_0/src/main.nr index ca95c6e0aa8..1cb1015eaec 100644 --- a/test_programs/execution_success/diamond_deps_0/src/main.nr +++ b/test_programs/execution_success/diamond_deps_0/src/main.nr @@ -2,6 +2,6 @@ use dep::dep1::call_dep1_then_dep2; use dep::dep2::call_dep2; use dep::dep2::RESOLVE_THIS; -fn main(x: Field, y: pub Field) -> pub Field { +fn main(x: field, y: pub field) -> pub field { call_dep1_then_dep2(x, y) + call_dep2(x, y) + RESOLVE_THIS } diff --git a/test_programs/execution_success/distinct_keyword/src/main.nr b/test_programs/execution_success/distinct_keyword/src/main.nr index 8e9b5c008ed..6b3bf9be957 100644 --- a/test_programs/execution_success/distinct_keyword/src/main.nr +++ b/test_programs/execution_success/distinct_keyword/src/main.nr @@ -1,4 +1,4 @@ // Example that uses the distinct keyword -fn main(x: pub Field) -> distinct pub [Field; 2] { +fn main(x: pub field) -> distinct pub [field; 2] { [x + 1, x] } diff --git a/test_programs/execution_success/double_verify_proof/src/main.nr b/test_programs/execution_success/double_verify_proof/src/main.nr index ce087dc4e61..f69685f31ec 100644 --- a/test_programs/execution_success/double_verify_proof/src/main.nr +++ b/test_programs/execution_success/double_verify_proof/src/main.nr @@ -1,16 +1,16 @@ use dep::std; fn main( - verification_key: [Field; 114], + verification_key: [field; 114], // This is the proof without public inputs attached. // // This means: the size of this does not change with the number of public inputs. - proof: [Field; 93], - public_inputs: [Field; 1], + proof: [field; 93], + public_inputs: [field; 1], // This is currently not public. It is fine given that the vk is a part of the circuit definition. // I believe we want to eventually make it public too though. - key_hash: Field, - proof_b: [Field; 93] + key_hash: field, + proof_b: [field; 93] ) { std::verify_proof( verification_key.as_slice(), diff --git a/test_programs/execution_success/eddsa/src/main.nr b/test_programs/execution_success/eddsa/src/main.nr index 12e8ea92785..589c75a02de 100644 --- a/test_programs/execution_success/eddsa/src/main.nr +++ b/test_programs/execution_success/eddsa/src/main.nr @@ -2,7 +2,7 @@ use dep::std::compat; use dep::std::ec::consts::te::baby_jubjub; use dep::std::hash; use dep::std::eddsa::eddsa_poseidon_verify; -fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { +fn main(msg: pub field, _priv_key_a: field, _priv_key_b: field) { // Skip this test for non-bn254 backends if compat::is_bn254() { let bjj = baby_jubjub(); diff --git a/test_programs/execution_success/generics/src/main.nr b/test_programs/execution_success/generics/src/main.nr index 3edce1ed8e7..b0ef17ab4e3 100644 --- a/test_programs/execution_success/generics/src/main.nr +++ b/test_programs/execution_success/generics/src/main.nr @@ -26,12 +26,12 @@ impl BigInt { } impl Bar { - fn get_other(self) -> Field { + fn get_other(self) -> field { self.other } } -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let bar1: Bar = Bar { one: x, two: y, other: 0 }; let bar2 = Bar { one: x, two: y, other: [0] }; @@ -54,7 +54,7 @@ fn main(x: Field, y: Field) { let _ = regression_2055([1, 2, 3]); } -fn regression_2055(bytes: [u8; LEN]) -> Field { +fn regression_2055(bytes: [u8; LEN]) -> field { let mut f = 0; let mut b = 1; let mut len = LEN - 1; // FAILS diff --git a/test_programs/execution_success/global_consts/src/baz.nr b/test_programs/execution_success/global_consts/src/baz.nr index 384cf9d3569..b7e98f87a46 100644 --- a/test_programs/execution_success/global_consts/src/baz.nr +++ b/test_programs/execution_success/global_consts/src/baz.nr @@ -1,4 +1,4 @@ -pub fn from_baz(x: [Field; crate::foo::MAGIC_NUMBER]) { +pub fn from_baz(x: [field; crate::foo::MAGIC_NUMBER]) { for i in 0..crate::foo::MAGIC_NUMBER { assert(x[i] == crate::foo::MAGIC_NUMBER as Field); } diff --git a/test_programs/execution_success/global_consts/src/foo.nr b/test_programs/execution_success/global_consts/src/foo.nr index 413b9c3a74b..3812a89159d 100644 --- a/test_programs/execution_success/global_consts/src/foo.nr +++ b/test_programs/execution_success/global_consts/src/foo.nr @@ -4,7 +4,7 @@ global N: u64 = 5; global MAGIC_NUMBER: u64 = 3; global TYPE_INFERRED = 42; -pub fn from_foo(x: [Field; bar::N]) { +pub fn from_foo(x: [field; bar::N]) { for i in 0..bar::N { assert(x[i] == bar::N as Field); } diff --git a/test_programs/execution_success/global_consts/src/foo/bar.nr b/test_programs/execution_success/global_consts/src/foo/bar.nr index 5404c9cf1e3..40b5fc938a3 100644 --- a/test_programs/execution_success/global_consts/src/foo/bar.nr +++ b/test_programs/execution_success/global_consts/src/foo/bar.nr @@ -1,5 +1,5 @@ global N: u64 = 5; -pub fn from_bar(x: Field) -> Field { +pub fn from_bar(x: field) -> field { x * N as Field } diff --git a/test_programs/execution_success/global_consts/src/main.nr b/test_programs/execution_success/global_consts/src/main.nr index 3c8ecc67a0c..2d49a326508 100644 --- a/test_programs/execution_success/global_consts/src/main.nr +++ b/test_programs/execution_success/global_consts/src/main.nr @@ -20,7 +20,7 @@ struct Test { global VALS: [Test; 1] = [Test { v: 100 }]; global NESTED = [VALS, VALS]; -unconstrained fn calculate_global_value() -> Field { +unconstrained fn calculate_global_value() -> field { 42 } @@ -28,10 +28,10 @@ unconstrained fn calculate_global_value() -> Field { global CALCULATED_GLOBAL: Field = calculate_global_value(); fn main( - a: [Field; M + N - N], - b: [Field; 30 + N / 2], - c: pub [Field; foo::MAGIC_NUMBER], - d: [Field; foo::bar::N] + a: [field; M + N - N], + b: [field; 30 + N / 2], + c: pub [field; foo::MAGIC_NUMBER], + d: [field; foo::bar::N] ) { let test_struct = Dummy { x: d, y: c }; @@ -85,11 +85,11 @@ fn main( assert(CALCULATED_GLOBAL == 42); } -fn multiplyByM(x: Field) -> Field { +fn multiplyByM(x: field) -> field { x * M } -fn arrays_neq(a: [Field; M], b: [Field; M]) { +fn arrays_neq(a: [field; M], b: [field; M]) { assert(a != b); } @@ -101,7 +101,7 @@ mod my_submodule { assert(x | y == 1); } - pub fn my_helper() -> Field { + pub fn my_helper() -> field { let N: Field = 15; // Like in Rust, local variables override globals let x = N; x diff --git a/test_programs/execution_success/hash_to_field/src/main.nr b/test_programs/execution_success/hash_to_field/src/main.nr index 5af1c5af55e..7744e8c78f0 100644 --- a/test_programs/execution_success/hash_to_field/src/main.nr +++ b/test_programs/execution_success/hash_to_field/src/main.nr @@ -1,5 +1,5 @@ use dep::std; -fn main(input: Field) -> pub Field { +fn main(input: field) -> pub field { std::hash::hash_to_field([input]) } diff --git a/test_programs/execution_success/higher_order_functions/src/main.nr b/test_programs/execution_success/higher_order_functions/src/main.nr index 6583f961d58..5c918473a8d 100644 --- a/test_programs/execution_success/higher_order_functions/src/main.nr +++ b/test_programs/execution_success/higher_order_functions/src/main.nr @@ -1,4 +1,4 @@ -fn main(w: Field) -> pub Field { +fn main(w: field) -> pub field { let f = if 3 * 7 > 200 as u32 { foo } else { bar }; assert(f()[1] == 2); // Lambdas: @@ -77,11 +77,11 @@ fn bar() -> [u32; 2] { [3, 2] } -fn add1(x: Field) -> Field { +fn add1(x: field) -> field { x + 1 } -fn twice(f: fn(Field) -> Field, x: Field) -> Field { +fn twice(f: fn(field) -> field, x: field) -> field { f(f(x)) } // Fixing an ICE, where rewriting the closures diff --git a/test_programs/execution_success/import/src/import.nr b/test_programs/execution_success/import/src/import.nr index ef3f0d94c28..a1f430a3986 100644 --- a/test_programs/execution_success/import/src/import.nr +++ b/test_programs/execution_success/import/src/import.nr @@ -1,3 +1,3 @@ -pub fn hello(x: Field) -> Field { +pub fn hello(x: field) -> field { x } diff --git a/test_programs/execution_success/import/src/main.nr b/test_programs/execution_success/import/src/main.nr index 7dcc16fed16..faf5ee07839 100644 --- a/test_programs/execution_success/import/src/main.nr +++ b/test_programs/execution_success/import/src/main.nr @@ -1,7 +1,7 @@ mod import; use crate::import::hello; -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let _k = dep::std::hash::pedersen_commitment([x]); let _l = hello(x); diff --git a/test_programs/execution_success/integer_array_indexing/src/main.nr b/test_programs/execution_success/integer_array_indexing/src/main.nr index 1698c68161b..ccff7bd2a7b 100644 --- a/test_programs/execution_success/integer_array_indexing/src/main.nr +++ b/test_programs/execution_success/integer_array_indexing/src/main.nr @@ -1,6 +1,6 @@ global ARRAY_LEN: u32 = 3; -fn main(arr: [Field; ARRAY_LEN], x: u32) -> pub Field { +fn main(arr: [field; ARRAY_LEN], x: u32) -> pub field { let mut value = arr[ARRAY_LEN - 1]; value += arr[0 as u32]; diff --git a/test_programs/execution_success/keccak256/src/main.nr b/test_programs/execution_success/keccak256/src/main.nr index eb401fe614c..d6694891896 100644 --- a/test_programs/execution_success/keccak256/src/main.nr +++ b/test_programs/execution_success/keccak256/src/main.nr @@ -1,7 +1,7 @@ // docs:start:keccak256 use dep::std; -fn main(x: Field, result: [u8; 32]) { +fn main(x: field, result: [u8; 32]) { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field // The padding is taken care of by the program let digest = std::hash::keccak256([x as u8], 1); diff --git a/test_programs/execution_success/merkle_insert/src/main.nr b/test_programs/execution_success/merkle_insert/src/main.nr index ac9a7b34ea3..357bf1b0b71 100644 --- a/test_programs/execution_success/merkle_insert/src/main.nr +++ b/test_programs/execution_success/merkle_insert/src/main.nr @@ -2,13 +2,13 @@ use dep::std; use dep::std::hash::mimc; fn main( - old_root: Field, - old_leaf: Field, - old_hash_path: [Field; 3], - new_root: pub Field, - leaf: Field, - index: Field, - mimc_input: [Field; 4] + old_root: field, + old_leaf: field, + old_hash_path: [field; 3], + new_root: pub field, + leaf: field, + index: field, + mimc_input: [field; 4] ) { assert(old_root == std::merkle::compute_merkle_root(old_leaf, index, old_hash_path)); diff --git a/test_programs/execution_success/missing_closure_env/src/main.nr b/test_programs/execution_success/missing_closure_env/src/main.nr index 0bc99b0671c..0fc4948f919 100644 --- a/test_programs/execution_success/missing_closure_env/src/main.nr +++ b/test_programs/execution_success/missing_closure_env/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field) { +fn main(x: field) { let x1 = &mut 42; let set_x1 = |y| { *x1 = y; }; diff --git a/test_programs/execution_success/mock_oracle/src/main.nr b/test_programs/execution_success/mock_oracle/src/main.nr index 90fca7993cc..d427b8360e0 100644 --- a/test_programs/execution_success/mock_oracle/src/main.nr +++ b/test_programs/execution_success/mock_oracle/src/main.nr @@ -6,7 +6,7 @@ struct Point { } #[oracle(foo)] -unconstrained fn foo_oracle(_point: Point, _array: [Field; 4]) -> Field {} +unconstrained fn foo_oracle(_point: Point, _array: [field; 4]) -> field {} unconstrained fn main() { let array = [1, 2, 3, 4]; diff --git a/test_programs/execution_success/modules/src/foo.nr b/test_programs/execution_success/modules/src/foo.nr index ef3f0d94c28..a1f430a3986 100644 --- a/test_programs/execution_success/modules/src/foo.nr +++ b/test_programs/execution_success/modules/src/foo.nr @@ -1,3 +1,3 @@ -pub fn hello(x: Field) -> Field { +pub fn hello(x: field) -> field { x } diff --git a/test_programs/execution_success/modules/src/main.nr b/test_programs/execution_success/modules/src/main.nr index 167f7e671a0..cdd2548eb22 100644 --- a/test_programs/execution_success/modules/src/main.nr +++ b/test_programs/execution_success/modules/src/main.nr @@ -9,6 +9,6 @@ mod foo; // To run a proof on the command line, type `cargo run prove {proof_name}` // // To verify that proof, type `cargo run verify {proof_name}` -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != foo::hello(y)); } diff --git a/test_programs/execution_success/modules_more/src/foo.nr b/test_programs/execution_success/modules_more/src/foo.nr index fa531a1a2f0..3a72727a7cd 100644 --- a/test_programs/execution_success/modules_more/src/foo.nr +++ b/test_programs/execution_success/modules_more/src/foo.nr @@ -1,5 +1,5 @@ mod bar; -fn hello(x: Field) -> Field { +fn hello(x: field) -> field { x } diff --git a/test_programs/execution_success/modules_more/src/foo/bar.nr b/test_programs/execution_success/modules_more/src/foo/bar.nr index 1665f720be6..6a88f84b115 100644 --- a/test_programs/execution_success/modules_more/src/foo/bar.nr +++ b/test_programs/execution_success/modules_more/src/foo/bar.nr @@ -1,3 +1,3 @@ -pub fn from_bar(x: Field) -> Field { +pub fn from_bar(x: field) -> field { x } diff --git a/test_programs/execution_success/modules_more/src/main.nr b/test_programs/execution_success/modules_more/src/main.nr index 93b76d62845..020b1da3e28 100644 --- a/test_programs/execution_success/modules_more/src/main.nr +++ b/test_programs/execution_success/modules_more/src/main.nr @@ -1,5 +1,5 @@ mod foo; // An example of the module system -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { assert(x != foo::bar::from_bar(y)); } diff --git a/test_programs/execution_success/nested_array_dynamic/src/main.nr b/test_programs/execution_success/nested_array_dynamic/src/main.nr index 2c53822d6b9..ea09cb7c7f8 100644 --- a/test_programs/execution_success/nested_array_dynamic/src/main.nr +++ b/test_programs/execution_success/nested_array_dynamic/src/main.nr @@ -13,7 +13,7 @@ struct FooParent { foos: [Foo; 4], } -fn main(mut x: [Foo; 4], y: pub Field) { +fn main(mut x: [Foo; 4], y: pub field) { assert(x[y - 3].a == 1); assert(x[y - 3].b == [2, 3, 20]); assert(x[y - 2].a == 4); diff --git a/test_programs/execution_success/nested_array_in_slice/src/main.nr b/test_programs/execution_success/nested_array_in_slice/src/main.nr index a3007d5d0dc..e59123d0840 100644 --- a/test_programs/execution_success/nested_array_in_slice/src/main.nr +++ b/test_programs/execution_success/nested_array_in_slice/src/main.nr @@ -8,7 +8,7 @@ struct Foo { bar: Bar, } -fn main(y: Field) { +fn main(y: field) { let foo_one = Foo { a: 1, b: [2, 3, 20], bar: Bar { inner: [100, 101, 102] } }; let foo_two = Foo { a: 4, b: [5, 6, 21], bar: Bar { inner: [103, 104, 105] } }; let foo_three = Foo { a: 7, b: [8, 9, 22], bar: Bar { inner: [106, 107, 108] } }; diff --git a/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr b/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr index 1bcbd7d5421..27e9b892d69 100644 --- a/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr +++ b/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr @@ -8,18 +8,18 @@ struct MyNote { header: Header, } -fn access_nested(notes: [MyNote; 2]) -> Field { +fn access_nested(notes: [MyNote; 2]) -> field { notes[0].array[1] + notes[1].array[0] + notes[0].plain + notes[1].header.params[0] } -unconstrained fn create_inside_brillig(values: [Field; 6]) -> [MyNote; 2] { +unconstrained fn create_inside_brillig(values: [field; 6]) -> [MyNote; 2] { let header = Header { params: [values[0], values[1], values[2]] }; let note0 = MyNote { array: [values[0], values[1]], plain: values[2], header }; let note1 = MyNote { array: [values[3], values[4]], plain: values[5], header }; [note0, note1] } -fn main(values: [Field; 6]) { +fn main(values: [field; 6]) { let notes = create_inside_brillig(values); assert(access_nested(notes) == (2 + 4 + 3 + 1)); } diff --git a/test_programs/execution_success/pedersen_check/src/main.nr b/test_programs/execution_success/pedersen_check/src/main.nr index 90ef218249b..dd4753d7770 100644 --- a/test_programs/execution_success/pedersen_check/src/main.nr +++ b/test_programs/execution_success/pedersen_check/src/main.nr @@ -1,6 +1,6 @@ use dep::std; -fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { +fn main(x: field, y: field, salt: field, out_x: field, out_y: field, out_hash: field) { let res = std::hash::pedersen_commitment([x, y]); assert(res.x == out_x); assert(res.y == out_y); diff --git a/test_programs/execution_success/pedersen_commitment/src/main.nr b/test_programs/execution_success/pedersen_commitment/src/main.nr index 83cbe20851d..77ac1f21555 100644 --- a/test_programs/execution_success/pedersen_commitment/src/main.nr +++ b/test_programs/execution_success/pedersen_commitment/src/main.nr @@ -1,7 +1,7 @@ // docs:start:pedersen-commitment use dep::std; -fn main(x: Field, y: Field, expected_commitment: std::hash::PedersenPoint) { +fn main(x: field, y: field, expected_commitment: std::hash::PedersenPoint) { let commitment = std::hash::pedersen_commitment([x, y]); assert_eq(commitment.x, expected_commitment.x); assert_eq(commitment.y, expected_commitment.y); diff --git a/test_programs/execution_success/pedersen_hash/src/main.nr b/test_programs/execution_success/pedersen_hash/src/main.nr index 20c7de12d6c..2e6da9a14ea 100644 --- a/test_programs/execution_success/pedersen_hash/src/main.nr +++ b/test_programs/execution_success/pedersen_hash/src/main.nr @@ -1,7 +1,7 @@ // docs:start:pedersen-hash use dep::std; -fn main(x: Field, y: Field, expected_hash: Field) { +fn main(x: field, y: field, expected_hash: field) { let hash = std::hash::pedersen_hash([x, y]); assert_eq(hash, expected_hash); } diff --git a/test_programs/execution_success/poseidon_bn254_hash/src/main.nr b/test_programs/execution_success/poseidon_bn254_hash/src/main.nr index 939b99595c7..c7ae3d3d5c4 100644 --- a/test_programs/execution_success/poseidon_bn254_hash/src/main.nr +++ b/test_programs/execution_success/poseidon_bn254_hash/src/main.nr @@ -2,7 +2,7 @@ use dep::std::hash::poseidon; use dep::std::hash::poseidon2; -fn main(x1: [Field; 2], y1: pub Field, x2: [Field; 4], y2: pub Field, x3: [Field; 4], y3: Field) { +fn main(x1: [field; 2], y1: pub field, x2: [field; 4], y2: pub field, x3: [field; 4], y3: field) { let hash1 = poseidon::bn254::hash_2(x1); assert(hash1 == y1); diff --git a/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr b/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr index 910a17c8c89..4925251901c 100644 --- a/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr +++ b/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr @@ -1,6 +1,6 @@ use dep::std::hash::poseidon; -fn main(x: [Field; 7]) { +fn main(x: [field; 7]) { // Test optimized sponge let result = poseidon::bn254::sponge(x); diff --git a/test_programs/execution_success/pred_eq/src/main.nr b/test_programs/execution_success/pred_eq/src/main.nr index d1e79a3e408..2f3da942540 100644 --- a/test_programs/execution_success/pred_eq/src/main.nr +++ b/test_programs/execution_success/pred_eq/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let p = x == y; assert(p == true); } diff --git a/test_programs/execution_success/references/src/main.nr b/test_programs/execution_success/references/src/main.nr index 1a9be5f82b9..e9a3407738f 100644 --- a/test_programs/execution_success/references/src/main.nr +++ b/test_programs/execution_success/references/src/main.nr @@ -1,4 +1,4 @@ -fn main(mut x: Field) { +fn main(mut x: field) { add1(&mut x); assert(x == 3); @@ -36,7 +36,7 @@ fn main(mut x: Field) { regression_2560(s_ref); } -fn add1(x: &mut Field) { +fn add1(x: &mut field) { *x += 1; } @@ -58,12 +58,12 @@ impl S { self.y += 2; } - fn get_y(self) -> Field { + fn get_y(self) -> field { self.y } } -fn mutate_copy(mut a: Field) { +fn mutate_copy(mut a: field) { a = 7; } // Previously the `foo.bar` in `foo.bar.mutate()` would insert an automatic dereference @@ -107,11 +107,11 @@ fn regression_2255() { assert(*x == 1); } -fn regression_2255_helper(mut x: &mut Field) { +fn regression_2255_helper(mut x: &mut field) { *x = 1; } -fn regression_2218(x: Field, y: Field) -> Field { +fn regression_2218(x: field, y: field) -> field { let q = &mut &mut 0; let q1 = *q; let q2 = *q; @@ -136,22 +136,22 @@ fn regression_2218(x: Field, y: Field) -> Field { value } -fn regression_2218_if_inner_if(x: Field, y: Field) { +fn regression_2218_if_inner_if(x: field, y: field) { let value = regression_2218(x, y); assert(value == 2); } -fn regression_2218_if_inner_else(x: Field, y: Field) { +fn regression_2218_if_inner_else(x: field, y: field) { let value = regression_2218(x, y); assert(value == 15); } -fn regression_2218_else(x: Field, y: Field) { +fn regression_2218_else(x: field, y: field) { let value = regression_2218(x, y); assert(value == 20); } -fn regression_2218_loop(x: Field, y: Field) { +fn regression_2218_loop(x: field, y: field) { let q = &mut &mut 0; let q1 = *q; let q2 = *q; diff --git a/test_programs/execution_success/regression/src/main.nr b/test_programs/execution_success/regression/src/main.nr index c70e2e75fa8..aa46e8d7774 100644 --- a/test_programs/execution_success/regression/src/main.nr +++ b/test_programs/execution_success/regression/src/main.nr @@ -20,7 +20,7 @@ impl Eq for U4 { } } -fn compact_decode(input: [u8; N], length: Field) -> ([U4; NIBBLE_LENGTH], Field) { +fn compact_decode(input: [u8; N], length: field) -> ([U4; NIBBLE_LENGTH], field) { assert(2 * input.len() as u64 <= NIBBLE_LENGTH as u64); assert(length as u64 <= input.len() as u64); @@ -53,7 +53,7 @@ fn compact_decode(input: [u8; N], length: Field) -> ([U4; NIBBLE_LENGTH], Fie out } -fn enc(value: [u8; N], value_length: Field) -> ([u8; 32], Field) { +fn enc(value: [u8; N], value_length: field) -> ([u8; 32], field) { assert(value.len() as u8 >= value_length as u8); let mut out_value = [0; 32]; if value_length == 0 { @@ -94,7 +94,7 @@ fn bitshift_variable(idx: u64) -> u64 { bits } -fn main(x: [u8; 5], z: Field) { +fn main(x: [u8; 5], z: field) { //Issue 1144 let (nib, len) = compact_decode(x, z); assert(len == 5); diff --git a/test_programs/execution_success/regression_3889/src/main.nr b/test_programs/execution_success/regression_3889/src/main.nr index 402a69a10da..730c811c03a 100644 --- a/test_programs/execution_success/regression_3889/src/main.nr +++ b/test_programs/execution_success/regression_3889/src/main.nr @@ -17,6 +17,6 @@ mod Baz { use crate::Bar::NewType; } -fn main(works: Baz::Works, fails: Baz::BarStruct, also_fails: Bar::NewType) -> pub Field { +fn main(works: Baz::Works, fails: Baz::BarStruct, also_fails: Bar::NewType) -> pub field { works.a + fails.a + also_fails.a } diff --git a/test_programs/execution_success/regression_4088/src/main.nr b/test_programs/execution_success/regression_4088/src/main.nr index 9e4d7892fc3..b17373c0d34 100644 --- a/test_programs/execution_success/regression_4088/src/main.nr +++ b/test_programs/execution_success/regression_4088/src/main.nr @@ -12,7 +12,7 @@ impl Serialize<1> for ValueNote { } } -fn check(serialized_note: [Field; N]) { +fn check(serialized_note: [field; N]) { assert(serialized_note[0] == 0); } diff --git a/test_programs/execution_success/regression_4124/src/main.nr b/test_programs/execution_success/regression_4124/src/main.nr index b47bf28d461..214d3330893 100644 --- a/test_programs/execution_success/regression_4124/src/main.nr +++ b/test_programs/execution_success/regression_4124/src/main.nr @@ -10,7 +10,7 @@ impl MyDeserialize<1> for Field { } } -pub fn storage_read() -> [Field; N] { +pub fn storage_read() -> [field; N] { dep::std::unsafe::zeroed() } @@ -19,7 +19,7 @@ struct PublicState { } impl PublicState { - pub fn new(storage_slot: Field) -> Self { + pub fn new(storage_slot: field) -> Self { assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1."); PublicState { storage_slot } } @@ -31,7 +31,7 @@ impl PublicState { } } -fn main(value: Field) { +fn main(value: field) { let ps: PublicState = PublicState::new(27); // error here diff --git a/test_programs/execution_success/regression_mem_op_predicate/src/main.nr b/test_programs/execution_success/regression_mem_op_predicate/src/main.nr index 4b5ca67f6de..244bceb3e5c 100644 --- a/test_programs/execution_success/regression_mem_op_predicate/src/main.nr +++ b/test_programs/execution_success/regression_mem_op_predicate/src/main.nr @@ -1,4 +1,4 @@ -fn main(mut x: [u32; 5], idx: Field) { +fn main(mut x: [u32; 5], idx: field) { // We should not hit out of bounds here as we have a predicate // that should not be hit if idx as u32 < 3 { diff --git a/test_programs/execution_success/scalar_mul/src/main.nr b/test_programs/execution_success/scalar_mul/src/main.nr index e20f47907db..3a4256c013c 100644 --- a/test_programs/execution_success/scalar_mul/src/main.nr +++ b/test_programs/execution_success/scalar_mul/src/main.nr @@ -1,12 +1,12 @@ use dep::std; fn main( - a: Field, - a_pub_x: pub Field, - a_pub_y: pub Field, - b: Field, - b_pub_x: pub Field, - b_pub_y: pub Field + a: field, + a_pub_x: pub field, + a_pub_y: pub field, + b: field, + b_pub_x: pub field, + b_pub_y: pub field ) { let mut priv_key = a; let mut pub_x: Field = a_pub_x; diff --git a/test_programs/execution_success/schnorr/src/main.nr b/test_programs/execution_success/schnorr/src/main.nr index 107af152625..fda3afd31c7 100644 --- a/test_programs/execution_success/schnorr/src/main.nr +++ b/test_programs/execution_success/schnorr/src/main.nr @@ -3,9 +3,9 @@ use dep::std; // to figure out the circuit instance fn main( message: [u8; 10], - message_field: Field, - pub_key_x: Field, - pub_key_y: Field, + message_field: field, + pub_key_x: field, + pub_key_y: field, signature: [u8; 64] ) { // Regression for issue #2421 diff --git a/test_programs/execution_success/sha256/src/main.nr b/test_programs/execution_success/sha256/src/main.nr index fd5340e2384..641972838fc 100644 --- a/test_programs/execution_success/sha256/src/main.nr +++ b/test_programs/execution_success/sha256/src/main.nr @@ -11,7 +11,7 @@ // This can be done in ACIR! use dep::std; -fn main(x: Field, result: [u8; 32]) { +fn main(x: field, result: [u8; 32]) { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field // The padding is taken care of by the program let digest = std::hash::sha256([x as u8]); diff --git a/test_programs/execution_success/sha2_byte/src/main.nr b/test_programs/execution_success/sha2_byte/src/main.nr index fa8ddfbdf69..4475b2ff48f 100644 --- a/test_programs/execution_success/sha2_byte/src/main.nr +++ b/test_programs/execution_success/sha2_byte/src/main.nr @@ -1,7 +1,7 @@ // Test Noir implementations of SHA256 and SHA512 on a one-byte message. use dep::std; -fn main(x: Field, result256: [u8; 32], result512: [u8; 64]) { +fn main(x: field, result256: [u8; 32], result512: [u8; 64]) { let digest256 = std::sha256::digest([x as u8]); assert(digest256 == result256); diff --git a/test_programs/execution_success/simple_2d_array/src/main.nr b/test_programs/execution_success/simple_2d_array/src/main.nr index 2ecdd4bc15f..adc4623da36 100644 --- a/test_programs/execution_success/simple_2d_array/src/main.nr +++ b/test_programs/execution_success/simple_2d_array/src/main.nr @@ -1,5 +1,5 @@ // Test accessing a multidimensional array -fn main(x: Field, y: Field, array_input: [[Field; 2]; 2]) { +fn main(x: field, y: field, array_input: [[field; 2]; 2]) { assert(array_input[0][0] == x); assert(array_input[0][1] == y); diff --git a/test_programs/execution_success/simple_add_and_ret_arr/src/main.nr b/test_programs/execution_success/simple_add_and_ret_arr/src/main.nr index 016c4fedf40..ce65c73e990 100644 --- a/test_programs/execution_success/simple_add_and_ret_arr/src/main.nr +++ b/test_programs/execution_success/simple_add_and_ret_arr/src/main.nr @@ -3,6 +3,6 @@ // that dead instruction elemination looks inside of arrays // when deciding whether of not an instruction should be // retained. -fn main(x: Field) -> pub [Field; 1] { +fn main(x: field) -> pub [field; 1] { [x + 1] } diff --git a/test_programs/execution_success/simple_comparison/src/main.nr b/test_programs/execution_success/simple_comparison/src/main.nr index 05800440459..363e47e90cd 100644 --- a/test_programs/execution_success/simple_comparison/src/main.nr +++ b/test_programs/execution_success/simple_comparison/src/main.nr @@ -1,6 +1,6 @@ // Tests a very simple program. // // The features being tested is comparison -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { assert(x as u32 < y as u32); } diff --git a/test_programs/execution_success/simple_mut/src/main.nr b/test_programs/execution_success/simple_mut/src/main.nr index d0715dbafe0..9e07d6077de 100644 --- a/test_programs/execution_success/simple_mut/src/main.nr +++ b/test_programs/execution_success/simple_mut/src/main.nr @@ -1,5 +1,5 @@ // A simple program to test mutable variables -fn main(x: Field) -> pub Field { +fn main(x: field) -> pub field { let mut y = 2; y += x; y diff --git a/test_programs/execution_success/simple_print/src/main.nr b/test_programs/execution_success/simple_print/src/main.nr index 6038b995af0..cf97e9bd3a6 100644 --- a/test_programs/execution_success/simple_print/src/main.nr +++ b/test_programs/execution_success/simple_print/src/main.nr @@ -2,7 +2,7 @@ // of single witnesses and witness arrays. use dep::std; -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { std::println(x); std::println([x, y]); } diff --git a/test_programs/execution_success/simple_program_addition/src/main.nr b/test_programs/execution_success/simple_program_addition/src/main.nr index 0390d79e83b..54b2bf89493 100644 --- a/test_programs/execution_success/simple_program_addition/src/main.nr +++ b/test_programs/execution_success/simple_program_addition/src/main.nr @@ -1,5 +1,5 @@ // The feature being tested is handling of // a binary operation. -fn main(x: Field) -> pub Field { +fn main(x: field) -> pub field { x + 1 } diff --git a/test_programs/execution_success/simple_radix/src/main.nr b/test_programs/execution_success/simple_radix/src/main.nr index 4a335e1bade..e6e9b690316 100644 --- a/test_programs/execution_success/simple_radix/src/main.nr +++ b/test_programs/execution_success/simple_radix/src/main.nr @@ -1,5 +1,5 @@ // Simple program to test to_radix -fn main(x: Field) { +fn main(x: field) { let bits = x.to_le_bits(3); assert(bits[0] == 0); assert(bits[1] == 1); diff --git a/test_programs/execution_success/simple_shield/src/main.nr b/test_programs/execution_success/simple_shield/src/main.nr index c46d3b4594c..c891cb6f699 100644 --- a/test_programs/execution_success/simple_shield/src/main.nr +++ b/test_programs/execution_success/simple_shield/src/main.nr @@ -3,15 +3,15 @@ use dep::std; fn main( // Public key of note // all notes have the same denomination - priv_key: Field, + priv_key: field, // Merkle membership proof - note_root: pub Field, - index: Field, - note_hash_path: [Field; 3], + note_root: pub field, + index: field, + note_hash_path: [field; 3], // Receiver public key - to_pubkey_x: Field, - to_pubkey_y: Field -) -> pub [Field; 2] { + to_pubkey_x: field, + to_pubkey_y: field +) -> pub [field; 2] { // Compute public key from private key to show ownership let pubkey = std::scalar_mul::fixed_base_embedded_curve(priv_key, 0); let pubkey_x = pubkey[0]; diff --git a/test_programs/execution_success/slice_dynamic_index/src/main.nr b/test_programs/execution_success/slice_dynamic_index/src/main.nr index 41fc9a645c1..8b8790280c8 100644 --- a/test_programs/execution_success/slice_dynamic_index/src/main.nr +++ b/test_programs/execution_success/slice_dynamic_index/src/main.nr @@ -1,9 +1,9 @@ -fn main(x: Field) { +fn main(x: field) { // The parameters to this function must come directly from witness values (inputs to main). regression_dynamic_slice_index(x - 1, x - 4); } -fn regression_dynamic_slice_index(x: Field, y: Field) { +fn regression_dynamic_slice_index(x: field, y: field) { let mut slice = []; for i in 0..5 { slice = slice.push_back(i as Field); @@ -25,7 +25,7 @@ fn regression_dynamic_slice_index(x: Field, y: Field) { dynamic_slice_merge_push_then_pop(slice, x, y); } -fn dynamic_slice_index_set_if(mut slice: [Field], x: Field, y: Field) { +fn dynamic_slice_index_set_if(mut slice: [field], x: field, y: field) { assert(slice[x] == 4); assert(slice[y] == 1); slice[y] = 0; @@ -42,7 +42,7 @@ fn dynamic_slice_index_set_if(mut slice: [Field], x: Field, y: Field) { assert(slice[4] == 2); } -fn dynamic_slice_index_set_else(mut slice: [Field], x: Field, y: Field) { +fn dynamic_slice_index_set_else(mut slice: [field], x: field, y: field) { assert(slice[x] == 4); assert(slice[y] == 1); slice[y] = 0; @@ -59,7 +59,7 @@ fn dynamic_slice_index_set_else(mut slice: [Field], x: Field, y: Field) { } // This tests the case of missing a store instruction in the else branch // of merging slices -fn dynamic_slice_index_if(mut slice: [Field], x: Field) { +fn dynamic_slice_index_if(mut slice: [field], x: field) { if x as u32 < 10 { assert(slice[x] == 4); slice[x] = slice[x] - 2; @@ -69,7 +69,7 @@ fn dynamic_slice_index_if(mut slice: [Field], x: Field) { assert(slice[4] == 2); } -fn dynamic_array_index_if(mut array: [Field; 5], x: Field) { +fn dynamic_array_index_if(mut array: [field; 5], x: field) { if x as u32 < 10 { assert(array[x] == 4); array[x] = array[x] - 2; @@ -80,7 +80,7 @@ fn dynamic_array_index_if(mut array: [Field; 5], x: Field) { } // This tests the case of missing a store instruction in the then branch // of merging slices -fn dynamic_slice_index_else(mut slice: [Field], x: Field) { +fn dynamic_slice_index_else(mut slice: [field], x: field) { if x as u32 > 10 { assert(slice[x] == 0); } else { @@ -90,7 +90,7 @@ fn dynamic_slice_index_else(mut slice: [Field], x: Field) { assert(slice[4] == 2); } -fn dynamic_slice_merge_if(mut slice: [Field], x: Field) { +fn dynamic_slice_merge_if(mut slice: [field], x: field) { if x as u32 < 10 { assert(slice[x] == 4); slice[x] = slice[x] - 2; @@ -145,7 +145,7 @@ fn dynamic_slice_merge_if(mut slice: [Field], x: Field) { assert(slice[slice.len() - 1] == 30); } -fn dynamic_slice_merge_else(mut slice: [Field], x: Field) { +fn dynamic_slice_merge_else(mut slice: [field], x: field) { if x as u32 > 10 { assert(slice[x] == 0); slice[x] = 2; @@ -162,7 +162,7 @@ fn dynamic_slice_merge_else(mut slice: [Field], x: Field) { assert(slice[slice.len() - 1] == 20); } -fn dynamic_slice_index_set_nested_if_else_else(mut slice: [Field], x: Field, y: Field) { +fn dynamic_slice_index_set_nested_if_else_else(mut slice: [field], x: field, y: field) { assert(slice[x] == 4); assert(slice[y] == 1); slice[y] = 0; @@ -195,7 +195,7 @@ fn dynamic_slice_index_set_nested_if_else_else(mut slice: [Field], x: Field, y: assert(slice[slice.len() - 1] == 20); } -fn dynamic_slice_index_set_nested_if_else_if(mut slice: [Field], x: Field, y: Field) { +fn dynamic_slice_index_set_nested_if_else_if(mut slice: [field], x: field, y: field) { assert(slice[x] == 4); assert(slice[y] == 2); slice[y] = 0; @@ -218,7 +218,7 @@ fn dynamic_slice_index_set_nested_if_else_if(mut slice: [Field], x: Field, y: Fi assert(slice[4] == 5); } -fn dynamic_slice_merge_two_ifs(mut slice: [Field], x: Field) { +fn dynamic_slice_merge_two_ifs(mut slice: [field], x: field) { if x as u32 > 10 { assert(slice[x] == 0); slice[x] = 2; @@ -245,7 +245,7 @@ fn dynamic_slice_merge_two_ifs(mut slice: [Field], x: Field) { assert(slice[slice.len() - 1] == 20); } -fn dynamic_slice_merge_mutate_between_ifs(mut slice: [Field], x: Field, y: Field) { +fn dynamic_slice_merge_mutate_between_ifs(mut slice: [field], x: field, y: field) { if x != y { slice[x] = 50; slice = slice.push_back(y); @@ -277,7 +277,7 @@ fn dynamic_slice_merge_mutate_between_ifs(mut slice: [Field], x: Field, y: Field assert(slice[slice.len() - 1] == 60); } -fn dynamic_slice_merge_push_then_pop(mut slice: [Field], x: Field, y: Field) { +fn dynamic_slice_merge_push_then_pop(mut slice: [field], x: field, y: field) { if x != y { slice[x] = 5; slice = slice.push_back(y); diff --git a/test_programs/execution_success/slices/src/main.nr b/test_programs/execution_success/slices/src/main.nr index eca42a660c4..429b0ea563f 100644 --- a/test_programs/execution_success/slices/src/main.nr +++ b/test_programs/execution_success/slices/src/main.nr @@ -1,7 +1,7 @@ use dep::std::slice; use dep::std; -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let mut slice = [0; 2]; assert(slice[0] == 0); assert(slice[0] != 1); @@ -83,12 +83,12 @@ fn regression_2083() { assert(x.1 == 6); } // The parameters to this function must come from witness values (inputs to main) -fn regression_merge_slices(x: Field, y: Field) { +fn regression_merge_slices(x: field, y: field) { merge_slices_if(x, y); merge_slices_else(x); } -fn merge_slices_if(x: Field, y: Field) { +fn merge_slices_if(x: field, y: field) { let slice = merge_slices_return(x, y); assert(slice.len() == 3); assert(slice[2] == 10); @@ -128,7 +128,7 @@ fn merge_slices_if(x: Field, y: Field) { assert(slice.len() == 5); } -fn merge_slices_else(x: Field) { +fn merge_slices_else(x: field) { let slice = merge_slices_return(x, 5); assert(slice[0] == 0); assert(slice[1] == 0); @@ -143,7 +143,7 @@ fn merge_slices_else(x: Field) { assert(slice.len() == 3); } // Test returning a merged slice without a mutation -fn merge_slices_return(x: Field, y: Field) -> [Field] { +fn merge_slices_return(x: field, y: field) -> [field] { let slice = [0; 2]; if x != y { if x != 20 { slice.push_back(y) } else { slice } @@ -152,7 +152,7 @@ fn merge_slices_return(x: Field, y: Field) -> [Field] { } } // Test mutating a slice inside of an if statement -fn merge_slices_mutate(x: Field, y: Field) -> [Field] { +fn merge_slices_mutate(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { slice = slice.push_back(y); @@ -163,7 +163,7 @@ fn merge_slices_mutate(x: Field, y: Field) -> [Field] { slice } // Test mutating a slice inside of a loop in an if statement -fn merge_slices_mutate_in_loop(x: Field, y: Field) -> [Field] { +fn merge_slices_mutate_in_loop(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { for i in 0..5 { @@ -175,7 +175,7 @@ fn merge_slices_mutate_in_loop(x: Field, y: Field) -> [Field] { slice } -fn merge_slices_mutate_two_ifs(x: Field, y: Field) -> [Field] { +fn merge_slices_mutate_two_ifs(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { slice = slice.push_back(y); @@ -194,7 +194,7 @@ fn merge_slices_mutate_two_ifs(x: Field, y: Field) -> [Field] { slice } -fn merge_slices_mutate_between_ifs(x: Field, y: Field) -> [Field] { +fn merge_slices_mutate_between_ifs(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { slice = slice.push_back(y); @@ -220,7 +220,7 @@ fn merge_slices_mutate_between_ifs(x: Field, y: Field) -> [Field] { slice } -fn merge_slices_push_then_pop(x: Field, y: Field) { +fn merge_slices_push_then_pop(x: field, y: field) { let mut slice = [0; 2]; if x != y { slice = slice.push_back(y); @@ -244,7 +244,7 @@ fn merge_slices_push_then_pop(x: Field, y: Field) { assert(elem == x); } -fn merge_slices_push_then_insert(x: Field, y: Field) -> [Field] { +fn merge_slices_push_then_insert(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { slice = slice.push_back(y); @@ -267,7 +267,7 @@ fn merge_slices_push_then_insert(x: Field, y: Field) -> [Field] { slice } -fn merge_slices_remove_between_ifs(x: Field, y: Field) -> [Field] { +fn merge_slices_remove_between_ifs(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { slice = slice.push_back(y); diff --git a/test_programs/execution_success/strings/src/main.nr b/test_programs/execution_success/strings/src/main.nr index cff229d368a..d25c0fb4166 100644 --- a/test_programs/execution_success/strings/src/main.nr +++ b/test_programs/execution_success/strings/src/main.nr @@ -2,7 +2,7 @@ use dep::std; // Test global string literals global HELLO_WORLD = "hello world"; -fn main(message: pub str<11>, y: Field, hex_as_string: str<4>, hex_as_field: Field) { +fn main(message: pub str<11>, y: field, hex_as_string: str<4>, hex_as_field: field) { let mut bad_message = "hello world"; assert(message == "hello world"); @@ -65,7 +65,7 @@ fn test_prints_array() { std::println(hash); } -fn failed_constraint(hex_as_field: Field) { +fn failed_constraint(hex_as_field: field) { // When this method is called from a test method or with constant values // a `Failed constraint` compile error will be caught before this `println` // is executed as the input will be a constant. diff --git a/test_programs/execution_success/struct/src/main.nr b/test_programs/execution_success/struct/src/main.nr index de08f42f79d..866d266073c 100644 --- a/test_programs/execution_success/struct/src/main.nr +++ b/test_programs/execution_success/struct/src/main.nr @@ -9,7 +9,7 @@ struct Pair { } impl Foo { - fn default(x: Field, y: Field) -> Self { + fn default(x: field, y: field) -> Self { Self { bar: 0, array: [x, y] } } } @@ -19,7 +19,7 @@ impl Pair { p.first } - fn bar(self) -> Field { + fn bar(self) -> field { self.foo().bar } } @@ -33,7 +33,7 @@ struct MyStruct { my_int: u32, my_nest: Nested, } -fn test_struct_in_tuple(a_bool: bool, x: Field, y: Field) -> (MyStruct, bool) { +fn test_struct_in_tuple(a_bool: bool, x: field, y: field) -> (MyStruct, bool) { let my_struct = MyStruct { my_bool: a_bool, my_int: 5, my_nest: Nested { a: x, b: y } }; (my_struct, a_bool) } @@ -50,7 +50,7 @@ fn get_dog() -> Animal { struct Unit; -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let unit = Unit {}; let first = Foo::default(x, y); diff --git a/test_programs/execution_success/struct_array_inputs/src/main.nr b/test_programs/execution_success/struct_array_inputs/src/main.nr index 4a367558671..85dc59d8f0b 100644 --- a/test_programs/execution_success/struct_array_inputs/src/main.nr +++ b/test_programs/execution_success/struct_array_inputs/src/main.nr @@ -3,6 +3,6 @@ struct Foo { baz: Field, } -fn main(foos: [Foo; 3]) -> pub Field { +fn main(foos: [Foo; 3]) -> pub field { foos[2].bar + foos[2].baz } diff --git a/test_programs/execution_success/struct_inputs/src/main.nr b/test_programs/execution_success/struct_inputs/src/main.nr index 5b03483cbaf..d67d96df057 100644 --- a/test_programs/execution_success/struct_inputs/src/main.nr +++ b/test_programs/execution_success/struct_inputs/src/main.nr @@ -6,7 +6,7 @@ struct myStruct { message: str<5>, } -fn main(x: Field, y: pub myStruct, z: pub foo::bar::barStruct, a: pub foo::fooStruct) -> pub Field { +fn main(x: field, y: pub myStruct, z: pub foo::bar::barStruct, a: pub foo::fooStruct) -> pub field { let struct_from_bar = foo::bar::barStruct { val: 1, array: [0, 1], message: "hello" }; check_inner_struct(a, z); diff --git a/test_programs/execution_success/to_be_bytes/src/main.nr b/test_programs/execution_success/to_be_bytes/src/main.nr index 64d54ddff66..5d00298e3a7 100644 --- a/test_programs/execution_success/to_be_bytes/src/main.nr +++ b/test_programs/execution_success/to_be_bytes/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field) -> pub [u8; 31] { +fn main(x: field) -> pub [u8; 31] { // The result of this byte array will be big-endian let byte_array = x.to_be_bytes(31); let mut bytes = [0; 31]; diff --git a/test_programs/execution_success/to_bytes_consistent/src/main.nr b/test_programs/execution_success/to_bytes_consistent/src/main.nr index 638b34c9bab..6f619f47a5f 100644 --- a/test_programs/execution_success/to_bytes_consistent/src/main.nr +++ b/test_programs/execution_success/to_bytes_consistent/src/main.nr @@ -2,7 +2,7 @@ // between a `to_be_bytes` call (which is radix decomposition under the hood) // with constant inputs or with witness inputs. // x = 2040124 -fn main(x: Field) { +fn main(x: field) { let byte_array = x.to_be_bytes(31); let x_as_constant = 2040124; let constant_byte_array = x_as_constant.to_be_bytes(31); diff --git a/test_programs/execution_success/to_bytes_integration/src/main.nr b/test_programs/execution_success/to_bytes_integration/src/main.nr index d6a757c6f55..b16fb4782e5 100644 --- a/test_programs/execution_success/to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/to_bytes_integration/src/main.nr @@ -1,6 +1,6 @@ use dep::std; -fn main(x: Field, a: Field) { +fn main(x: field, a: field) { let y: Field = 2040124; let be_byte_array = y.to_be_bytes(31); let le_byte_array = x.to_le_bytes(31); diff --git a/test_programs/execution_success/to_le_bytes/src/main.nr b/test_programs/execution_success/to_le_bytes/src/main.nr index a0b48efe528..94b8661e980 100644 --- a/test_programs/execution_success/to_le_bytes/src/main.nr +++ b/test_programs/execution_success/to_le_bytes/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, cond: bool) -> pub [u8; 31] { +fn main(x: field, cond: bool) -> pub [u8; 31] { // The result of this byte array will be little-endian let byte_array = x.to_le_bytes(31); assert(byte_array.len() == 31); diff --git a/test_programs/execution_success/trait_as_return_type/src/main.nr b/test_programs/execution_success/trait_as_return_type/src/main.nr index f6828a356c1..1b2738c2f77 100644 --- a/test_programs/execution_success/trait_as_return_type/src/main.nr +++ b/test_programs/execution_success/trait_as_return_type/src/main.nr @@ -34,7 +34,7 @@ fn factory_b() -> impl SomeTrait { B {} } -fn factory_c(x: Field) -> impl SomeTrait { +fn factory_c(x: field) -> impl SomeTrait { C { x } } // x = 15 diff --git a/test_programs/execution_success/traits_in_crates_1/src/main.nr b/test_programs/execution_success/traits_in_crates_1/src/main.nr index 7ba2f63c5c0..284b1b28d5b 100644 --- a/test_programs/execution_success/traits_in_crates_1/src/main.nr +++ b/test_programs/execution_success/traits_in_crates_1/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let mut V = dep::crate2::MyStruct { Q: x }; V.Add10(); assert(V.Q == y); diff --git a/test_programs/execution_success/traits_in_crates_2/src/main.nr b/test_programs/execution_success/traits_in_crates_2/src/main.nr index 7ba2f63c5c0..284b1b28d5b 100644 --- a/test_programs/execution_success/traits_in_crates_2/src/main.nr +++ b/test_programs/execution_success/traits_in_crates_2/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let mut V = dep::crate2::MyStruct { Q: x }; V.Add10(); assert(V.Q == y); diff --git a/test_programs/execution_success/tuple_inputs/src/main.nr b/test_programs/execution_success/tuple_inputs/src/main.nr index 38fec58f14f..9e61be60eb1 100644 --- a/test_programs/execution_success/tuple_inputs/src/main.nr +++ b/test_programs/execution_success/tuple_inputs/src/main.nr @@ -8,7 +8,7 @@ struct Foo { bar: Bar, } -fn main(pair: (Field, Field), x: [(u8, u8, u8); 2], struct_pair: (Foo, Bar)) -> pub (Field, u8) { +fn main(pair: (field, field), x: [(u8, u8, u8); 2], struct_pair: (Foo, Bar)) -> pub (field, u8) { let mut start_val = 0; for i in 0..2 { assert(x[i].0 == start_val); diff --git a/test_programs/execution_success/tuples/src/main.nr b/test_programs/execution_success/tuples/src/main.nr index 5526fcad422..60bc4d1e7e3 100644 --- a/test_programs/execution_success/tuples/src/main.nr +++ b/test_programs/execution_success/tuples/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let pair = (x, y); assert(pair.0 == 1); assert(pair.1 == 0); diff --git a/test_programs/execution_success/type_aliases/src/main.nr b/test_programs/execution_success/type_aliases/src/main.nr index ee62b0b7260..098e043ceeb 100644 --- a/test_programs/execution_success/type_aliases/src/main.nr +++ b/test_programs/execution_success/type_aliases/src/main.nr @@ -10,7 +10,7 @@ struct MyStruct { foo: Bar, } -fn main(x: [Field; 2]) { +fn main(x: [field; 2]) { let a: Foo = [1, 2]; assert(a[0] != x[0]); diff --git a/test_programs/execution_success/unsafe_range_constraint/src/main.nr b/test_programs/execution_success/unsafe_range_constraint/src/main.nr index ead5613bcce..1af5f24d829 100644 --- a/test_programs/execution_success/unsafe_range_constraint/src/main.nr +++ b/test_programs/execution_success/unsafe_range_constraint/src/main.nr @@ -1,5 +1,5 @@ // Test that we can apply a range constraint to a field using // a builtin. -fn main(x: Field) { +fn main(x: field) { x.assert_max_bit_size(48); } diff --git a/test_programs/noir_test_success/field_comparisons/src/main.nr b/test_programs/noir_test_success/field_comparisons/src/main.nr index 105d82ca755..bf623fae21d 100644 --- a/test_programs/noir_test_success/field_comparisons/src/main.nr +++ b/test_programs/noir_test_success/field_comparisons/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::field::bn254::{TWO_POW_128, assert_gt}; +use dep::std::field_element::bn254::{TWO_POW_128, assert_gt}; #[test(should_fail)] fn test_assert_gt_should_fail_eq() { From 8190761d340847ac6a71d1ebb769e97ab2a0b371 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 26 Feb 2024 21:58:39 +0000 Subject: [PATCH 10/19] chore: format stdlib --- noir_stdlib/src/ec.nr | 10 ++-- noir_stdlib/src/ec/montcurve.nr | 24 +++++----- noir_stdlib/src/ec/swcurve.nr | 20 ++++---- noir_stdlib/src/ec/tecurve.nr | 24 +++++----- noir_stdlib/src/eddsa.nr | 12 ++--- noir_stdlib/src/field_element.nr | 4 +- noir_stdlib/src/field_element/bn254.nr | 24 +++++----- noir_stdlib/src/grumpkin_scalar.nr | 6 +-- noir_stdlib/src/grumpkin_scalar_mul.nr | 2 +- noir_stdlib/src/hash.nr | 14 +++--- noir_stdlib/src/hash/mimc.nr | 4 +- noir_stdlib/src/hash/poseidon.nr | 30 ++++++------ noir_stdlib/src/hash/poseidon/bn254.nr | 48 +++++++++---------- noir_stdlib/src/hash/poseidon/bn254/consts.nr | 2 +- noir_stdlib/src/hash/poseidon/bn254/perm.nr | 32 ++++++------- noir_stdlib/src/hash/poseidon2.nr | 23 ++++----- noir_stdlib/src/lib.nr | 6 +-- noir_stdlib/src/merkle.nr | 2 +- noir_stdlib/src/scalar_mul.nr | 8 ++-- noir_stdlib/src/schnorr.nr | 4 +- noir_stdlib/src/test.nr | 10 ++-- noir_stdlib/src/uint128.nr | 14 +++--- 22 files changed, 158 insertions(+), 165 deletions(-) diff --git a/noir_stdlib/src/ec.nr b/noir_stdlib/src/ec.nr index be2ba8c1ccf..91727a04a78 100644 --- a/noir_stdlib/src/ec.nr +++ b/noir_stdlib/src/ec.nr @@ -143,22 +143,22 @@ global C5 = 19103219067921713944291392827692070036145651957329286315305642004821 // out //} // TODO: Make this built-in. -pub fn safe_inverse(x: Field) -> Field { +pub fn safe_inverse(x: field) -> field { if x == 0 { 0 } else { 1 / x } } // Boolean indicating whether Field element is a square, i.e. whether there exists a y in Field s.t. x = y*y. -pub fn is_square(x: Field) -> bool { +pub fn is_square(x: field) -> bool { let v = pow(x, 0 - 1 / 2); v * (v - 1) == 0 } // Power function of two Field arguments of arbitrary size. // Adapted from std::field_element::pow_32. -pub fn pow(x: Field, y: Field) -> Field { +pub fn pow(x: field, y: field) -> field { // As in tests with minor modifications let N_BITS = crate::field_element::modulus_num_bits(); - let mut r = 1 as Field; + let mut r = 1 as field; let b = y.to_le_bits(N_BITS as u32); for i in 0..N_BITS { @@ -173,7 +173,7 @@ pub fn pow(x: Field, y: Field) -> Field { // as well as C3 = (C2 - 1)/2, where C2 = (p-1)/(2^c1), // and C5 = ZETA^C2, where ZETA is a non-square element of Field. // These are pre-computed above as globals. -pub fn sqrt(x: Field) -> Field { +pub fn sqrt(x: field) -> field { let mut z = pow(x, C3); let mut t = z * z * x; z *= x; diff --git a/noir_stdlib/src/ec/montcurve.nr b/noir_stdlib/src/ec/montcurve.nr index 7dc756781c0..918038d7f99 100644 --- a/noir_stdlib/src/ec/montcurve.nr +++ b/noir_stdlib/src/ec/montcurve.nr @@ -30,7 +30,7 @@ mod affine { impl Point { // Point constructor - pub fn new(x: Field, y: Field) -> Self { + pub fn new(x: field, y: field) -> Self { Self { x, y, infty: false } } @@ -81,7 +81,7 @@ mod affine { impl Curve { // Curve constructor - pub fn new(j: Field, k: Field, gen: Point) -> Self { + pub fn new(j: field, k: field, gen: Point) -> Self { // Check curve coefficients assert(k != 0); assert(j * j != 4); @@ -119,12 +119,12 @@ mod affine { } // Scalar multiplication (p + ... + p n times) - fn mul(self, n: Field, p: Point) -> Point { + fn mul(self, n: field, p: Point) -> Point { self.into_tecurve().mul(n, p.into_tecurve()).into_montcurve() } // Multi-scalar multiplication (n[0]*p[0] + ... + n[N]*p[N], where * denotes scalar multiplication) - fn msm(self, n: [Field; N], p: [Point; N]) -> Point { + fn msm(self, n: [field; N], p: [Point; N]) -> Point { let mut out = Point::zero(); for i in 0..N { @@ -174,7 +174,7 @@ mod affine { } // Elligator 2 map-to-curve method; see . - fn elligator2_map(self, u: Field) -> Point { + fn elligator2_map(self, u: field) -> Point { let j = self.j; let k = self.k; let z = ZETA; // Non-square Field element required for map @@ -205,7 +205,7 @@ mod affine { } // SWU map-to-curve method (via rational map) - fn swu_map(self, z: Field, u: Field) -> Point { + fn swu_map(self, z: field, u: field) -> Point { self.map_from_swcurve(self.into_swcurve().swu_map(z, u)) } } @@ -237,7 +237,7 @@ mod curvegroup { impl Point { // Point constructor - pub fn new(x: Field, y: Field, z: Field) -> Self { + pub fn new(x: field, y: field, z: field) -> Self { Self { x, y, z } } @@ -282,7 +282,7 @@ mod curvegroup { impl Curve { // Curve constructor - pub fn new(j: Field, k: Field, gen: Point) -> Self { + pub fn new(j: field, k: field, gen: Point) -> Self { // Check curve coefficients assert(k != 0); assert(j * j != 4); @@ -320,12 +320,12 @@ mod curvegroup { } // Scalar multiplication (p + ... + p n times) - pub fn mul(self, n: Field, p: Point) -> Point { + pub fn mul(self, n: field, p: Point) -> Point { self.into_tecurve().mul(n, p.into_tecurve()).into_montcurve() } // Multi-scalar multiplication (n[0]*p[0] + ... + n[N]*p[N], where * denotes scalar multiplication) - fn msm(self, n: [Field; N], p: [Point; N]) -> Point { + fn msm(self, n: [field; N], p: [Point; N]) -> Point { let mut out = Point::zero(); for i in 0..N { @@ -367,12 +367,12 @@ mod curvegroup { } // Elligator 2 map-to-curve method - fn elligator2_map(self, u: Field) -> Point { + fn elligator2_map(self, u: field) -> Point { self.into_affine().elligator2_map(u).into_group() } // SWU map-to-curve method (via rational map) - fn swu_map(self, z: Field, u: Field) -> Point { + fn swu_map(self, z: field, u: field) -> Point { self.into_affine().swu_map(z, u).into_group() } } diff --git a/noir_stdlib/src/ec/swcurve.nr b/noir_stdlib/src/ec/swcurve.nr index 8b34245a71e..2089fc53609 100644 --- a/noir_stdlib/src/ec/swcurve.nr +++ b/noir_stdlib/src/ec/swcurve.nr @@ -26,7 +26,7 @@ mod affine { impl Point { // Point constructor - pub fn new(x: Field, y: Field) -> Self { + pub fn new(x: field, y: field) -> Self { Self { x, y, infty: false } } @@ -70,7 +70,7 @@ mod affine { impl Curve { // Curve constructor - pub fn new(a: Field, b: Field, gen: Point) -> Curve { + pub fn new(a: field, b: field, gen: Point) -> Curve { // Check curve coefficients assert(4 * a * a * a + 27 * b * b != 0); @@ -139,12 +139,12 @@ mod affine { } // Scalar multiplication (p + ... + p n times) - pub fn mul(self, n: Field, p: Point) -> Point { + pub fn mul(self, n: field, p: Point) -> Point { self.into_group().mul(n, p.into_group()).into_affine() } // Multi-scalar multiplication (n[0]*p[0] + ... + n[N]*p[N], where * denotes scalar multiplication) - pub fn msm(self, n: [Field; N], p: [Point; N]) -> Point { + pub fn msm(self, n: [field; N], p: [Point; N]) -> Point { let mut out = Point::zero(); for i in 0..N { @@ -162,7 +162,7 @@ mod affine { // Simplified Shallue-van de Woestijne-Ulas map-to-curve method; see . // First determine non-square z != -1 in Field s.t. g(x) - z irreducible over Field and g(b/(z*a)) is square, // where g(x) = x^3 + a*x + b. swu_map(c,z,.) then maps a Field element to a point on curve c. - fn swu_map(self, z: Field, u: Field) -> Point { + fn swu_map(self, z: field, u: field) -> Point { // Check whether curve is admissible assert(self.a * self.b != 0); @@ -211,7 +211,7 @@ mod curvegroup { impl Point { // Point constructor - pub fn new(x: Field, y: Field, z: Field) -> Self { + pub fn new(x: field, y: field, z: field) -> Self { Self { x, y, z } } @@ -254,7 +254,7 @@ mod curvegroup { impl Curve { // Curve constructor - pub fn new(a: Field, b: Field, gen: Point) -> Curve { + pub fn new(a: field, b: field, gen: Point) -> Curve { // Check curve coefficients assert(4 * a * a * a + 27 * b * b != 0); @@ -349,7 +349,7 @@ mod curvegroup { } // Scalar multiplication (p + ... + p n times) - pub fn mul(self, n: Field, p: Point) -> Point { + pub fn mul(self, n: field, p: Point) -> Point { let N_BITS = crate::field_element::modulus_num_bits(); // TODO: temporary workaround until issue 1354 is solved @@ -363,7 +363,7 @@ mod curvegroup { } // Multi-scalar multiplication (n[0]*p[0] + ... + n[N]*p[N], where * denotes scalar multiplication) - fn msm(self, n: [Field; N], p: [Point; N]) -> Point { + fn msm(self, n: [field; N], p: [Point; N]) -> Point { let mut out = Point::zero(); for i in 0..N { @@ -379,7 +379,7 @@ mod curvegroup { } // Simplified SWU map-to-curve method - fn swu_map(self, z: Field, u: Field) -> Point { + fn swu_map(self, z: field, u: field) -> Point { self.into_affine().swu_map(z, u).into_group() } } diff --git a/noir_stdlib/src/ec/tecurve.nr b/noir_stdlib/src/ec/tecurve.nr index 3739e661de4..6abb704e898 100644 --- a/noir_stdlib/src/ec/tecurve.nr +++ b/noir_stdlib/src/ec/tecurve.nr @@ -27,7 +27,7 @@ mod affine { impl Point { // Point constructor - pub fn new(x: Field, y: Field) -> Self { + pub fn new(x: field, y: field) -> Self { Self { x, y } } @@ -79,7 +79,7 @@ mod affine { impl Curve { // Curve constructor - pub fn new(a: Field, d: Field, gen: Point) -> Curve { + pub fn new(a: field, d: field, gen: Point) -> Curve { // Check curve coefficients assert(a * d * (a - d) != 0); @@ -137,12 +137,12 @@ mod affine { } // Scalar multiplication (p + ... + p n times) - fn mul(self, n: Field, p: Point) -> Point { + fn mul(self, n: field, p: Point) -> Point { self.into_group().mul(n, p.into_group()).into_affine() } // Multi-scalar multiplication (n[0]*p[0] + ... + n[N]*p[N], where * denotes scalar multiplication) - fn msm(self, n: [Field; N], p: [Point; N]) -> Point { + fn msm(self, n: [field; N], p: [Point; N]) -> Point { let mut out = Point::zero(); for i in 0..N { @@ -182,12 +182,12 @@ mod affine { } // Elligator 2 map-to-curve method (via rational map) - fn elligator2_map(self, u: Field) -> Point { + fn elligator2_map(self, u: field) -> Point { self.into_montcurve().elligator2_map(u).into_tecurve() } // Simplified SWU map-to-curve method (via rational map) - fn swu_map(self, z: Field, u: Field) -> Point { + fn swu_map(self, z: field, u: field) -> Point { self.into_montcurve().swu_map(z, u).into_tecurve() } } @@ -221,7 +221,7 @@ mod curvegroup { impl Point { // Point constructor - pub fn new(x: Field, y: Field, t: Field, z: Field) -> Self { + pub fn new(x: field, y: field, t: field, z: field) -> Self { Self { x, y, t, z } } @@ -267,7 +267,7 @@ mod curvegroup { impl Curve { // Curve constructor - pub fn new(a: Field, d: Field, gen: Point) -> Curve { + pub fn new(a: field, d: field, gen: Point) -> Curve { // Check curve coefficients assert(a * d * (a - d) != 0); @@ -353,7 +353,7 @@ mod curvegroup { } // Scalar multiplication (p + ... + p n times) - pub fn mul(self, n: Field, p: Point) -> Point { + pub fn mul(self, n: field, p: Point) -> Point { let N_BITS = crate::field_element::modulus_num_bits(); // TODO: temporary workaround until issue 1354 is solved @@ -367,7 +367,7 @@ mod curvegroup { } // Multi-scalar multiplication (n[0]*p[0] + ... + n[N]*p[N], where * denotes scalar multiplication) - fn msm(self, n: [Field; N], p: [Point; N]) -> Point { + fn msm(self, n: [field; N], p: [Point; N]) -> Point { let mut out = Point::zero(); for i in 0..N { @@ -403,12 +403,12 @@ mod curvegroup { } // Elligator 2 map-to-curve method (via rational maps) - fn elligator2_map(self, u: Field) -> Point { + fn elligator2_map(self, u: field) -> Point { self.into_montcurve().elligator2_map(u).into_tecurve() } // Simplified SWU map-to-curve method (via rational map) - fn swu_map(self, z: Field, u: Field) -> Point { + fn swu_map(self, z: field, u: field) -> Point { self.into_montcurve().swu_map(z, u).into_tecurve() } } diff --git a/noir_stdlib/src/eddsa.nr b/noir_stdlib/src/eddsa.nr index 657e791e9c7..cb9ffc5322f 100644 --- a/noir_stdlib/src/eddsa.nr +++ b/noir_stdlib/src/eddsa.nr @@ -4,12 +4,12 @@ use crate::ec::tecurve::affine::Point as TEPoint; // Returns true if signature is valid pub fn eddsa_poseidon_verify( - pub_key_x: Field, - pub_key_y: Field, - signature_s: Field, - signature_r8_x: Field, - signature_r8_y: Field, - message: Field + pub_key_x: field, + pub_key_y: field, + signature_s: field, + signature_r8_x: field, + signature_r8_y: field, + message: field ) -> bool { // Verifies by testing: // S * B8 = R8 + H(R8, A, m) * A8 diff --git a/noir_stdlib/src/field_element.nr b/noir_stdlib/src/field_element.nr index 2069d9a0828..5aa99c0d308 100644 --- a/noir_stdlib/src/field_element.nr +++ b/noir_stdlib/src/field_element.nr @@ -74,7 +74,7 @@ impl field { self as u1 } - pub fn lt(self, another: Field) -> bool { + pub fn lt(self, another: field) -> bool { if crate::compat::is_bn254() { bn254_lt(self, another) } else { @@ -113,7 +113,7 @@ pub fn bytes32_to_field(bytes32: [u8; 32]) -> field { low + high * v } -fn lt_fallback(x: Field, y: Field) -> bool { +fn lt_fallback(x: field, y: field) -> bool { let num_bytes = (modulus_num_bits() as u32 + 7) / 8; let x_bytes = x.to_le_bytes(num_bytes); let y_bytes = y.to_le_bytes(num_bytes); diff --git a/noir_stdlib/src/field_element/bn254.nr b/noir_stdlib/src/field_element/bn254.nr index 9e1445fd3ba..c021ab5567f 100644 --- a/noir_stdlib/src/field_element/bn254.nr +++ b/noir_stdlib/src/field_element/bn254.nr @@ -5,7 +5,7 @@ global PHI: Field = 64323764613183177041862057485226039389; global TWO_POW_128: Field = 0x100000000000000000000000000000000; /// A hint for decomposing a single field into two 16 byte fields. -unconstrained fn decompose_unsafe(x: Field) -> (Field, Field) { +unconstrained fn decompose_unsafe(x: field) -> (field, field) { let x_bytes = x.to_le_bytes(32); let mut low: Field = 0; @@ -22,7 +22,7 @@ unconstrained fn decompose_unsafe(x: Field) -> (Field, Field) { } /// Decompose a single field into two 16 byte fields. -pub fn decompose(x: Field) -> (Field, Field) { +pub fn decompose(x: field) -> (field, field) { // Take hints of the decomposition let (xlo, xhi) = decompose_unsafe(x); let borrow = lt_unsafe(PLO, xlo, 16); @@ -35,8 +35,8 @@ pub fn decompose(x: Field) -> (Field, Field) { assert_eq(x, xlo + TWO_POW_128 * xhi); // Check that (xlo < plo && xhi <= phi) || (xlo >= plo && xhi < phi) - let rlo = PLO - xlo + (borrow as Field) * TWO_POW_128; - let rhi = PHI - xhi - (borrow as Field); + let rlo = PLO - xlo + (borrow as field) * TWO_POW_128; + let rhi = PHI - xhi - (borrow as field); rlo.assert_max_bit_size(128); rhi.assert_max_bit_size(128); @@ -44,7 +44,7 @@ pub fn decompose(x: Field) -> (Field, Field) { (xlo, xhi) } -unconstrained fn lt_unsafe(x: Field, y: Field, num_bytes: u32) -> bool { +unconstrained fn lt_unsafe(x: field, y: field, num_bytes: u32) -> bool { let x_bytes = x.__to_le_radix(256, num_bytes); let y_bytes = y.__to_le_radix(256, num_bytes); let mut x_is_lt = false; @@ -63,11 +63,11 @@ unconstrained fn lt_unsafe(x: Field, y: Field, num_bytes: u32) -> bool { x_is_lt } -unconstrained fn lte_unsafe(x: Field, y: Field, num_bytes: u32) -> bool { +unconstrained fn lte_unsafe(x: field, y: field, num_bytes: u32) -> bool { lt_unsafe(x, y, num_bytes) | (x == y) } -pub fn assert_gt(a: Field, b: Field) { +pub fn assert_gt(a: field, b: field) { // Decompose a and b let (alo, ahi) = decompose(a); let (blo, bhi) = decompose(b); @@ -75,18 +75,18 @@ pub fn assert_gt(a: Field, b: Field) { let borrow = lte_unsafe(alo, blo, 16); // Assert that (alo > blo && ahi >= bhi) || (alo <= blo && ahi > bhi) - let rlo = alo - blo - 1 + (borrow as Field) * TWO_POW_128; - let rhi = ahi - bhi - (borrow as Field); + let rlo = alo - blo - 1 + (borrow as field) * TWO_POW_128; + let rhi = ahi - bhi - (borrow as field); rlo.assert_max_bit_size(128); rhi.assert_max_bit_size(128); } -pub fn assert_lt(a: Field, b: Field) { +pub fn assert_lt(a: field, b: field) { assert_gt(b, a); } -pub fn gt(a: Field, b: Field) -> bool { +pub fn gt(a: field, b: field) -> bool { if a == b { false } else if lt_unsafe(a, b, 32) { @@ -98,6 +98,6 @@ pub fn gt(a: Field, b: Field) -> bool { } } -pub fn lt(a: Field, b: Field) -> bool { +pub fn lt(a: field, b: field) -> bool { gt(b, a) } diff --git a/noir_stdlib/src/grumpkin_scalar.nr b/noir_stdlib/src/grumpkin_scalar.nr index d05158488f4..e425c36e546 100644 --- a/noir_stdlib/src/grumpkin_scalar.nr +++ b/noir_stdlib/src/grumpkin_scalar.nr @@ -4,7 +4,7 @@ struct GrumpkinScalar { } impl GrumpkinScalar { - pub fn new(low: Field, high: Field) -> Self { + pub fn new(low: field, high: field) -> Self { // TODO: check that the low and high value fit within the grumpkin modulus GrumpkinScalar { low, high } } @@ -12,10 +12,10 @@ impl GrumpkinScalar { global GRUMPKIN_SCALAR_SERIALIZED_LEN: Field = 2; -pub fn deserialize_grumpkin_scalar(fields: [Field; GRUMPKIN_SCALAR_SERIALIZED_LEN]) -> GrumpkinScalar { +pub fn deserialize_grumpkin_scalar(fields: [field; GRUMPKIN_SCALAR_SERIALIZED_LEN]) -> GrumpkinScalar { GrumpkinScalar { low: fields[0], high: fields[1] } } -pub fn serialize_grumpkin_scalar(scalar: GrumpkinScalar) -> [Field; GRUMPKIN_SCALAR_SERIALIZED_LEN] { +pub fn serialize_grumpkin_scalar(scalar: GrumpkinScalar) -> [field; GRUMPKIN_SCALAR_SERIALIZED_LEN] { [scalar.low, scalar.high] } diff --git a/noir_stdlib/src/grumpkin_scalar_mul.nr b/noir_stdlib/src/grumpkin_scalar_mul.nr index 06d30d62332..46e60d5b6de 100644 --- a/noir_stdlib/src/grumpkin_scalar_mul.nr +++ b/noir_stdlib/src/grumpkin_scalar_mul.nr @@ -1,7 +1,7 @@ use crate::grumpkin_scalar::GrumpkinScalar; use crate::scalar_mul::fixed_base_embedded_curve; -pub fn grumpkin_fixed_base(scalar: GrumpkinScalar) -> [Field; 2] { +pub fn grumpkin_fixed_base(scalar: GrumpkinScalar) -> [field; 2] { // TODO: this should use both the low and high limbs to do the scalar multiplication fixed_base_embedded_curve(scalar.low, scalar.high) } diff --git a/noir_stdlib/src/hash.nr b/noir_stdlib/src/hash.nr index 87ccc4ed078..aba733ff355 100644 --- a/noir_stdlib/src/hash.nr +++ b/noir_stdlib/src/hash.nr @@ -29,31 +29,31 @@ struct PedersenPoint { y : Field, } -pub fn pedersen_commitment(input: [Field; N]) -> PedersenPoint +pub fn pedersen_commitment(input: [field; N]) -> PedersenPoint // docs:end:pedersen_commitment { pedersen_commitment_with_separator(input, 0) } #[foreign(pedersen_commitment)] -pub fn __pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> [Field; 2] {} +pub fn __pedersen_commitment_with_separator(input: [field; N], separator: u32) -> [field; 2] {} -pub fn pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> PedersenPoint { +pub fn pedersen_commitment_with_separator(input: [field; N], separator: u32) -> PedersenPoint { let values = __pedersen_commitment_with_separator(input, separator); PedersenPoint { x: values[0], y: values[1] } } // docs:start:pedersen_hash -pub fn pedersen_hash(input: [Field; N]) -> Field +pub fn pedersen_hash(input: [field; N]) -> field // docs:end:pedersen_hash { pedersen_hash_with_separator(input, 0) } #[foreign(pedersen_hash)] -pub fn pedersen_hash_with_separator(input: [Field; N], separator: u32) -> Field {} +pub fn pedersen_hash_with_separator(input: [field; N], separator: u32) -> field {} -pub fn hash_to_field(input: [Field; N]) -> Field { +pub fn hash_to_field(input: [field; N]) -> field { let mut inputs_as_bytes = []; for i in 0..N { @@ -74,7 +74,7 @@ pub fn keccak256(input: [u8; N], message_size: u32) -> [u8; 32] {} #[foreign(poseidon2_permutation)] -pub fn poseidon2_permutation(_input: [Field; N], _state_length: u32) -> [Field; N] {} +pub fn poseidon2_permutation(_input: [field; N], _state_length: u32) -> [field; N] {} #[foreign(sha256_compression)] pub fn sha256_compression(_input: [u32; 16], _state: [u32; 8]) -> [u32; 8] {} diff --git a/noir_stdlib/src/hash/mimc.nr b/noir_stdlib/src/hash/mimc.nr index 10c0a48917c..592895ad820 100644 --- a/noir_stdlib/src/hash/mimc.nr +++ b/noir_stdlib/src/hash/mimc.nr @@ -3,7 +3,7 @@ // You must use constants generated for the native field // Rounds number should be ~ log(p)/log(exp) // For 254 bit primes, exponent 7 and 91 rounds seems to be recommended -fn mimc(x: Field, k: Field, constants: [Field; N], exp: Field) -> Field { +fn mimc(x: field, k: field, constants: [field; N], exp: field) -> field { //round 0 let mut t = x + k; let mut h = t.pow_32(exp); @@ -18,7 +18,7 @@ fn mimc(x: Field, k: Field, constants: [Field; N], exp: Field) -> Field { global MIMC_BN254_ROUNDS = 91; //mimc implementation with hardcoded parameters for BN254 curve. #[field(bn254)] -pub fn mimc_bn254(array: [Field; N]) -> Field { +pub fn mimc_bn254(array: [field; N]) -> field { //mimc parameters let exponent = 7; //generated from seed "mimc" using keccak256 diff --git a/noir_stdlib/src/hash/poseidon.nr b/noir_stdlib/src/hash/poseidon.nr index aab60178534..ce57b64048d 100644 --- a/noir_stdlib/src/hash/poseidon.nr +++ b/noir_stdlib/src/hash/poseidon.nr @@ -11,26 +11,26 @@ struct PoseidonConfig { } pub fn config( - t: Field, + t: field, rf: u8, rp: u8, - alpha: Field, - ark: [Field; M], - mds: [Field; N] + alpha: field, + ark: [field; M], + mds: [field; N] ) -> PoseidonConfig { // Input checks let mul = crate::wrapping_mul(t as u8, (rf + rp)); assert(mul == ark.len() as u8); - assert(t * t == mds.len() as Field); + assert(t * t == mds.len() as field); assert(alpha != 0); PoseidonConfig { t, rf, rp, alpha, ark, mds } } // General Poseidon permutation on elements of type Field -fn permute(pos_conf: PoseidonConfig, mut state: [Field; O]) -> [Field; O] { +fn permute(pos_conf: PoseidonConfig, mut state: [field; O]) -> [field; O] { let PoseidonConfig {t, rf, rp, alpha, ark, mds} = pos_conf; - assert(t == state.len() as Field); + assert(t == state.len() as field); let mut count = 0; // for r in 0..rf + rp @@ -55,11 +55,11 @@ fn permute(pos_conf: PoseidonConfig, mut state: [Field; O]) -> [F // Absorption. Fully absorbs input message. fn absorb( pos_conf: PoseidonConfig, - mut state: [Field; O], // Initial state; usually [0; O] - rate: Field, // Rate - capacity: Field, // Capacity; usually 1 - msg: [Field; P] -) -> [Field; O] { + mut state: [field; O], // Initial state; usually [0; O] + rate: field, // Rate + capacity: field, // Capacity; usually 1 + msg: [field; P] +) -> [field; O] { assert(pos_conf.t == rate + capacity); let mut i = 0; @@ -82,13 +82,13 @@ fn absorb( state } // Check security of sponge instantiation -fn check_security(rate: Field, width: Field, security: Field) -> bool { +fn check_security(rate: field, width: field, security: field) -> bool { let n = modulus_num_bits(); - ((n - 1) as Field * (width - rate) / 2) as u8 > security as u8 + ((n - 1) as field * (width - rate) / 2) as u8 > security as u8 } // A*x where A is an n x n matrix in row-major order and x an n-vector -fn apply_matrix(a: [Field; M], x: [Field; N]) -> [Field; N] { +fn apply_matrix(a: [field; M], x: [field; N]) -> [field; N] { let mut y = x; for i in 0..x.len() { diff --git a/noir_stdlib/src/hash/poseidon/bn254.nr b/noir_stdlib/src/hash/poseidon/bn254.nr index 37b08e3c8fb..708d8dad120 100644 --- a/noir_stdlib/src/hash/poseidon/bn254.nr +++ b/noir_stdlib/src/hash/poseidon/bn254.nr @@ -7,12 +7,12 @@ use crate::hash::poseidon::apply_matrix; // Optimised permutation for this particular field; uses hardcoded rf and rp values, // which should agree with those in pos_conf. #[field(bn254)] -pub fn permute(pos_conf: PoseidonConfig, mut state: [Field; O]) -> [Field; O] { +pub fn permute(pos_conf: PoseidonConfig, mut state: [field; O]) -> [field; O] { let PoseidonConfig {t, rf: config_rf, rp: config_rp, alpha, ark, mds} = pos_conf; let rf: u8 = 8; let rp: u8 = [56, 57, 56, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68][state.len() - 2]; - assert(t == state.len() as Field); + assert(t == state.len() as field); assert(rf == config_rf); assert(rp == config_rp); @@ -58,11 +58,11 @@ pub fn permute(pos_conf: PoseidonConfig, mut state: [Field; O]) - #[field(bn254)] fn absorb( pos_conf: PoseidonConfig, - mut state: [Field; O], // Initial state; usually [0; O] - rate: Field, // Rate - capacity: Field, // Capacity; usually 1 - msg: [Field; P] // Arbitrary length message -) -> [Field; O] { + mut state: [field; O], // Initial state; usually [0; O] + rate: field, // Rate + capacity: field, // Capacity; usually 1 + msg: [field; P] // Arbitrary length message +) -> [field; O] { assert(pos_conf.t == rate + capacity); let mut i = 0; @@ -86,12 +86,12 @@ fn absorb( } // Variable-length Poseidon-128 sponge as suggested in second bullet point of §3 of https://eprint.iacr.org/2019/458.pdf #[field(bn254)] -pub fn sponge(msg: [Field; N]) -> Field { +pub fn sponge(msg: [field; N]) -> field { absorb(consts::x5_5_config(), [0; 5], 4, 1, msg)[1] } // Various instances of the Poseidon hash function // Consistent with Circom's implementation -pub fn hash_1(input: [Field; 1]) -> Field { +pub fn hash_1(input: [field; 1]) -> field { let mut state = [0; 2]; for i in 0..input.len() { state[i+1] = input[i]; @@ -100,7 +100,7 @@ pub fn hash_1(input: [Field; 1]) -> Field { perm::x5_2(state)[0] } -pub fn hash_2(input: [Field; 2]) -> Field { +pub fn hash_2(input: [field; 2]) -> field { let mut state = [0; 3]; for i in 0..input.len() { state[i+1] = input[i]; @@ -109,7 +109,7 @@ pub fn hash_2(input: [Field; 2]) -> Field { perm::x5_3(state)[0] } -pub fn hash_3(input: [Field; 3]) -> Field { +pub fn hash_3(input: [field; 3]) -> field { let mut state = [0; 4]; for i in 0..input.len() { state[i+1] = input[i]; @@ -118,7 +118,7 @@ pub fn hash_3(input: [Field; 3]) -> Field { perm::x5_4(state)[0] } -pub fn hash_4(input: [Field; 4]) -> Field { +pub fn hash_4(input: [field; 4]) -> field { let mut state = [0; 5]; for i in 0..input.len() { state[i+1] = input[i]; @@ -127,7 +127,7 @@ pub fn hash_4(input: [Field; 4]) -> Field { perm::x5_5(state)[0] } -pub fn hash_5(input: [Field; 5]) -> Field { +pub fn hash_5(input: [field; 5]) -> field { let mut state = [0; 6]; for i in 0..input.len() { state[i+1] = input[i]; @@ -136,7 +136,7 @@ pub fn hash_5(input: [Field; 5]) -> Field { perm::x5_6(state)[0] } -pub fn hash_6(input: [Field; 6]) -> Field { +pub fn hash_6(input: [field; 6]) -> field { let mut state = [0; 7]; for i in 0..input.len() { state[i+1] = input[i]; @@ -145,7 +145,7 @@ pub fn hash_6(input: [Field; 6]) -> Field { perm::x5_7(state)[0] } -pub fn hash_7(input: [Field; 7]) -> Field { +pub fn hash_7(input: [field; 7]) -> field { let mut state = [0; 8]; for i in 0..input.len() { state[i+1] = input[i]; @@ -154,7 +154,7 @@ pub fn hash_7(input: [Field; 7]) -> Field { perm::x5_8(state)[0] } -pub fn hash_8(input: [Field; 8]) -> Field { +pub fn hash_8(input: [field; 8]) -> field { let mut state = [0; 9]; for i in 0..input.len() { state[i+1] = input[i]; @@ -163,7 +163,7 @@ pub fn hash_8(input: [Field; 8]) -> Field { perm::x5_9(state)[0] } -pub fn hash_9(input: [Field; 9]) -> Field { +pub fn hash_9(input: [field; 9]) -> field { let mut state = [0; 10]; for i in 0..input.len() { state[i+1] = input[i]; @@ -172,7 +172,7 @@ pub fn hash_9(input: [Field; 9]) -> Field { perm::x5_10(state)[0] } -pub fn hash_10(input: [Field; 10]) -> Field { +pub fn hash_10(input: [field; 10]) -> field { let mut state = [0; 11]; for i in 0..input.len() { state[i+1] = input[i]; @@ -181,7 +181,7 @@ pub fn hash_10(input: [Field; 10]) -> Field { perm::x5_11(state)[0] } -pub fn hash_11(input: [Field; 11]) -> Field { +pub fn hash_11(input: [field; 11]) -> field { let mut state = [0; 12]; for i in 0..input.len() { state[i+1] = input[i]; @@ -190,7 +190,7 @@ pub fn hash_11(input: [Field; 11]) -> Field { perm::x5_12(state)[0] } -pub fn hash_12(input: [Field; 12]) -> Field { +pub fn hash_12(input: [field; 12]) -> field { let mut state = [0; 13]; for i in 0..input.len() { state[i+1] = input[i]; @@ -199,7 +199,7 @@ pub fn hash_12(input: [Field; 12]) -> Field { perm::x5_13(state)[0] } -pub fn hash_13(input: [Field; 13]) -> Field { +pub fn hash_13(input: [field; 13]) -> field { let mut state = [0; 14]; for i in 0..input.len() { state[i+1] = input[i]; @@ -208,7 +208,7 @@ pub fn hash_13(input: [Field; 13]) -> Field { perm::x5_14(state)[0] } -pub fn hash_14(input: [Field; 14]) -> Field { +pub fn hash_14(input: [field; 14]) -> field { let mut state = [0; 15]; for i in 0..input.len() { state[i+1] = input[i]; @@ -217,7 +217,7 @@ pub fn hash_14(input: [Field; 14]) -> Field { perm::x5_15(state)[0] } -pub fn hash_15(input: [Field; 15]) -> Field { +pub fn hash_15(input: [field; 15]) -> field { let mut state = [0; 16]; for i in 0..input.len() { state[i+1] = input[i]; @@ -226,7 +226,7 @@ pub fn hash_15(input: [Field; 15]) -> Field { perm::x5_16(state)[0] } -pub fn hash_16(input: [Field; 16]) -> Field { +pub fn hash_16(input: [field; 16]) -> field { let mut state = [0; 17]; for i in 0..input.len() { state[i+1] = input[i]; diff --git a/noir_stdlib/src/hash/poseidon/bn254/consts.nr b/noir_stdlib/src/hash/poseidon/bn254/consts.nr index 62b5f4b5212..d357f87c417 100644 --- a/noir_stdlib/src/hash/poseidon/bn254/consts.nr +++ b/noir_stdlib/src/hash/poseidon/bn254/consts.nr @@ -9,7 +9,7 @@ fn rp() -> [u8; 16] { [56, 57, 56, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68] } // S-box power -fn alpha() -> Field { +fn alpha() -> field { 5 } // Poseidon configurations for states of size 2 to 17. diff --git a/noir_stdlib/src/hash/poseidon/bn254/perm.nr b/noir_stdlib/src/hash/poseidon/bn254/perm.nr index 890f54fdb3f..ed1361ea843 100644 --- a/noir_stdlib/src/hash/poseidon/bn254/perm.nr +++ b/noir_stdlib/src/hash/poseidon/bn254/perm.nr @@ -4,7 +4,7 @@ use crate::hash::poseidon::bn254::permute; use crate::hash::poseidon::PoseidonConfig; #[field(bn254)] -pub fn x5_2(mut state: [Field; 2]) -> [Field; 2] { +pub fn x5_2(mut state: [field; 2]) -> [field; 2] { state = permute( consts::x5_2_config(), state); @@ -13,7 +13,7 @@ pub fn x5_2(mut state: [Field; 2]) -> [Field; 2] { } #[field(bn254)] -pub fn x5_3(mut state: [Field; 3]) -> [Field; 3] { +pub fn x5_3(mut state: [field; 3]) -> [field; 3] { state = permute( consts::x5_3_config(), state); @@ -22,7 +22,7 @@ pub fn x5_3(mut state: [Field; 3]) -> [Field; 3] { } #[field(bn254)] -pub fn x5_4(mut state: [Field; 4]) -> [Field; 4] { +pub fn x5_4(mut state: [field; 4]) -> [field; 4] { state = permute( consts::x5_4_config(), state); @@ -31,7 +31,7 @@ pub fn x5_4(mut state: [Field; 4]) -> [Field; 4] { } #[field(bn254)] -pub fn x5_5(mut state: [Field; 5]) -> [Field; 5] { +pub fn x5_5(mut state: [field; 5]) -> [field; 5] { state = permute( consts::x5_5_config(), state); @@ -40,7 +40,7 @@ pub fn x5_5(mut state: [Field; 5]) -> [Field; 5] { } #[field(bn254)] -pub fn x5_6(mut state: [Field; 6]) -> [Field; 6] { +pub fn x5_6(mut state: [field; 6]) -> [field; 6] { state = permute( consts::x5_6_config(), state); @@ -49,7 +49,7 @@ pub fn x5_6(mut state: [Field; 6]) -> [Field; 6] { } #[field(bn254)] -pub fn x5_7(mut state: [Field; 7]) -> [Field; 7] { +pub fn x5_7(mut state: [field; 7]) -> [field; 7] { state = permute( consts::x5_7_config(), state); @@ -58,7 +58,7 @@ pub fn x5_7(mut state: [Field; 7]) -> [Field; 7] { } #[field(bn254)] -pub fn x5_8(mut state: [Field; 8]) -> [Field; 8] { +pub fn x5_8(mut state: [field; 8]) -> [field; 8] { state = permute( consts::x5_8_config(), state); @@ -67,7 +67,7 @@ pub fn x5_8(mut state: [Field; 8]) -> [Field; 8] { } #[field(bn254)] -pub fn x5_9(mut state: [Field; 9]) -> [Field; 9] { +pub fn x5_9(mut state: [field; 9]) -> [field; 9] { state = permute( consts::x5_9_config(), state); @@ -76,7 +76,7 @@ pub fn x5_9(mut state: [Field; 9]) -> [Field; 9] { } #[field(bn254)] -pub fn x5_10(mut state: [Field; 10]) -> [Field; 10] { +pub fn x5_10(mut state: [field; 10]) -> [field; 10] { state = permute( consts::x5_10_config(), state); @@ -85,7 +85,7 @@ pub fn x5_10(mut state: [Field; 10]) -> [Field; 10] { } #[field(bn254)] -pub fn x5_11(mut state: [Field; 11]) -> [Field; 11] { +pub fn x5_11(mut state: [field; 11]) -> [field; 11] { state = permute( consts::x5_11_config(), state); @@ -94,7 +94,7 @@ pub fn x5_11(mut state: [Field; 11]) -> [Field; 11] { } #[field(bn254)] -pub fn x5_12(mut state: [Field; 12]) -> [Field; 12] { +pub fn x5_12(mut state: [field; 12]) -> [field; 12] { state = permute( consts::x5_12_config(), state); @@ -103,7 +103,7 @@ pub fn x5_12(mut state: [Field; 12]) -> [Field; 12] { } #[field(bn254)] -pub fn x5_13(mut state: [Field; 13]) -> [Field; 13] { +pub fn x5_13(mut state: [field; 13]) -> [field; 13] { state = permute( consts::x5_13_config(), state); @@ -112,7 +112,7 @@ pub fn x5_13(mut state: [Field; 13]) -> [Field; 13] { } #[field(bn254)] -pub fn x5_14(mut state: [Field; 14]) -> [Field; 14] { +pub fn x5_14(mut state: [field; 14]) -> [field; 14] { state = permute( consts::x5_14_config(), state); @@ -121,7 +121,7 @@ pub fn x5_14(mut state: [Field; 14]) -> [Field; 14] { } #[field(bn254)] -pub fn x5_15(mut state: [Field; 15]) -> [Field; 15] { +pub fn x5_15(mut state: [field; 15]) -> [field; 15] { state = permute( consts::x5_15_config(), state); @@ -130,7 +130,7 @@ pub fn x5_15(mut state: [Field; 15]) -> [Field; 15] { } #[field(bn254)] -pub fn x5_16(mut state: [Field; 16]) -> [Field; 16] { +pub fn x5_16(mut state: [field; 16]) -> [field; 16] { state = permute( consts::x5_16_config(), state); @@ -139,7 +139,7 @@ pub fn x5_16(mut state: [Field; 16]) -> [Field; 16] { } #[field(bn254)] -pub fn x5_17(mut state: [Field; 17]) -> [Field; 17] { +pub fn x5_17(mut state: [field; 17]) -> [field; 17] { state = permute( consts::x5_17_config(), state); diff --git a/noir_stdlib/src/hash/poseidon2.nr b/noir_stdlib/src/hash/poseidon2.nr index 8e0fcc6858e..37a219600d7 100644 --- a/noir_stdlib/src/hash/poseidon2.nr +++ b/noir_stdlib/src/hash/poseidon2.nr @@ -9,7 +9,7 @@ struct Poseidon2 { impl Poseidon2 { - pub fn hash(input: [Field; N], message_size: u32) -> Field { + pub fn hash(input: [field; N], message_size: u32) -> field { if message_size == N { Poseidon2::hash_internal(input, N, false) } else { @@ -17,18 +17,13 @@ impl Poseidon2 { } } - fn new(iv: Field) -> Poseidon2 { - let mut result = Poseidon2 { - cache: [0;3], - state: [0;4], - cache_size: 0, - squeeze_mode: false, - }; + fn new(iv: field) -> Poseidon2 { + let mut result = Poseidon2 { cache: [0; 3], state: [0; 4], cache_size: 0, squeeze_mode: false }; result.state[rate] = iv; result } - fn perform_duplex(&mut self) -> [Field; rate] { + fn perform_duplex(&mut self) -> [field; rate] { // zero-pad the cache for i in 0..rate { if i >= self.cache_size { @@ -48,7 +43,7 @@ impl Poseidon2 { result } - fn absorb(&mut self, input: Field) { + fn absorb(&mut self, input: field) { if (!self.squeeze_mode) & (self.cache_size == rate) { // If we're absorbing, and the cache is full, apply the sponge permutation to compress the cache let _ = self.perform_duplex(); @@ -67,8 +62,7 @@ impl Poseidon2 { } } - fn squeeze(&mut self) -> Field - { + fn squeeze(&mut self) -> field { if self.squeeze_mode & (self.cache_size == 0) { // If we're in squeze mode and the cache is empty, there is nothing left to squeeze out of the sponge! // Switch to absorb mode. @@ -98,9 +92,8 @@ impl Poseidon2 { result } - fn hash_internal(input:[Field;N], in_len:u32, is_variable_length: bool) -> Field - { - let iv : Field = (in_len as Field)*18446744073709551616; + fn hash_internal(input: [field; N], in_len: u32, is_variable_length: bool) -> field { + let iv : Field = (in_len as field) * 18446744073709551616; let mut sponge = Poseidon2::new(iv); for i in 0..input.len() { if i as u32 < in_len { diff --git a/noir_stdlib/src/lib.nr b/noir_stdlib/src/lib.nr index f728f3b2289..8b77d065a78 100644 --- a/noir_stdlib/src/lib.nr +++ b/noir_stdlib/src/lib.nr @@ -41,7 +41,7 @@ unconstrained pub fn println(input: T) { } #[foreign(recursive_aggregation)] -pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [Field], key_hash: Field) {} +pub fn verify_proof(verification_key: [field], proof: [field], public_inputs: [field], key_hash: field) {} // Asserts that the given value is known at compile-time. // Useful for debugging for-loop bounds. @@ -51,10 +51,10 @@ pub fn assert_constant(x: T) {} // `as` should be the default for users to cast between primitive types, and in the future // traits can be used to work with generic types. #[builtin(from_field)] -fn from_field(x: Field) -> T {} +fn from_field(x: field) -> T {} #[builtin(as_field)] -fn as_field(x: T) -> Field {} +fn as_field(x: T) -> field {} pub fn wrapping_add(x: T, y: T) -> T { crate::from_field(crate::as_field(x) + crate::as_field(y)) diff --git a/noir_stdlib/src/merkle.nr b/noir_stdlib/src/merkle.nr index 9b15fe7313d..3d56a4fbedc 100644 --- a/noir_stdlib/src/merkle.nr +++ b/noir_stdlib/src/merkle.nr @@ -2,7 +2,7 @@ // Currently we assume that it is a binary tree, so depth k implies a width of 2^k // XXX: In the future we can add an arity parameter // Returns the merkle root of the tree from the provided leaf, its hashpath, using a pedersen hash function. -pub fn compute_merkle_root(leaf: Field, index: Field, hash_path: [Field; N]) -> Field { +pub fn compute_merkle_root(leaf: field, index: field, hash_path: [field; N]) -> field { let n = hash_path.len(); let index_bits = index.to_le_bits(n as u32); let mut current = leaf; diff --git a/noir_stdlib/src/scalar_mul.nr b/noir_stdlib/src/scalar_mul.nr index eee7aac39f2..48df9185a2d 100644 --- a/noir_stdlib/src/scalar_mul.nr +++ b/noir_stdlib/src/scalar_mul.nr @@ -26,9 +26,9 @@ impl Add for EmbeddedCurvePoint { #[foreign(fixed_base_scalar_mul)] // docs:start:fixed_base_embedded_curve pub fn fixed_base_embedded_curve( - low: Field, - high: Field -) -> [Field; 2] + low: field, + high: field +) -> [field; 2] // docs:end:fixed_base_embedded_curve {} @@ -42,4 +42,4 @@ fn embedded_curve_add(point1: EmbeddedCurvePoint, point2: EmbeddedCurvePoint) -> } #[foreign(embedded_curve_add)] -fn embedded_curve_add_array_return(_point1: EmbeddedCurvePoint, _point2: EmbeddedCurvePoint) -> [Field; 2] {} +fn embedded_curve_add_array_return(_point1: EmbeddedCurvePoint, _point2: EmbeddedCurvePoint) -> [field; 2] {} diff --git a/noir_stdlib/src/schnorr.nr b/noir_stdlib/src/schnorr.nr index 757963d40d7..f5a3076528f 100644 --- a/noir_stdlib/src/schnorr.nr +++ b/noir_stdlib/src/schnorr.nr @@ -1,8 +1,8 @@ #[foreign(schnorr_verify)] // docs:start:schnorr_verify pub fn verify_signature( - public_key_x: Field, - public_key_y: Field, + public_key_x: field, + public_key_y: field, signature: [u8; 64], message: [u8; N] ) -> bool diff --git a/noir_stdlib/src/test.nr b/noir_stdlib/src/test.nr index e1c320215de..500b5cec9be 100644 --- a/noir_stdlib/src/test.nr +++ b/noir_stdlib/src/test.nr @@ -1,17 +1,17 @@ #[oracle(create_mock)] -unconstrained fn create_mock_oracle(name: str) -> Field {} +unconstrained fn create_mock_oracle(name: str) -> field {} #[oracle(set_mock_params)] -unconstrained fn set_mock_params_oracle

(id: Field, params: P) {} +unconstrained fn set_mock_params_oracle

(id: field, params: P) {} #[oracle(set_mock_returns)] -unconstrained fn set_mock_returns_oracle(id: Field, returns: R) {} +unconstrained fn set_mock_returns_oracle(id: field, returns: R) {} #[oracle(set_mock_times)] -unconstrained fn set_mock_times_oracle(id: Field, times: u64) {} +unconstrained fn set_mock_times_oracle(id: field, times: u64) {} #[oracle(clear_mock)] -unconstrained fn clear_mock_oracle(id: Field) {} +unconstrained fn clear_mock_oracle(id: field) {} struct OracleMock { id: Field, diff --git a/noir_stdlib/src/uint128.nr b/noir_stdlib/src/uint128.nr index 1bf285fecac..42a45008721 100644 --- a/noir_stdlib/src/uint128.nr +++ b/noir_stdlib/src/uint128.nr @@ -13,7 +13,7 @@ impl U128 { pub fn from_u64s_le(lo: u64, hi: u64) -> U128 { // in order to handle multiplication, we need to represent the product of two u64 without overflow assert(crate::field_element::modulus_num_bits() as u32 > 128); - U128 { lo: lo as Field, hi: hi as Field } + U128 { lo: lo as field, hi: hi as field } } pub fn from_u64s_be(hi: u64, lo: u64) -> U128 { @@ -84,17 +84,17 @@ impl U128 { base = base*16; } } - U128 { lo: lo as Field, hi: hi as Field } + U128 { lo: lo as field, hi: hi as field } } - fn decode_ascii(ascii: u8) -> Field { + fn decode_ascii(ascii: u8) -> field { if ascii < 58 { ascii - 48 } else if ascii < 71 { ascii - 55 } else { ascii - 87 - } as Field + } as field } unconstrained fn unconstrained_div(self: Self, b: U128) -> (U128, U128) { @@ -116,7 +116,7 @@ impl U128 { let f = crate::as_field(i); // Reject values which would overflow a u128 f.assert_max_bit_size(128); - let lo = f as u64 as Field; + let lo = f as u64 as field; let hi = (f - lo) / pow64; U128 { lo, hi } } @@ -127,14 +127,14 @@ impl U128 { fn wrapping_mul(self: Self, b: U128) -> U128 { let low = self.lo * b.lo; - let lo = low as u64 as Field; + let lo = low as u64 as field; let carry = (low - lo) / pow64; let high = if crate::field_element::modulus_num_bits() as u32 > 196 { (self.lo + self.hi) * (b.lo + b.hi) - low + carry } else { self.lo * b.hi + self.hi * b.lo + carry }; - let hi = high as u64 as Field; + let hi = high as u64 as field; U128 { lo, hi } } } From dca0dbed8eccba9c37480d1fa19c089f2f35c635 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 27 Feb 2024 14:08:59 +0000 Subject: [PATCH 11/19] chore: update outputs for formatter tests --- tooling/nargo_fmt/tests/expected/assert.nr | 2 +- tooling/nargo_fmt/tests/expected/contract.nr | 16 ++++----- tooling/nargo_fmt/tests/expected/expr.nr | 6 ++-- tooling/nargo_fmt/tests/expected/fn.nr | 36 +++++++++---------- tooling/nargo_fmt/tests/expected/module.nr | 6 ++-- .../nargo_fmt/tests/expected/read_array.nr | 2 +- tooling/nargo_fmt/tests/expected/struct.nr | 22 ++++++------ tooling/nargo_fmt/tests/expected/vec.nr | 8 ++--- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tooling/nargo_fmt/tests/expected/assert.nr b/tooling/nargo_fmt/tests/expected/assert.nr index 805e069c9a7..3fc41239f82 100644 --- a/tooling/nargo_fmt/tests/expected/assert.nr +++ b/tooling/nargo_fmt/tests/expected/assert.nr @@ -1,4 +1,4 @@ -fn main(x: Field) { +fn main(x: field) { assert(x == 0, "with a message"); assert_eq(x, 1); assert(x, message); diff --git a/tooling/nargo_fmt/tests/expected/contract.nr b/tooling/nargo_fmt/tests/expected/contract.nr index a03b8774700..b4b5f882429 100644 --- a/tooling/nargo_fmt/tests/expected/contract.nr +++ b/tooling/nargo_fmt/tests/expected/contract.nr @@ -11,13 +11,13 @@ contract Benchmarking { context::{Context}, note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader}, log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet}, - types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN}, + types::type_serialization::field_serialization::{fieldSerializationMethods, field_SERIALIZED_LEN}, types::address::{AztecAddress} }; struct Storage { notes: Map>, - balances: Map>, + balances: Map>, } impl Storage { @@ -31,7 +31,7 @@ contract Benchmarking { balances: Map::new( context, 2, - |context, slot| { PublicMutable::new(context, slot, FieldSerializationMethods) } + |context, slot| { PublicMutable::new(context, slot, fieldSerializationMethods) } ) } } @@ -42,13 +42,13 @@ contract Benchmarking { // Nec tincidunt praesent semper feugiat nibh sed pulvinar. Nibh nisl condimentum id venenatis a. #[aztec(private)] - fn create_note(owner: Field, value: Field) { + fn create_note(owner: field, value: field) { increment(storage.notes.at(owner), value, owner); } // Diam quam nulla porttitor massa id. Elit ullamcorper dignissim cras tincidunt lobortis feugiat. #[aztec(private)] - fn recreate_note(owner: Field, index: u32) { + fn recreate_note(owner: field, index: u32) { let owner_notes = storage.notes.at(owner); let getter_options = NoteGetterOptions::new().set_limit(1).set_offset(index); let notes = owner_notes.get_notes(getter_options); @@ -59,19 +59,19 @@ contract Benchmarking { // Ultrices in iaculis nunc sed augue lacus. #[aztec(public)] - fn increment_balance(owner: Field, value: Field) { + fn increment_balance(owner: field, value: field) { let current = storage.balances.at(owner).read(); storage.balances.at(owner).write(current + value); let _callStackItem1 = context.call_public_function( context.this_address(), - FunctionSelector::from_signature("broadcast(Field)"), + FunctionSelector::from_signature("broadcast(field)"), [owner] ); } // Est ultricies integer quis auctor elit sed. In nibh mauris cursus mattis molestie a iaculis. #[aztec(public)] - fn broadcast(owner: Field) { + fn broadcast(owner: field) { emit_unencrypted_log(&mut context, storage.balances.at(owner).read()); } } diff --git a/tooling/nargo_fmt/tests/expected/expr.nr b/tooling/nargo_fmt/tests/expected/expr.nr index 03a26835ee3..410a68f602e 100644 --- a/tooling/nargo_fmt/tests/expected/expr.nr +++ b/tooling/nargo_fmt/tests/expected/expr.nr @@ -88,7 +88,7 @@ fn line() { } fn parenthesized() { - value + (x as Field) + value + (x as field) } fn parenthesized() { @@ -96,13 +96,13 @@ fn parenthesized() { } fn parenthesized() { - value + (/*test*/x as Field/*test*/) + value + (/*test*/x as field/*test*/) } fn parenthesized() { value + ( // line - x as Field + x as field ) } diff --git a/tooling/nargo_fmt/tests/expected/fn.nr b/tooling/nargo_fmt/tests/expected/fn.nr index 0088dba6a8f..efb1dd6c186 100644 --- a/tooling/nargo_fmt/tests/expected/fn.nr +++ b/tooling/nargo_fmt/tests/expected/fn.nr @@ -1,8 +1,8 @@ fn main(x: pub u8, y: u8) {} -fn main(x: pub u8, y: u8) -> pub Field {} +fn main(x: pub u8, y: u8) -> pub field {} -fn main(x: A, y: B) -> pub Field where A: Eq, B: Eq {} +fn main(x: A, y: B) -> pub field where A: Eq, B: Eq {} fn main() // hello @@ -20,11 +20,11 @@ fn main( fn main() where T: Eq {} fn main( - tape: [Field; TAPE_LEN], - initial_registers: [Field; REGISTER_COUNT], - initial_memory: [Field; MEM_COUNT], - initial_program_counter: Field, - initial_call_stack: [Field; MAX_CALL_STACK], + tape: [field; TAPE_LEN], + initial_registers: [field; REGISTER_COUNT], + initial_memory: [field; MEM_COUNT], + initial_program_counter: field, + initial_call_stack: [field; MAX_CALL_STACK], initial_call_stack_pointer: u64 ) -> pub ExecutionResult {} @@ -36,28 +36,28 @@ fn apply_binary_field_op( registers: &mut Registers ) -> bool {} -fn main() -> distinct pub [Field; 2] {} +fn main() -> distinct pub [field; 2] {} -fn ret_normal_lambda1() -> ((fn() -> Field)) {} +fn ret_normal_lambda1() -> ((fn() -> field)) {} -fn ret_normal_lambda1() -> fn() -> Field {} +fn ret_normal_lambda1() -> fn() -> field {} -fn ret_closure1() -> fn[(Field,)]() -> Field {} +fn ret_closure1() -> fn[(field,)]() -> field {} -fn ret_closure2() -> fn[(Field, Field)]() -> Field {} +fn ret_closure2() -> fn[(field, field)]() -> field {} fn ret_closure3() -> fn[(u32, u64)]() -> u64 {} -fn make_counter() -> fn[(&mut Field,)]() -> Field {} +fn make_counter() -> fn[(&mut field,)]() -> field {} -fn get_some(generator: fn[Env]() -> Field) -> [Field; 5] {} +fn get_some(generator: fn[Env]() -> field) -> [field; 5] {} fn main( message: [u8; 10], - message_field: Field, - pub_key_x: Field, - pub_key_y: Field, + message_field: field, + pub_key_x: field, + pub_key_y: field, signature: [u8; 64] ) {} -pub fn from_baz(x: [Field; crate::foo::MAGIC_NUMBER]) {} +pub fn from_baz(x: [field; crate::foo::MAGIC_NUMBER]) {} diff --git a/tooling/nargo_fmt/tests/expected/module.nr b/tooling/nargo_fmt/tests/expected/module.nr index e419543dbc4..648e6f1fee8 100644 --- a/tooling/nargo_fmt/tests/expected/module.nr +++ b/tooling/nargo_fmt/tests/expected/module.nr @@ -1,15 +1,15 @@ mod a { mod b { struct Data { - a: Field + a: field } } - fn data(a: Field) -> Data { + fn data(a: field) -> Data { Data { a } } - fn data2(a: Field) -> Data2 { + fn data2(a: field) -> Data2 { Data2 { a } } diff --git a/tooling/nargo_fmt/tests/expected/read_array.nr b/tooling/nargo_fmt/tests/expected/read_array.nr index d2619884b5d..d35dd9c3ddf 100644 --- a/tooling/nargo_fmt/tests/expected/read_array.nr +++ b/tooling/nargo_fmt/tests/expected/read_array.nr @@ -1,4 +1,4 @@ -fn read_array(x: [Field; 3]) { +fn read_array(x: [field; 3]) { assert(x[0] == 1); let y = [1, 5, 27]; diff --git a/tooling/nargo_fmt/tests/expected/struct.nr b/tooling/nargo_fmt/tests/expected/struct.nr index 8fc642f7cd5..2c6dacc8123 100644 --- a/tooling/nargo_fmt/tests/expected/struct.nr +++ b/tooling/nargo_fmt/tests/expected/struct.nr @@ -1,15 +1,15 @@ struct Foo { - bar: Field, - array: [Field; 2], + bar: field, + array: [field; 2], } struct Pair { first: Foo, - second: Field, + second: field, } impl Foo { - fn default(x: Field, y: Field) -> Self { + fn default(x: field, y: field) -> Self { Self { bar: 0, array: [x, y] } } } @@ -19,27 +19,27 @@ impl Pair { p.first } - fn bar(self) -> Field { + fn bar(self) -> field { self.foo().bar } } struct Nested { - a: Field, - b: Field + a: field, + b: field } struct MyStruct { my_bool: bool, my_int: u32, my_nest: Nested, } -fn test_struct_in_tuple(a_bool: bool, x: Field, y: Field) -> (MyStruct, bool) { +fn test_struct_in_tuple(a_bool: bool, x: field, y: field) -> (MyStruct, bool) { let my_struct = MyStruct { my_bool: a_bool, my_int: 5, my_nest: Nested { a: x, b: y } }; (my_struct, a_bool) } struct Animal { - legs: Field, + legs: field, eyes: u8, } @@ -48,7 +48,7 @@ fn get_dog() -> Animal { dog } -fn main(x: Field, y: Field) { +fn main(x: field, y: field) { let first = Foo::default(x, y); let p = Pair { first, second: 1 }; @@ -65,7 +65,7 @@ fn main(x: Field, y: Field) { // Regression test for issue #670 let Animal { legs, eyes } = get_dog(); - let six = legs + eyes as Field; + let six = legs + eyes as field; assert(six == 6); diff --git a/tooling/nargo_fmt/tests/expected/vec.nr b/tooling/nargo_fmt/tests/expected/vec.nr index 466c9844e74..5ba4a0448dd 100644 --- a/tooling/nargo_fmt/tests/expected/vec.nr +++ b/tooling/nargo_fmt/tests/expected/vec.nr @@ -18,7 +18,7 @@ impl Vec { /// Get an element from the vector at the given index. /// Panics if the given index /// points beyond the end of the vector. - pub fn get(self, index: Field) -> T { + pub fn get(self, index: field) -> T { self.slice[index] } @@ -41,20 +41,20 @@ impl Vec { /// Insert an element at a specified index, shifting all elements /// after it to the right - pub fn insert(&mut self, index: Field, elem: T) { + pub fn insert(&mut self, index: field, elem: T) { self.slice = self.slice.insert(index, elem); } /// Remove an element at a specified index, shifting all elements /// after it to the left, returning the removed element - pub fn remove(&mut self, index: Field) -> T { + pub fn remove(&mut self, index: field) -> T { let (new_slice, elem) = self.slice.remove(index); self.slice = new_slice; elem } /// Returns the number of elements in the vector - pub fn len(self) -> Field { + pub fn len(self) -> field { self.slice.len() } } From f160797db6896ec5c6b5193d412e5f9e1679732f Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 27 Feb 2024 14:16:29 +0000 Subject: [PATCH 12/19] chore: format stdlib --- noir_stdlib/src/hash/poseidon2.nr | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/noir_stdlib/src/hash/poseidon2.nr b/noir_stdlib/src/hash/poseidon2.nr index 21723145018..e576a0f2c30 100644 --- a/noir_stdlib/src/hash/poseidon2.nr +++ b/noir_stdlib/src/hash/poseidon2.nr @@ -17,13 +17,13 @@ impl Poseidon2 { } } - fn new(iv: Field) -> Poseidon2 { + fn new(iv: field) -> Poseidon2 { let mut result = Poseidon2 { cache: [0; 3], state: [0; 4], cache_size: 0, squeeze_mode: false }; result.state[RATE] = iv; result } - fn perform_duplex(&mut self) -> [Field; RATE] { + fn perform_duplex(&mut self) -> [field; RATE] { // zero-pad the cache for i in 0..RATE { if i >= self.cache_size { @@ -43,7 +43,7 @@ impl Poseidon2 { result } - fn absorb(&mut self, input: Field) { + fn absorb(&mut self, input: field) { if (!self.squeeze_mode) & (self.cache_size == RATE) { // If we're absorbing, and the cache is full, apply the sponge permutation to compress the cache let _ = self.perform_duplex(); @@ -62,7 +62,7 @@ impl Poseidon2 { } } - fn squeeze(&mut self) -> Field { + fn squeeze(&mut self) -> field { if self.squeeze_mode & (self.cache_size == 0) { // If we're in squeze mode and the cache is empty, there is nothing left to squeeze out of the sponge! // Switch to absorb mode. @@ -92,8 +92,8 @@ impl Poseidon2 { result } - fn hash_internal(input: [Field; N], in_len: u32, is_variable_length: bool) -> Field { - let iv : Field = (in_len as Field) * 18446744073709551616; + fn hash_internal(input: [field; N], in_len: u32, is_variable_length: bool) -> field { + let iv : Field = (in_len as field) * 18446744073709551616; let mut sponge = Poseidon2::new(iv); for i in 0..input.len() { if i as u32 < in_len { From 684139e997a8595200a661dfbf9f58e52db1540e Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 27 Feb 2024 14:17:41 +0000 Subject: [PATCH 13/19] chore: remove unwanted change --- tooling/nargo_fmt/tests/expected/contract.nr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tooling/nargo_fmt/tests/expected/contract.nr b/tooling/nargo_fmt/tests/expected/contract.nr index b4b5f882429..1e82daba4ca 100644 --- a/tooling/nargo_fmt/tests/expected/contract.nr +++ b/tooling/nargo_fmt/tests/expected/contract.nr @@ -11,7 +11,7 @@ contract Benchmarking { context::{Context}, note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader}, log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet}, - types::type_serialization::field_serialization::{fieldSerializationMethods, field_SERIALIZED_LEN}, + types::type_serialization::field_serialization::{FieldSerializationMethods, field_SERIALIZED_LEN}, types::address::{AztecAddress} }; @@ -31,7 +31,7 @@ contract Benchmarking { balances: Map::new( context, 2, - |context, slot| { PublicMutable::new(context, slot, fieldSerializationMethods) } + |context, slot| { PublicMutable::new(context, slot, FieldSerializationMethods) } ) } } From ccba71d5301da6fb896682e2574314940f1414a0 Mon Sep 17 00:00:00 2001 From: Tom French Date: Sat, 20 Apr 2024 15:27:30 +0100 Subject: [PATCH 14/19] chore: fix stdlib --- noir_stdlib/src/array.nr | 2 +- noir_stdlib/src/cmp.nr | 6 +-- noir_stdlib/src/collections/bounded_vec.nr | 8 ++-- noir_stdlib/src/convert.nr | 8 ++-- noir_stdlib/src/default.nr | 2 +- noir_stdlib/src/ec.nr | 36 ++++++++-------- noir_stdlib/src/ec/consts/te.nr | 2 +- noir_stdlib/src/ec/montcurve.nr | 20 ++++----- noir_stdlib/src/ec/swcurve.nr | 22 +++++----- noir_stdlib/src/ec/tecurve.nr | 20 ++++----- noir_stdlib/src/eddsa.nr | 16 ++++---- noir_stdlib/src/field_element/bn254.nr | 26 ++++++------ noir_stdlib/src/grumpkin_scalar.nr | 6 +-- noir_stdlib/src/hash.nr | 36 ++++++++-------- noir_stdlib/src/hash/mimc.nr | 8 ++-- noir_stdlib/src/hash/poseidon.nr | 16 ++++---- noir_stdlib/src/hash/poseidon2.nr | 14 +++---- noir_stdlib/src/ops.nr | 8 ++-- noir_stdlib/src/scalar_mul.nr | 4 +- noir_stdlib/src/schnorr.nr | 4 +- noir_stdlib/src/sha256.nr | 8 ++-- noir_stdlib/src/sha512.nr | 8 ++-- noir_stdlib/src/test.nr | 4 +- noir_stdlib/src/uint128.nr | 48 +++++++++++----------- 24 files changed, 166 insertions(+), 166 deletions(-) diff --git a/noir_stdlib/src/array.nr b/noir_stdlib/src/array.nr index 8a8a1fad01c..ea724797a27 100644 --- a/noir_stdlib/src/array.nr +++ b/noir_stdlib/src/array.nr @@ -108,7 +108,7 @@ impl [T; N] { } } -// helper function used to look up the position of a value in an array of Field +// helper function used to look up the position of a value in an array of field // Note that function returns 0 if the value is not found unconstrained fn find_index(a: [u64; N], find: u64) -> u64 { let mut result = 0; diff --git a/noir_stdlib/src/cmp.nr b/noir_stdlib/src/cmp.nr index 457b2cfa167..5a566ba1423 100644 --- a/noir_stdlib/src/cmp.nr +++ b/noir_stdlib/src/cmp.nr @@ -4,7 +4,7 @@ trait Eq { } // docs:end:eq-trait -impl Eq for Field { fn eq(self, other: Field) -> bool { self == other } } +impl Eq for field { fn eq(self, other: field) -> bool { self == other } } impl Eq for u64 { fn eq(self, other: u64) -> bool { self == other } } impl Eq for u32 { fn eq(self, other: u32) -> bool { self == other } } @@ -79,7 +79,7 @@ impl Eq for Ordering { // Noir doesn't have enums yet so we emulate (Lt | Eq | Gt) with a struct // that has 3 public functions for constructing the struct. struct Ordering { - result: Field, + result: field, } impl Ordering { @@ -105,7 +105,7 @@ trait Ord { } // docs:end:ord-trait -// Note: Field deliberately does not implement Ord +// Note: field deliberately does not implement Ord impl Ord for u64 { fn cmp(self, other: u64) -> Ordering { diff --git a/noir_stdlib/src/collections/bounded_vec.nr b/noir_stdlib/src/collections/bounded_vec.nr index c6a3365a979..f67a7655cbd 100644 --- a/noir_stdlib/src/collections/bounded_vec.nr +++ b/noir_stdlib/src/collections/bounded_vec.nr @@ -113,16 +113,16 @@ mod bounded_vec_tests { #[test] fn empty_equality() { - let mut bounded_vec1: BoundedVec = BoundedVec::new(); - let mut bounded_vec2: BoundedVec = BoundedVec::new(); + let mut bounded_vec1: BoundedVec = BoundedVec::new(); + let mut bounded_vec2: BoundedVec = BoundedVec::new(); assert_eq(bounded_vec1, bounded_vec2); } #[test] fn inequality() { - let mut bounded_vec1: BoundedVec = BoundedVec::new(); - let mut bounded_vec2: BoundedVec = BoundedVec::new(); + let mut bounded_vec1: BoundedVec = BoundedVec::new(); + let mut bounded_vec2: BoundedVec = BoundedVec::new(); bounded_vec1.push(1); bounded_vec2.push(2); diff --git a/noir_stdlib/src/convert.nr b/noir_stdlib/src/convert.nr index 00ac0a0fd8c..6241ca34f01 100644 --- a/noir_stdlib/src/convert.nr +++ b/noir_stdlib/src/convert.nr @@ -30,9 +30,9 @@ impl From for u32 { fn from(value: u8) -> u32 { value as u32 } } impl From for u64 { fn from(value: u8) -> u64 { value as u64 } } impl From for u64 { fn from(value: u32) -> u64 { value as u64 } } -impl From for Field { fn from(value: u8) -> Field { value as Field } } -impl From for Field { fn from(value: u32) -> Field { value as Field } } -impl From for Field { fn from(value: u64) -> Field { value as Field } } +impl From for field { fn from(value: u8) -> field { value as field } } +impl From for field { fn from(value: u32) -> field { value as field } } +impl From for field { fn from(value: u64) -> field { value as field } } // Signed integers @@ -48,5 +48,5 @@ impl From for u64 { fn from(value: bool) -> u64 { value as u64 } } impl From for i8 { fn from(value: bool) -> i8 { value as i8 } } impl From for i32 { fn from(value: bool) -> i32 { value as i32 } } impl From for i64 { fn from(value: bool) -> i64 { value as i64 } } -impl From for Field { fn from(value: bool) -> Field { value as Field } } +impl From for field { fn from(value: bool) -> field { value as field } } // docs:end:from-impls diff --git a/noir_stdlib/src/default.nr b/noir_stdlib/src/default.nr index bd2f1ce0cd2..1e72503dc78 100644 --- a/noir_stdlib/src/default.nr +++ b/noir_stdlib/src/default.nr @@ -4,7 +4,7 @@ trait Default { } // docs:end:default-trait -impl Default for Field { fn default() -> Field { 0 } } +impl Default for field { fn default() -> field { 0 } } impl Default for u8 { fn default() -> u8 { 0 } } impl Default for u32 { fn default() -> u32 { 0 } } diff --git a/noir_stdlib/src/ec.nr b/noir_stdlib/src/ec.nr index 91727a04a78..6da2b9386f3 100644 --- a/noir_stdlib/src/ec.nr +++ b/noir_stdlib/src/ec.nr @@ -54,7 +54,7 @@ mod consts; // Commonly used curve presets // // Curves // ====== -// A curve configuration (Curve) is completely determined by the Field coefficients of its defining +// A curve configuration (Curve) is completely determined by the field coefficients of its defining // equation (a and b in the case of swcurve, a and d in the case of tecurve, and j and k in // the case of montcurve) together with a generator (`gen`) in the corresponding coordinate system. // For example, the Baby Jubjub curve configuration as defined in ERC-2494 may be instantiated as a Twisted @@ -74,13 +74,13 @@ mod consts; // Commonly used curve presets // // `constrain tecurve::Point::zero().eq(bjj_affine.subtract(bjj_affine.gen, bjj_affine.gen));` // -// scalar multiplication as the `mul` method, where the scalar is assumed to be a Field* element, e.g. +// scalar multiplication as the `mul` method, where the scalar is assumed to be a field* element, e.g. // // `constrain tecurve::Point::zero().eq(bjj_affine.mul(2, tecurve::Point::zero());` // // There is a scalar multiplication method (`bit_mul`) provided where the scalar input is expected to be // an array of bits (little-endian convention), as well as a multi-scalar multiplication method** (`msm`) -// which takes an array of Field elements and an array of elliptic curve points as arguments, both assumed +// which takes an array of field elements and an array of elliptic curve points as arguments, both assumed // to be of the same length. // // Curve configurations may be converted between different coordinate representations by calling the `into_group` @@ -96,30 +96,30 @@ mod consts; // Commonly used curve presets // // Curve maps // ========== -// There are a few different ways of mapping Field elements to elliptic curves. Here we provide the simplified +// There are a few different ways of mapping field elements to elliptic curves. Here we provide the simplified // Shallue-van de Woestijne-Ulas and Elligator 2 methods, the former being applicable to all curve types // provided above subject to the constraint that the coefficients of the corresponding Short Weierstraß curve satisfies // a*b != 0 and the latter being applicable to Montgomery and Twisted Edwards curves subject to the constraint that // the coefficients of the corresponding Montgomery curve satisfy j*k != 0 and (j^2 - 4)/k^2 is non-square. // // The simplified Shallue-van de Woestijne-Ulas method is exposed as the method `swu_map` on the Curve configuration and -// depends on two parameters, a Field element z != -1 for which g(x) - z is irreducible over Field and g(b/(z*a)) is +// depends on two parameters, a field element z != -1 for which g(x) - z is irreducible over field and g(b/(z*a)) is // square, where g(x) = x^3 + a*x + b is the right-hand side of the defining equation of the corresponding Short -// Weierstraß curve, and a Field element u to be mapped onto the curve. For example, in the case of bjj_affine above, +// Weierstraß curve, and a field element u to be mapped onto the curve. For example, in the case of bjj_affine above, // it may be determined using the scripts provided at that z = 5. // // The Elligator 2 method is exposed as the method `elligator2_map` on the Curve configurations of Montgomery and -// Twisted Edwards curves. Like the simplified SWU method above, it depends on a certain non-square element of Field, -// but this element need not satisfy any further conditions, so it is included as the (Field-dependent) constant -//`ZETA` below. Thus, the `elligator2_map` method depends only on one parameter, the Field element to be mapped onto +// Twisted Edwards curves. Like the simplified SWU method above, it depends on a certain non-square element of field, +// but this element need not satisfy any further conditions, so it is included as the (field-dependent) constant +//`ZETA` below. Thus, the `elligator2_map` method depends only on one parameter, the field element to be mapped onto // the curve. // // For details on all of the above in the context of hashing to elliptic curves, see . // // -// *TODO: Replace Field with Bigint. +// *TODO: Replace field with Bigint. // **TODO: Support arrays of structs to make this work. -// Field-dependent constant ZETA = a non-square element of Field +// Field-dependent constant ZETA = a non-square element of field // Required for Elligator 2 map // TODO: Replace with built-in constant. global ZETA = 5; @@ -146,32 +146,32 @@ global C5 = 19103219067921713944291392827692070036145651957329286315305642004821 pub fn safe_inverse(x: field) -> field { if x == 0 { 0 } else { 1 / x } } -// Boolean indicating whether Field element is a square, i.e. whether there exists a y in Field s.t. x = y*y. +// Boolean indicating whether field element is a square, i.e. whether there exists a y in field s.t. x = y*y. pub fn is_square(x: field) -> bool { let v = pow(x, 0 - 1 / 2); v * (v - 1) == 0 } -// Power function of two Field arguments of arbitrary size. +// Power function of two field arguments of arbitrary size. // Adapted from std::field_element::pow_32. pub fn pow(x: field, y: field) -> field { // As in tests with minor modifications let N_BITS = crate::field_element::modulus_num_bits(); - let mut r = 1 as field; + let mut r: field = 1; let b = y.to_le_bits(N_BITS as u32); for i in 0..N_BITS { r *= r; - r *= (b[N_BITS - 1 - i] as Field)*x + (1-b[N_BITS - 1 - i] as Field); + r *= (b[N_BITS - 1 - i] as field)*x + (1-b[N_BITS - 1 - i] as field); } r } -// Tonelli-Shanks algorithm for computing the square root of a Field element. -// Requires C1 = max{c: 2^c divides (p-1)}, where p is the order of Field +// Tonelli-Shanks algorithm for computing the square root of a field element. +// Requires C1 = max{c: 2^c divides (p-1)}, where p is the order of field // as well as C3 = (C2 - 1)/2, where C2 = (p-1)/(2^c1), -// and C5 = ZETA^C2, where ZETA is a non-square element of Field. +// and C5 = ZETA^C2, where ZETA is a non-square element of field. // These are pre-computed above as globals. pub fn sqrt(x: field) -> field { let mut z = pow(x, C3); diff --git a/noir_stdlib/src/ec/consts/te.nr b/noir_stdlib/src/ec/consts/te.nr index e25f373593a..1aa2744f4ad 100644 --- a/noir_stdlib/src/ec/consts/te.nr +++ b/noir_stdlib/src/ec/consts/te.nr @@ -5,7 +5,7 @@ use crate::ec::tecurve::affine::Curve as TECurve; struct BabyJubjub { curve: TECurve, base8: TEPoint, - suborder: Field, + suborder: field, } #[field(bn254)] diff --git a/noir_stdlib/src/ec/montcurve.nr b/noir_stdlib/src/ec/montcurve.nr index 918038d7f99..a548298b646 100644 --- a/noir_stdlib/src/ec/montcurve.nr +++ b/noir_stdlib/src/ec/montcurve.nr @@ -16,15 +16,15 @@ mod affine { // Curve specification struct Curve { // Montgomery Curve configuration (ky^2 = x^3 + j*x^2 + x) - j: Field, - k: Field, + j: field, + k: field, // Generator as point in Cartesian coordinates gen: Point } // Point in Cartesian coordinates struct Point { - x: Field, - y: Field, + x: field, + y: field, infty: bool // Indicator for point at infinity } @@ -177,7 +177,7 @@ mod affine { fn elligator2_map(self, u: field) -> Point { let j = self.j; let k = self.k; - let z = ZETA; // Non-square Field element required for map + let z = ZETA; // Non-square field element required for map // Check whether curve is admissible assert(j != 0); @@ -223,16 +223,16 @@ mod curvegroup { use crate::cmp::Eq; struct Curve { // Montgomery Curve configuration (ky^2 z = x*(x^2 + j*x*z + z*z)) - j: Field, - k: Field, + j: field, + k: field, // Generator as point in projective coordinates gen: Point } // Point in projective coordinates struct Point { - x: Field, - y: Field, - z: Field + x: field, + y: field, + z: field } impl Point { diff --git a/noir_stdlib/src/ec/swcurve.nr b/noir_stdlib/src/ec/swcurve.nr index 2089fc53609..da10093a291 100644 --- a/noir_stdlib/src/ec/swcurve.nr +++ b/noir_stdlib/src/ec/swcurve.nr @@ -12,15 +12,15 @@ mod affine { // Curve specification struct Curve { // Short Weierstraß curve // Coefficients in defining equation y^2 = x^3 + ax + b - a: Field, - b: Field, + a: field, + b: field, // Generator as point in Cartesian coordinates gen: Point } // Point in Cartesian coordinates struct Point { - x: Field, - y: Field, + x: field, + y: field, infty: bool // Indicator for point at infinity } @@ -160,8 +160,8 @@ mod affine { } // Simplified Shallue-van de Woestijne-Ulas map-to-curve method; see . - // First determine non-square z != -1 in Field s.t. g(x) - z irreducible over Field and g(b/(z*a)) is square, - // where g(x) = x^3 + a*x + b. swu_map(c,z,.) then maps a Field element to a point on curve c. + // First determine non-square z != -1 in field s.t. g(x) - z irreducible over field and g(b/(z*a)) is square, + // where g(x) = x^3 + a*x + b. swu_map(c,z,.) then maps a field element to a point on curve c. fn swu_map(self, z: field, u: field) -> Point { // Check whether curve is admissible assert(self.a * self.b != 0); @@ -197,16 +197,16 @@ mod curvegroup { // Curve specification struct Curve { // Short Weierstraß curve // Coefficients in defining equation y^2 = x^3 + axz^4 + bz^6 - a: Field, - b: Field, + a: field, + b: field, // Generator as point in Cartesian coordinates gen: Point } // Point in three-dimensional Jacobian coordinates struct Point { - x: Field, - y: Field, - z: Field // z = 0 corresponds to point at infinity. + x: field, + y: field, + z: field // z = 0 corresponds to point at infinity. } impl Point { diff --git a/noir_stdlib/src/ec/tecurve.nr b/noir_stdlib/src/ec/tecurve.nr index 6abb704e898..f3de94f2ee2 100644 --- a/noir_stdlib/src/ec/tecurve.nr +++ b/noir_stdlib/src/ec/tecurve.nr @@ -14,15 +14,15 @@ mod affine { // Curve specification struct Curve { // Twisted Edwards curve // Coefficients in defining equation ax^2 + y^2 = 1 + dx^2y^2 - a: Field, - d: Field, + a: field, + d: field, // Generator as point in Cartesian coordinates gen: Point } // Point in Cartesian coordinates struct Point { - x: Field, - y: Field + x: field, + y: field } impl Point { @@ -206,17 +206,17 @@ mod curvegroup { // Curve specification struct Curve { // Twisted Edwards curve // Coefficients in defining equation a(x^2 + y^2)z^2 = z^4 + dx^2y^2 - a: Field, - d: Field, + a: field, + d: field, // Generator as point in projective coordinates gen: Point } // Point in extended twisted Edwards coordinates struct Point { - x: Field, - y: Field, - t: Field, - z: Field + x: field, + y: field, + t: field, + z: field } impl Point { diff --git a/noir_stdlib/src/eddsa.nr b/noir_stdlib/src/eddsa.nr index 6a657f450c1..dde62b80581 100644 --- a/noir_stdlib/src/eddsa.nr +++ b/noir_stdlib/src/eddsa.nr @@ -26,12 +26,12 @@ pub fn eddsa_poseidon_verify( } pub fn eddsa_verify_with_hasher( - pub_key_x: Field, - pub_key_y: Field, - signature_s: Field, - signature_r8_x: Field, - signature_r8_y: Field, - message: Field, + pub_key_x: field, + pub_key_y: field, + signature_s: field, + signature_r8_x: field, + signature_r8_y: field, + message: field, hasher: &mut H ) -> bool where H: Hasher { @@ -52,7 +52,7 @@ where H: Hasher { pub_key_x.hash(hasher); pub_key_y.hash(hasher); message.hash(hasher); - let hash: Field = (*hasher).finish(); + let hash: field = (*hasher).finish(); // Calculate second part of the right side: right2 = h*8*A // Multiply by 8 by doubling 3 times. This also ensures that the result is in the subgroup. let pub_key_mul_2 = bjj.curve.add(pub_key, pub_key); @@ -69,7 +69,7 @@ where H: Hasher { } // Returns the public key of the given secret key as (pub_key_x, pub_key_y) -pub fn eddsa_to_pub(secret: Field) -> (Field, Field) { +pub fn eddsa_to_pub(secret: field) -> (field, field) { let bjj = baby_jubjub(); let pub_key = bjj.curve.mul(secret, bjj.curve.gen); (pub_key.x, pub_key.y) diff --git a/noir_stdlib/src/field_element/bn254.nr b/noir_stdlib/src/field_element/bn254.nr index c3c1c3ef609..7c8a5af578c 100644 --- a/noir_stdlib/src/field_element/bn254.nr +++ b/noir_stdlib/src/field_element/bn254.nr @@ -1,20 +1,20 @@ // The low and high decomposition of the field modulus -global PLO: Field = 53438638232309528389504892708671455233; -global PHI: Field = 64323764613183177041862057485226039389; +global PLO: field = 53438638232309528389504892708671455233; +global PHI: field = 64323764613183177041862057485226039389; -global TWO_POW_128: Field = 0x100000000000000000000000000000000; +global TWO_POW_128: field = 0x100000000000000000000000000000000; /// A hint for decomposing a single field into two 16 byte fields. unconstrained fn decompose_unsafe(x: field) -> (field, field) { let x_bytes = x.to_le_bytes(32); - let mut low: Field = 0; - let mut high: Field = 0; + let mut low: field = 0; + let mut high: field = 0; let mut offset = 1; for i in 0..16 { - low += (x_bytes[i] as Field) * offset; - high += (x_bytes[i + 16] as Field) * offset; + low += (x_bytes[i] as field) * offset; + high += (x_bytes[i + 16] as field) * offset; offset *= 256; } @@ -105,7 +105,7 @@ pub fn lt(a: field, b: field) -> bool { mod tests { // TODO: Allow imports from "super" - use crate::field::bn254::{decompose_unsafe, decompose, lt_unsafe, assert_gt, gt, lt, TWO_POW_128, lte_unsafe, PLO, PHI}; + use crate::field_element::bn254::{decompose_unsafe, decompose, lt_unsafe, assert_gt, gt, lt, TWO_POW_128, lte_unsafe, PLO, PHI}; #[test] fn check_decompose_unsafe() { @@ -166,14 +166,14 @@ mod tests { #[test] fn check_plo_phi() { assert_eq(PLO + PHI * TWO_POW_128, 0); - let p_bytes = crate::field::modulus_le_bytes(); - let mut p_low: Field = 0; - let mut p_high: Field = 0; + let p_bytes = crate::field_element::modulus_le_bytes(); + let mut p_low: field = 0; + let mut p_high: field = 0; let mut offset = 1; for i in 0..16 { - p_low += (p_bytes[i] as Field) * offset; - p_high += (p_bytes[i + 16] as Field) * offset; + p_low += (p_bytes[i] as field) * offset; + p_high += (p_bytes[i + 16] as field) * offset; offset *= 256; } assert_eq(p_low, PLO); diff --git a/noir_stdlib/src/grumpkin_scalar.nr b/noir_stdlib/src/grumpkin_scalar.nr index e425c36e546..85edd79b44d 100644 --- a/noir_stdlib/src/grumpkin_scalar.nr +++ b/noir_stdlib/src/grumpkin_scalar.nr @@ -1,6 +1,6 @@ struct GrumpkinScalar { - low: Field, - high: Field, + low: field, + high: field, } impl GrumpkinScalar { @@ -10,7 +10,7 @@ impl GrumpkinScalar { } } -global GRUMPKIN_SCALAR_SERIALIZED_LEN: Field = 2; +global GRUMPKIN_SCALAR_SERIALIZED_LEN: field = 2; pub fn deserialize_grumpkin_scalar(fields: [field; GRUMPKIN_SCALAR_SERIALIZED_LEN]) -> GrumpkinScalar { GrumpkinScalar { low: fields[0], high: fields[1] } diff --git a/noir_stdlib/src/hash.nr b/noir_stdlib/src/hash.nr index 287227d2426..f4fe1a90583 100644 --- a/noir_stdlib/src/hash.nr +++ b/noir_stdlib/src/hash.nr @@ -25,8 +25,8 @@ pub fn blake3(input: [u8; N]) -> [u8; 32] // docs:start:pedersen_commitment struct PedersenPoint { - x : Field, - y : Field, + x : field, + y : field, } pub fn pedersen_commitment(input: [field; N]) -> PedersenPoint { @@ -35,7 +35,7 @@ pub fn pedersen_commitment(input: [field; N]) -> PedersenPoint { } #[foreign(pedersen_commitment)] -pub fn __pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> [Field; 2] {} +pub fn __pedersen_commitment_with_separator(input: [field; N], separator: u32) -> [field; 2] {} pub fn pedersen_commitment_with_separator(input: [field; N], separator: u32) -> PedersenPoint { let values = __pedersen_commitment_with_separator(input, separator); @@ -50,14 +50,14 @@ pub fn pedersen_hash(input: [field; N]) -> field } #[foreign(pedersen_hash)] -pub fn pedersen_hash_with_separator(input: [Field; N], separator: u32) -> Field {} +pub fn pedersen_hash_with_separator(input: [field; N], separator: u32) -> field {} pub fn hash_to_field(inputs: [field]) -> field { let mut sum = 0; for input in inputs { let input_bytes: [u8; 32] = input.to_le_bytes(32).as_array(); - sum += crate::field::bytes32_to_field(blake2s(input_bytes)); + sum += crate::field_element::bytes32_to_field(blake2s(input_bytes)); } sum @@ -84,11 +84,11 @@ trait Hash{ } // Hasher trait shall be implemented by algorithms to provide hash-agnostic means. -// TODO: consider making the types generic here ([u8], [Field], etc.) +// TODO: consider making the types generic here ([u8], [field], etc.) trait Hasher{ - fn finish(self) -> Field; + fn finish(self) -> field; - fn write(&mut self, input: Field); + fn write(&mut self, input: field); } // BuildHasher is a factory trait, responsible for production of specific Hasher. @@ -116,7 +116,7 @@ where } } -impl Hash for Field { +impl Hash for field { fn hash(self, state: &mut H) where H: Hasher{ H::write(state, self); } @@ -124,43 +124,43 @@ impl Hash for Field { impl Hash for u8 { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self as Field); + H::write(state, self as field); } } impl Hash for u32 { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self as Field); + H::write(state, self as field); } } impl Hash for u64 { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self as Field); + H::write(state, self as field); } } impl Hash for i8 { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self as Field); + H::write(state, self as field); } } impl Hash for i32 { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self as Field); + H::write(state, self as field); } } impl Hash for i64 { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self as Field); + H::write(state, self as field); } } impl Hash for bool { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self as Field); + H::write(state, self as field); } } @@ -170,8 +170,8 @@ impl Hash for () { impl Hash for U128 { fn hash(self, state: &mut H) where H: Hasher{ - H::write(state, self.lo as Field); - H::write(state, self.hi as Field); + H::write(state, self.lo as field); + H::write(state, self.hi as field); } } diff --git a/noir_stdlib/src/hash/mimc.nr b/noir_stdlib/src/hash/mimc.nr index deb638fa535..7184838e420 100644 --- a/noir_stdlib/src/hash/mimc.nr +++ b/noir_stdlib/src/hash/mimc.nr @@ -116,7 +116,7 @@ global MIMC_BN254_CONSTANTS: [field; MIMC_BN254_ROUNDS] = [ //mimc implementation with hardcoded parameters for BN254 curve. #[field(bn254)] -pub fn mimc_bn254(array: [Field; N]) -> Field { +pub fn mimc_bn254(array: [field; N]) -> field { let exponent = 7; let mut r = 0; for elem in array { @@ -127,12 +127,12 @@ pub fn mimc_bn254(array: [Field; N]) -> Field { } struct MimcHasher { - _state: [Field], + _state: [field], } impl Hasher for MimcHasher { #[field(bn254)] - fn finish(self) -> Field { + fn finish(self) -> field { let exponent = 7; let mut r = 0; for i in 0..self._state.len() { @@ -142,7 +142,7 @@ impl Hasher for MimcHasher { r } - fn write(&mut self, input: Field){ + fn write(&mut self, input: field){ self._state = self._state.push_back(input); } } diff --git a/noir_stdlib/src/hash/poseidon.nr b/noir_stdlib/src/hash/poseidon.nr index bbaeb5b16f7..c10cfc2c757 100644 --- a/noir_stdlib/src/hash/poseidon.nr +++ b/noir_stdlib/src/hash/poseidon.nr @@ -4,12 +4,12 @@ use crate::hash::Hasher; use crate::default::Default; struct PoseidonConfig { - t: Field, // Width, i.e. state size + t: field, // Width, i.e. state size rf: u8, // Number of full rounds; should be even rp: u8, // Number of partial rounds - alpha: Field, // S-box power; depends on the underlying field - ark: [Field; M], // Additive round keys - mds: [Field; N] // MDS Matrix in row-major order + alpha: field, // S-box power; depends on the underlying field + ark: [field; M], // Additive round keys + mds: [field; N] // MDS Matrix in row-major order } pub fn config( @@ -28,7 +28,7 @@ pub fn config( PoseidonConfig { t, rf, rp, alpha, ark, mds } } -// General Poseidon permutation on elements of type Field +// General Poseidon permutation on elements of type field fn permute(pos_conf: PoseidonConfig, mut state: [field; O]) -> [field; O] { let PoseidonConfig {t, rf, rp, alpha, ark, mds} = pos_conf; @@ -104,12 +104,12 @@ fn apply_matrix(a: [field; M], x: [field; N]) -> [field; N] { } struct PoseidonHasher{ - _state: [Field], + _state: [field], } impl Hasher for PoseidonHasher { #[field(bn254)] - fn finish(self) -> Field { + fn finish(self) -> field { let mut result = 0; let len = self._state.len(); assert(len < 16); @@ -162,7 +162,7 @@ impl Hasher for PoseidonHasher { result } - fn write(&mut self, input: Field){ + fn write(&mut self, input: field){ self._state = self._state.push_back(input); } } diff --git a/noir_stdlib/src/hash/poseidon2.nr b/noir_stdlib/src/hash/poseidon2.nr index 7acb2789e73..693cfb9bfb2 100644 --- a/noir_stdlib/src/hash/poseidon2.nr +++ b/noir_stdlib/src/hash/poseidon2.nr @@ -4,8 +4,8 @@ use crate::default::Default; global RATE: u32 = 3; struct Poseidon2 { - cache: [Field;3], - state: [Field;4], + cache: [field;3], + state: [field;4], cache_size: u32, squeeze_mode: bool, // 0 => absorb, 1 => squeeze } @@ -97,7 +97,7 @@ impl Poseidon2 { fn hash_internal(input: [field; N], in_len: u64, is_variable_length: bool) -> field { let two_pow_64 = 18446744073709551616; - let iv : Field = (in_len as Field) * two_pow_64; + let iv : field = (in_len as field) * two_pow_64; let mut sponge = Poseidon2::new(iv); for i in 0..input.len() { if i < in_len { @@ -116,12 +116,12 @@ impl Poseidon2 { } struct Poseidon2Hasher{ - _state: [Field], + _state: [field], } impl Hasher for Poseidon2Hasher { - fn finish(self) -> Field { - let iv : Field = (self._state.len() as Field)*18446744073709551616; // iv = (self._state.len() << 64) + fn finish(self) -> field { + let iv : field = (self._state.len() as field)*18446744073709551616; // iv = (self._state.len() << 64) let mut sponge = Poseidon2::new(iv); for i in 0..self._state.len() { sponge.absorb(self._state[i]); @@ -129,7 +129,7 @@ impl Hasher for Poseidon2Hasher { sponge.squeeze() } - fn write(&mut self, input: Field){ + fn write(&mut self, input: field){ self._state = self._state.push_back(input); } } diff --git a/noir_stdlib/src/ops.nr b/noir_stdlib/src/ops.nr index d855e794fb4..3c16c79a2bd 100644 --- a/noir_stdlib/src/ops.nr +++ b/noir_stdlib/src/ops.nr @@ -4,7 +4,7 @@ trait Add { } // docs:end:add-trait -impl Add for Field { fn add(self, other: Field) -> Field { self + other } } +impl Add for field { fn add(self, other: field) -> field { self + other } } impl Add for u64 { fn add(self, other: u64) -> u64 { self + other } } impl Add for u32 { fn add(self, other: u32) -> u32 { self + other } } @@ -20,7 +20,7 @@ trait Sub { } // docs:end:sub-trait -impl Sub for Field { fn sub(self, other: Field) -> Field { self - other } } +impl Sub for field { fn sub(self, other: field) -> field { self - other } } impl Sub for u64 { fn sub(self, other: u64) -> u64 { self - other } } impl Sub for u32 { fn sub(self, other: u32) -> u32 { self - other } } @@ -36,7 +36,7 @@ trait Mul { } // docs:end:mul-trait -impl Mul for Field { fn mul(self, other: Field) -> Field { self * other } } +impl Mul for field { fn mul(self, other: field) -> field { self * other } } impl Mul for u64 { fn mul(self, other: u64) -> u64 { self * other } } impl Mul for u32 { fn mul(self, other: u32) -> u32 { self * other } } @@ -52,7 +52,7 @@ trait Div { } // docs:end:div-trait -impl Div for Field { fn div(self, other: Field) -> Field { self / other } } +impl Div for field { fn div(self, other: field) -> field { self / other } } impl Div for u64 { fn div(self, other: u64) -> u64 { self / other } } impl Div for u32 { fn div(self, other: u32) -> u32 { self / other } } diff --git a/noir_stdlib/src/scalar_mul.nr b/noir_stdlib/src/scalar_mul.nr index 48df9185a2d..5e8d790130e 100644 --- a/noir_stdlib/src/scalar_mul.nr +++ b/noir_stdlib/src/scalar_mul.nr @@ -1,8 +1,8 @@ use crate::ops::Add; struct EmbeddedCurvePoint { - x: Field, - y: Field, + x: field, + y: field, } impl EmbeddedCurvePoint { diff --git a/noir_stdlib/src/schnorr.nr b/noir_stdlib/src/schnorr.nr index f262df11a71..af06f1a00ae 100644 --- a/noir_stdlib/src/schnorr.nr +++ b/noir_stdlib/src/schnorr.nr @@ -12,8 +12,8 @@ pub fn verify_signature( #[foreign(schnorr_verify)] // docs:start:schnorr_verify_slice pub fn verify_signature_slice( - public_key_x: Field, - public_key_y: Field, + public_key_x: field, + public_key_y: field, signature: [u8; 64], message: [u8] ) -> bool diff --git a/noir_stdlib/src/sha256.nr b/noir_stdlib/src/sha256.nr index 8ca6808568d..f579b0ab549 100644 --- a/noir_stdlib/src/sha256.nr +++ b/noir_stdlib/src/sha256.nr @@ -6,9 +6,9 @@ fn msg_u8_to_u32(msg: [u8; 64]) -> [u32; 16] { let mut msg32: [u32; 16] = [0; 16]; for i in 0..16 { - let mut msg_field: Field = 0; + let mut msg_field: field = 0; for j in 0..4 { - msg_field = msg_field * 256 + msg[64 - 4*(i + 1) + j] as Field; + msg_field = msg_field * 256 + msg[64 - 4*(i + 1) + j] as field; } msg32[15 - i] = msg_field as u32; } @@ -54,7 +54,7 @@ pub fn digest(msg: [u8; N]) -> [u8; 32] { } let len = 8 * msg.len(); - let len_bytes = (len as Field).to_le_bytes(8); + let len_bytes = (len as field).to_le_bytes(8); for _i in 0..64 { // In any case, fill blocks up with zeros until the last 64 (i.e. until i = 56). if i < 56 { @@ -72,7 +72,7 @@ pub fn digest(msg: [u8; N]) -> [u8; 32] { // Return final hash as byte array for j in 0..8 { - let h_bytes = (h[7 - j] as Field).to_le_bytes(4); + let h_bytes = (h[7 - j] as field).to_le_bytes(4); for k in 0..4 { out_h[31 - 4*j - k] = h_bytes[k]; } diff --git a/noir_stdlib/src/sha512.nr b/noir_stdlib/src/sha512.nr index a766ae50d55..8d3fc94167f 100644 --- a/noir_stdlib/src/sha512.nr +++ b/noir_stdlib/src/sha512.nr @@ -77,9 +77,9 @@ fn msg_u8_to_u64(msg: [u8; 128]) -> [u64; 16] { let mut msg64: [u64; 16] = [0; 16]; for i in 0..16 { - let mut msg_field: Field = 0; + let mut msg_field: field = 0; for j in 0..8 { - msg_field = msg_field * 256 + msg[128 - 8*(i + 1) + j] as Field; + msg_field = msg_field * 256 + msg[128 - 8*(i + 1) + j] as field; } msg64[15 - i] = msg_field as u64; } @@ -133,7 +133,7 @@ pub fn digest(msg: [u8; N]) -> [u8; 64] { } let len = 8 * msg.len(); - let len_bytes = (len as Field).to_le_bytes(16); + let len_bytes = (len as field).to_le_bytes(16); for _i in 0..128 { // In any case, fill blocks up with zeros until the last 128 (i.e. until i = 112). if i < 112 { @@ -153,7 +153,7 @@ pub fn digest(msg: [u8; N]) -> [u8; 64] { } // Return final hash as byte array for j in 0..8 { - let h_bytes = (h[7 - j] as Field).to_le_bytes(8); + let h_bytes = (h[7 - j] as field).to_le_bytes(8); for k in 0..8 { out_h[63 - 8*j - k] = h_bytes[k]; } diff --git a/noir_stdlib/src/test.nr b/noir_stdlib/src/test.nr index 00986e8385b..7805186f6ba 100644 --- a/noir_stdlib/src/test.nr +++ b/noir_stdlib/src/test.nr @@ -5,7 +5,7 @@ unconstrained fn create_mock_oracle(name: str) -> field {} unconstrained fn set_mock_params_oracle

(id: field, params: P) {} #[oracle(get_mock_last_params)] -unconstrained fn get_mock_last_params_oracle

(id: Field) -> P {} +unconstrained fn get_mock_last_params_oracle

(id: field) -> P {} #[oracle(set_mock_returns)] unconstrained fn set_mock_returns_oracle(id: field, returns: R) {} @@ -17,7 +17,7 @@ unconstrained fn set_mock_times_oracle(id: field, times: u64) {} unconstrained fn clear_mock_oracle(id: field) {} struct OracleMock { - id: Field, + id: field, } impl OracleMock { diff --git a/noir_stdlib/src/uint128.nr b/noir_stdlib/src/uint128.nr index c4e7e814502..c505a6536f2 100644 --- a/noir_stdlib/src/uint128.nr +++ b/noir_stdlib/src/uint128.nr @@ -1,11 +1,11 @@ use crate::ops::{Add, Sub, Mul, Div, Rem, BitOr, BitAnd, BitXor, Shl, Shr}; use crate::cmp::{Eq, Ord, Ordering}; -global pow64 : Field = 18446744073709551616; //2^64; +global pow64 : field = 18446744073709551616; //2^64; struct U128 { - lo: Field, - hi: Field, + lo: field, + hi: field, } impl U128 { @@ -24,13 +24,13 @@ impl U128 { let mut lo = 0; let mut base = 1; for i in 0..8 { - lo += (bytes[i] as Field)*base; + lo += (bytes[i] as field)*base; base *= 256; } let mut hi = 0; base = 1; for i in 8..16 { - hi += (bytes[i] as Field)*base; + hi += (bytes[i] as field)*base; base *= 256; } U128 { lo, hi } @@ -142,10 +142,10 @@ impl U128 { impl Add for U128 { fn add(self: Self, b: U128) -> U128 { let low = self.lo + b.lo; - let lo = low as u64 as Field; + let lo = low as u64 as field; let carry = (low - lo) / pow64; let high = self.hi + b.hi + carry; - let hi = high as u64 as Field; + let hi = high as u64 as field; assert(hi == high, "attempt to add with overflow"); U128 { lo, @@ -157,10 +157,10 @@ impl Add for U128 { impl Sub for U128 { fn sub(self: Self, b: U128) -> U128 { let low = pow64 + self.lo - b.lo; - let lo = low as u64 as Field; - let borrow = (low == lo) as Field; + let lo = low as u64 as field; + let borrow = (low == lo) as field; let high = self.hi - b.hi - borrow; - let hi = high as u64 as Field; + let hi = high as u64 as field; assert(hi == high, "attempt to subtract with underflow"); U128 { lo, @@ -173,14 +173,14 @@ impl Mul for U128 { fn mul(self: Self, b: U128) -> U128 { assert(self.hi*b.hi == 0, "attempt to multiply with overflow"); let low = self.lo*b.lo; - let lo = low as u64 as Field; + let lo = low as u64 as field; let carry = (low - lo) / pow64; let high = if crate::field_element::modulus_num_bits() as u32 > 196 { (self.lo+self.hi)*(b.lo+b.hi) - low + carry } else { self.lo*b.hi + self.hi*b.lo + carry }; - let hi = high as u64 as Field; + let hi = high as u64 as field; assert(hi == high, "attempt to multiply with overflow"); U128 { lo, @@ -231,8 +231,8 @@ impl Ord for U128 { impl BitOr for U128 { fn bitor(self, other: U128) -> U128 { U128 { - lo: ((self.lo as u64) | (other.lo as u64)) as Field, - hi: ((self.hi as u64) | (other.hi as u64))as Field + lo: ((self.lo as u64) | (other.lo as u64)) as field, + hi: ((self.hi as u64) | (other.hi as u64))as field } } } @@ -240,8 +240,8 @@ impl BitOr for U128 { impl BitAnd for U128 { fn bitand(self, other: U128) -> U128 { U128 { - lo: ((self.lo as u64) & (other.lo as u64)) as Field, - hi: ((self.hi as u64) & (other.hi as u64)) as Field + lo: ((self.lo as u64) & (other.lo as u64)) as field, + hi: ((self.hi as u64) & (other.hi as u64)) as field } } } @@ -249,8 +249,8 @@ impl BitAnd for U128 { impl BitXor for U128 { fn bitxor(self, other: U128) -> U128 { U128 { - lo: ((self.lo as u64) ^ (other.lo as u64)) as Field, - hi: ((self.hi as u64) ^ (other.hi as u64)) as Field + lo: ((self.lo as u64) ^ (other.lo as u64)) as field, + hi: ((self.hi as u64) ^ (other.hi as u64)) as field } } } @@ -260,10 +260,10 @@ impl Shl for U128 { assert(other < U128::from_u64s_le(128,0), "attempt to shift left with overflow"); let exp_bits = other.lo.to_be_bits(7); - let mut r: Field = 2; - let mut y: Field = 1; + let mut r: field = 2; + let mut y: field = 1; for i in 1..8 { - y = (exp_bits[7-i] as Field) * (r * y) + (1 - exp_bits[7-i] as Field) * y; + y = (exp_bits[7-i] as field) * (r * y) + (1 - exp_bits[7-i] as field) * y; r *= r; } self.wrapping_mul(U128::from_integer(y)) @@ -275,10 +275,10 @@ impl Shr for U128 { assert(other < U128::from_u64s_le(128,0), "attempt to shift right with overflow"); let exp_bits = other.lo.to_be_bits(7); - let mut r: Field = 2; - let mut y: Field = 1; + let mut r: field = 2; + let mut y: field = 1; for i in 1..8 { - y = (exp_bits[7-i] as Field) * (r * y) + (1 - exp_bits[7-i] as Field) * y; + y = (exp_bits[7-i] as field) * (r * y) + (1 - exp_bits[7-i] as field) * y; r *= r; } self / U128::from_integer(y) From 5eaf64abaa18c119cee5163a268be5fecf63ef18 Mon Sep 17 00:00:00 2001 From: Tom French Date: Sat, 20 Apr 2024 15:33:55 +0100 Subject: [PATCH 15/19] chore: update test programs --- .../array_length_defaulting/src/main.nr | 2 +- .../assert_constant_fail/src/main.nr | 4 +- .../brillig_mut_ref_from_acir/src/main.nr | 4 +- .../brillig_nested_slices/src/main.nr | 8 +- .../brillig_slice_to_acir/src/main.nr | 2 +- .../brillig_vec_to_acir/src/main.nr | 2 +- .../builtin_function_declaration/src/main.nr | 4 +- .../constrain_typo/src/main.nr | 4 +- .../custom_entry_not_found/src/main.nr | 2 +- .../dep_impl_primitive/src/main.nr | 2 +- .../compile_failure/depend_on_bin/src/main.nr | 2 +- .../dup_trait_items_2/src/main.nr | 2 +- .../duplicate_declaration/src/main.nr | 4 +- .../compile_failure/field_modulo/src/main.nr | 2 +- .../foreign_function_declaration/src/main.nr | 4 +- .../invalid_dependency_name/src/main.nr | 2 +- .../src/main.nr | 4 +- .../mutability_regression_2911/src/main.nr | 2 +- .../nested_slice_declared_type/src/main.nr | 4 +- .../nested_slice_literal/src/main.nr | 8 +- .../nested_slice_struct/src/main.nr | 10 +- .../no_impl_from_function/src/main.nr | 2 +- .../no_nested_impl/src/main.nr | 4 +- .../orphaned_trait_impl/src/main.nr | 2 +- .../package_name_empty/src/main.nr | 2 +- .../package_name_hyphen/src/main.nr | 2 +- .../primary_attribute_struct/src/main.nr | 4 +- .../radix_non_constant_length/src/main.nr | 2 +- .../typevar_default/src/main.nr | 2 +- .../unconstrained_oracle/src/main.nr | 2 +- .../unconstrained_ref/src/main.nr | 2 +- .../crates/a/src/main.nr | 2 +- .../crates/b/src/main.nr | 2 +- .../contract_with_impl/src/main.nr | 2 +- .../fold_non_contract_method/src/main.nr | 8 +- .../simple_contract/src/main.nr | 6 +- .../attributes_struct/src/main.nr | 4 +- .../src/main.nr | 2 +- .../ec_baby_jubjub/src/main.nr | 2 +- .../higher_order_fn_selector/src/main.nr | 4 +- .../impl_with_where_clause/src/main.nr | 6 +- .../numeric_generics/src/main.nr | 2 +- .../compile_success_empty/option/src/main.nr | 2 +- .../regression_4635/src/main.nr | 22 +- .../ret_fn_ret_cl/src/main.nr | 6 +- .../src/main.nr | 8 +- .../trait_default_implementation/src/main.nr | 10 +- .../trait_function_calls/src/main.nr | 312 +++++++++--------- .../trait_generics/src/main.nr | 12 +- .../trait_override_implementation/src/main.nr | 32 +- .../trait_static_methods/src/main.nr | 22 +- .../trait_where_clause/src/main.nr | 18 +- .../trait_where_clause/src/the_trait.nr | 4 +- .../compile_success_empty/traits/src/main.nr | 8 +- .../library2/src/lib.nr | 2 +- .../assert_msg_runtime/src/main.nr | 2 +- .../brillig_assert_fail/src/main.nr | 4 +- .../brillig_assert_msg_runtime/src/main.nr | 4 +- .../div_by_zero_constants/src/main.nr | 2 +- .../div_by_zero_numerator_witness/src/main.nr | 4 +- .../div_by_zero_witness/src/main.nr | 4 +- .../dyn_index_fail_nested_array/src/main.nr | 6 +- .../dynamic_index_failure/src/main.nr | 2 +- .../fold_dyn_index_fail/src/main.nr | 4 +- .../src/main.nr | 10 +- .../hashmap_load_factor/src/main.nr | 6 +- .../slice_access_failure/src/main.nr | 2 +- .../slice_insert_failure/src/main.nr | 2 +- .../slice_remove_failure/src/main.nr | 2 +- .../workspace_fail/crates/a/src/main.nr | 2 +- .../workspace_fail/crates/b/src/main.nr | 2 +- .../1327_concrete_in_generic/src/main.nr | 4 +- .../execution_success/7_function/src/main.nr | 6 +- .../src/main.nr | 4 +- .../array_to_slice/src/main.nr | 20 +- .../src/main.nr | 4 +- .../execution_success/bigint/src/main.nr | 4 +- .../brillig_array_to_slice/src/main.nr | 6 +- .../execution_success/brillig_cow/src/main.nr | 6 +- .../brillig_cow_regression/src/main.nr | 20 +- .../brillig_identity_function/src/main.nr | 4 +- .../brillig_keccak/src/main.nr | 2 +- .../brillig_nested_arrays/src/main.nr | 6 +- .../brillig_references/src/main.nr | 10 +- .../brillig_scalar_mul/src/main.nr | 4 +- .../brillig_sha256/src/main.nr | 2 +- .../brillig_slice_input/src/main.nr | 6 +- .../brillig_slices/src/main.nr | 4 +- .../brillig_to_bytes_integration/src/main.nr | 2 +- .../execution_success/debug_logs/src/main.nr | 14 +- .../double_verify_proof_recursive/src/main.nr | 10 +- .../execution_success/eddsa/src/main.nr | 4 +- .../execution_success/fold_basic/src/main.nr | 4 +- .../fold_basic_nested_call/src/main.nr | 6 +- .../fold_call_witness_condition/src/main.nr | 4 +- .../fold_numeric_generic_poseidon/src/main.nr | 6 +- .../execution_success/generics/src/main.nr | 14 +- .../global_consts/src/main.nr | 28 +- .../execution_success/hashmap/src/main.nr | 24 +- .../integer_array_indexing/src/main.nr | 2 +- .../execution_success/keccak256/src/main.nr | 2 +- .../nested_array_dynamic/src/main.nr | 8 +- .../nested_array_in_slice/src/main.nr | 6 +- .../nested_arrays_from_brillig/src/main.nr | 6 +- .../execution_success/prelude/src/main.nr | 4 +- .../execution_success/references/src/main.nr | 10 +- .../regression_3889/src/main.nr | 4 +- .../regression_4088/src/main.nr | 6 +- .../regression_4124/src/main.nr | 12 +- .../regression_4436/src/main.nr | 10 +- .../regression_capacity_tracker/src/main.nr | 2 +- .../src/main.nr | 2 +- .../execution_success/scalar_mul/src/main.nr | 4 +- .../execution_success/sha256/src/main.nr | 2 +- .../side_effects_constrain_array/src/main.nr | 2 +- .../simple_2d_array/src/main.nr | 2 +- .../slice_coercion/src/main.nr | 6 +- .../slice_dynamic_index/src/main.nr | 2 +- .../execution_success/slice_loop/src/main.nr | 8 +- .../execution_success/slices/src/main.nr | 4 +- .../execution_success/strings/src/main.nr | 8 +- .../execution_success/struct/src/main.nr | 12 +- .../struct_array_inputs/src/main.nr | 4 +- .../struct_fields_ordering/src/main.nr | 2 +- .../struct_inputs/src/foo.nr | 2 +- .../struct_inputs/src/foo/bar.nr | 4 +- .../struct_inputs/src/main.nr | 2 +- .../to_bytes_integration/src/main.nr | 2 +- .../trait_as_return_type/src/main.nr | 10 +- .../trait_impl_base_type/src/main.nr | 64 ++-- .../traits_in_crates_1/crate2/src/lib.nr | 2 +- .../traits_in_crates_2/crate2/src/lib.nr | 2 +- .../tuple_inputs/src/main.nr | 6 +- .../type_aliases/src/main.nr | 4 +- .../witness_compression/src/main.nr | 2 +- .../workspace/crates/a/src/main.nr | 2 +- .../workspace/crates/b/src/main.nr | 2 +- .../workspace_default_member/a/src/main.nr | 2 +- .../workspace_default_member/b/src/main.nr | 2 +- .../noir_test_success/bounded_vec/src/main.nr | 44 +-- .../brillig_overflow_checks/src/main.nr | 2 +- .../noir_test_success/mock_oracle/src/main.nr | 18 +- .../out_of_bounds_alignment/src/main.nr | 4 +- .../test_libraries/bad_impl/src/lib.nr | 4 +- .../test_libraries/bin_dep/src/main.nr | 2 +- .../test_libraries/diamond_deps_1/src/lib.nr | 2 +- .../test_libraries/diamond_deps_2/src/lib.nr | 2 +- .../test_libraries/exporting_lib/src/lib.nr | 2 +- 148 files changed, 602 insertions(+), 602 deletions(-) diff --git a/test_programs/compile_failure/array_length_defaulting/src/main.nr b/test_programs/compile_failure/array_length_defaulting/src/main.nr index 216a9ae3f0c..641d08aeb3a 100644 --- a/test_programs/compile_failure/array_length_defaulting/src/main.nr +++ b/test_programs/compile_failure/array_length_defaulting/src/main.nr @@ -3,7 +3,7 @@ fn main() { foo(x); } -fn foo(array: [Field; N]) { +fn foo(array: [field; N]) { for elem in array { println(elem); } diff --git a/test_programs/compile_failure/assert_constant_fail/src/main.nr b/test_programs/compile_failure/assert_constant_fail/src/main.nr index cf682607083..b045ab8db01 100644 --- a/test_programs/compile_failure/assert_constant_fail/src/main.nr +++ b/test_programs/compile_failure/assert_constant_fail/src/main.nr @@ -1,10 +1,10 @@ use dep::std::assert_constant; -fn main(x: Field) { +fn main(x: field) { foo(5, x); } -fn foo(constant: Field, non_constant: Field) { +fn foo(constant: field, non_constant: field) { assert_constant(constant); assert_constant(non_constant); } diff --git a/test_programs/compile_failure/brillig_mut_ref_from_acir/src/main.nr b/test_programs/compile_failure/brillig_mut_ref_from_acir/src/main.nr index 473ad8e8d6a..2dae17e6f9c 100644 --- a/test_programs/compile_failure/brillig_mut_ref_from_acir/src/main.nr +++ b/test_programs/compile_failure/brillig_mut_ref_from_acir/src/main.nr @@ -1,8 +1,8 @@ -unconstrained fn mut_ref_identity(value: &mut Field) -> Field { +unconstrained fn mut_ref_identity(value: &mut field) -> field { *value } -fn main(mut x: Field, y: pub Field) { +fn main(mut x: field, y: pub field) { let returned_x = mut_ref_identity(&mut x); assert(returned_x == x); } diff --git a/test_programs/compile_failure/brillig_nested_slices/src/main.nr b/test_programs/compile_failure/brillig_nested_slices/src/main.nr index 3d8a6748ccf..9828c71bb3c 100644 --- a/test_programs/compile_failure/brillig_nested_slices/src/main.nr +++ b/test_programs/compile_failure/brillig_nested_slices/src/main.nr @@ -5,17 +5,17 @@ unconstrained fn push_back_to_slice(slice: [T], item: T) -> [T] { } struct NestedSliceStruct { - id: Field, - arr: [Field] + id: field, + arr: [field] } -unconstrained fn create_foo(id: Field, value: Field) -> NestedSliceStruct { +unconstrained fn create_foo(id: field, value: field) -> NestedSliceStruct { let mut arr = [id]; arr = arr.push_back(value); NestedSliceStruct { id, arr } } -unconstrained fn main(a: Field, b: Field) { +unconstrained fn main(a: field, b: field) { let mut slice = [create_foo(a, b), create_foo(b, a)]; assert(slice.len() == 2); diff --git a/test_programs/compile_failure/brillig_slice_to_acir/src/main.nr b/test_programs/compile_failure/brillig_slice_to_acir/src/main.nr index dcf23aac5f5..4345836b12c 100644 --- a/test_programs/compile_failure/brillig_slice_to_acir/src/main.nr +++ b/test_programs/compile_failure/brillig_slice_to_acir/src/main.nr @@ -1,4 +1,4 @@ -global DEPTH: Field = 40000; +global DEPTH: field = 40000; fn main(x: [u32; DEPTH], y: u32) { let mut new_x = []; diff --git a/test_programs/compile_failure/brillig_vec_to_acir/src/main.nr b/test_programs/compile_failure/brillig_vec_to_acir/src/main.nr index 8f872f1b903..5e8aaaf4ea2 100644 --- a/test_programs/compile_failure/brillig_vec_to_acir/src/main.nr +++ b/test_programs/compile_failure/brillig_vec_to_acir/src/main.nr @@ -1,4 +1,4 @@ -global DEPTH: Field = 40000; +global DEPTH: field = 40000; fn main(x: [u32; DEPTH], y: u32) { let mut new_x = Vec::new(); diff --git a/test_programs/compile_failure/builtin_function_declaration/src/main.nr b/test_programs/compile_failure/builtin_function_declaration/src/main.nr index ed376557371..548b39c06fb 100644 --- a/test_programs/compile_failure/builtin_function_declaration/src/main.nr +++ b/test_programs/compile_failure/builtin_function_declaration/src/main.nr @@ -2,9 +2,9 @@ // This would otherwise be a perfectly valid declaration of the `to_le_bits` builtin function #[builtin(to_le_bits)] -fn to_le_bits(_x: Field, _bit_size: u32) -> [u1] {} +fn to_le_bits(_x: field, _bit_size: u32) -> [u1] {} -fn main(x: Field) -> pub u1 { +fn main(x: field) -> pub u1 { let bits = to_le_bits(x, 100); bits[0] } diff --git a/test_programs/compile_failure/constrain_typo/src/main.nr b/test_programs/compile_failure/constrain_typo/src/main.nr index ee99663da46..1ae5bdc19fa 100644 --- a/test_programs/compile_failure/constrain_typo/src/main.nr +++ b/test_programs/compile_failure/constrain_typo/src/main.nr @@ -2,6 +2,6 @@ // This should not compile as the keyword // is `constrain` and not `constrai` -fn main(x : Field, y : Field) { +fn main(x : field, y : field) { constrai x != y; -} \ No newline at end of file +} diff --git a/test_programs/compile_failure/custom_entry_not_found/src/main.nr b/test_programs/compile_failure/custom_entry_not_found/src/main.nr index 00e94414c0b..63916c93978 100644 --- a/test_programs/compile_failure/custom_entry_not_found/src/main.nr +++ b/test_programs/compile_failure/custom_entry_not_found/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field) { +fn main(x: field) { assert(x == 1); } diff --git a/test_programs/compile_failure/dep_impl_primitive/src/main.nr b/test_programs/compile_failure/dep_impl_primitive/src/main.nr index e61ae82b62c..a3ebb9ee49d 100644 --- a/test_programs/compile_failure/dep_impl_primitive/src/main.nr +++ b/test_programs/compile_failure/dep_impl_primitive/src/main.nr @@ -1,5 +1,5 @@ use dep::bad_impl; -fn main(x: Field) { +fn main(x: field) { x.something(); } diff --git a/test_programs/compile_failure/depend_on_bin/src/main.nr b/test_programs/compile_failure/depend_on_bin/src/main.nr index 4e03e8eb41e..5f1ce709f84 100644 --- a/test_programs/compile_failure/depend_on_bin/src/main.nr +++ b/test_programs/compile_failure/depend_on_bin/src/main.nr @@ -1,5 +1,5 @@ use dep::bin_dep; -fn main(x : Field) { +fn main(x : field) { assert(x == 1); } diff --git a/test_programs/compile_failure/dup_trait_items_2/src/main.nr b/test_programs/compile_failure/dup_trait_items_2/src/main.nr index cdcac745208..ed404a488ec 100644 --- a/test_programs/compile_failure/dup_trait_items_2/src/main.nr +++ b/test_programs/compile_failure/dup_trait_items_2/src/main.nr @@ -1,6 +1,6 @@ trait MyTrait { let SomeConst: u32; - let SomeConst: Field; + let SomeConst: field; } fn main() {} diff --git a/test_programs/compile_failure/duplicate_declaration/src/main.nr b/test_programs/compile_failure/duplicate_declaration/src/main.nr index e4433ef4078..21e4a8d1359 100644 --- a/test_programs/compile_failure/duplicate_declaration/src/main.nr +++ b/test_programs/compile_failure/duplicate_declaration/src/main.nr @@ -1,8 +1,8 @@ // Duplicate functions should not compile -fn hello(x: Field) -> Field { +fn hello(x: field) -> field { x } -fn hello(x: Field) -> Field { +fn hello(x: field) -> field { x } diff --git a/test_programs/compile_failure/field_modulo/src/main.nr b/test_programs/compile_failure/field_modulo/src/main.nr index a482b68806b..a622e118d62 100644 --- a/test_programs/compile_failure/field_modulo/src/main.nr +++ b/test_programs/compile_failure/field_modulo/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field) -> pub Field { +fn main(x: field) -> pub field { x % 2 } diff --git a/test_programs/compile_failure/foreign_function_declaration/src/main.nr b/test_programs/compile_failure/foreign_function_declaration/src/main.nr index 6273067f6a7..c00a0386970 100644 --- a/test_programs/compile_failure/foreign_function_declaration/src/main.nr +++ b/test_programs/compile_failure/foreign_function_declaration/src/main.nr @@ -3,8 +3,8 @@ // This would otherwise be a perfectly valid definition of the `pedersen_hash` black box function, // however executing the circuit results in an unhelpful ICE. #[foreign(pedersen_hash)] -fn my_pedersen_hash(_input: [Field; N]) -> Field {} +fn my_pedersen_hash(_input: [field; N]) -> field {} -fn main() -> pub Field { +fn main() -> pub field { my_pedersen_hash([1]) } diff --git a/test_programs/compile_failure/invalid_dependency_name/src/main.nr b/test_programs/compile_failure/invalid_dependency_name/src/main.nr index faf1ba0045a..497009d1e5b 100644 --- a/test_programs/compile_failure/invalid_dependency_name/src/main.nr +++ b/test_programs/compile_failure/invalid_dependency_name/src/main.nr @@ -1 +1 @@ -fn main(x: Field) { } +fn main(x: field) { } diff --git a/test_programs/compile_failure/multiple_primary_attributes_fail/src/main.nr b/test_programs/compile_failure/multiple_primary_attributes_fail/src/main.nr index c8d8b0a1969..2bc01f377e4 100644 --- a/test_programs/compile_failure/multiple_primary_attributes_fail/src/main.nr +++ b/test_programs/compile_failure/multiple_primary_attributes_fail/src/main.nr @@ -1,6 +1,6 @@ #[oracle(oracleName)] #[builtin(builtinName)] -fn main(x: Field) -> pub Field { +fn main(x: field) -> pub field { x + 1 -} \ No newline at end of file +} diff --git a/test_programs/compile_failure/mutability_regression_2911/src/main.nr b/test_programs/compile_failure/mutability_regression_2911/src/main.nr index a0d53706f97..157dfea5612 100644 --- a/test_programs/compile_failure/mutability_regression_2911/src/main.nr +++ b/test_programs/compile_failure/mutability_regression_2911/src/main.nr @@ -1,5 +1,5 @@ // Expect 'Variable must be mutable to be assigned to' error fn main() { - let slice : &mut [Field] = &mut []; + let slice : &mut [field] = &mut []; slice = &mut (*slice).push_back(1); } diff --git a/test_programs/compile_failure/nested_slice_declared_type/src/main.nr b/test_programs/compile_failure/nested_slice_declared_type/src/main.nr index 417f9a092e0..899a3732caa 100644 --- a/test_programs/compile_failure/nested_slice_declared_type/src/main.nr +++ b/test_programs/compile_failure/nested_slice_declared_type/src/main.nr @@ -1,6 +1,6 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y); - let slice: [[Field]] = []; + let slice: [[field]] = []; assert(slice.len() != 10); } diff --git a/test_programs/compile_failure/nested_slice_literal/src/main.nr b/test_programs/compile_failure/nested_slice_literal/src/main.nr index 3140818d0b2..8636e843c33 100644 --- a/test_programs/compile_failure/nested_slice_literal/src/main.nr +++ b/test_programs/compile_failure/nested_slice_literal/src/main.nr @@ -1,19 +1,19 @@ struct FooParent { - parent_arr: [Field; 3], + parent_arr: [field; 3], foos: [Foo], } struct Bar { - inner: [Field; 3], + inner: [field; 3], } struct Foo { - a: Field, + a: field, b: T, bar: Bar, } -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y); let foo = Foo { a: 7, b: [8, 9, 22].as_slice(), bar: Bar { inner: [106, 107, 108] } }; diff --git a/test_programs/compile_failure/nested_slice_struct/src/main.nr b/test_programs/compile_failure/nested_slice_struct/src/main.nr index 9fed4cfc299..dd2a59b14cb 100644 --- a/test_programs/compile_failure/nested_slice_struct/src/main.nr +++ b/test_programs/compile_failure/nested_slice_struct/src/main.nr @@ -1,18 +1,18 @@ struct FooParent { - parent_arr: [Field; 3], + parent_arr: [field; 3], foos: [Foo], } struct Bar { - inner: [Field; 3], + inner: [field; 3], } struct Foo { - a: Field, - b: [Field], + a: field, + b: [field], bar: Bar, } -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y); } diff --git a/test_programs/compile_failure/no_impl_from_function/src/main.nr b/test_programs/compile_failure/no_impl_from_function/src/main.nr index b0c485c2bf5..8c1b5e1eeeb 100644 --- a/test_programs/compile_failure/no_impl_from_function/src/main.nr +++ b/test_programs/compile_failure/no_impl_from_function/src/main.nr @@ -1,5 +1,5 @@ fn main() { - let array: [Field; 3] = [1, 2, 3]; + let array: [field; 3] = [1, 2, 3]; assert(foo(array)); // Ensure this still works if we have to infer the type of the integer literals diff --git a/test_programs/compile_failure/no_nested_impl/src/main.nr b/test_programs/compile_failure/no_nested_impl/src/main.nr index 1f1056fb6d9..eb67279c89d 100644 --- a/test_programs/compile_failure/no_nested_impl/src/main.nr +++ b/test_programs/compile_failure/no_nested_impl/src/main.nr @@ -1,5 +1,5 @@ fn main() { - let a: [[[[Field; 2]; 2]; 2]; 2] = [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]; + let a: [[[[field; 2]; 2]; 2]; 2] = [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]; assert(a.my_eq(a)); } @@ -13,7 +13,7 @@ impl MyEq for [T; 2] where T: MyEq { & self[0].my_eq(other[0]) } } -// Impl for u32 but not Field +// Impl for u32 but not field impl MyEq for u32 { fn my_eq(self, other: Self) -> bool { self == other diff --git a/test_programs/compile_failure/orphaned_trait_impl/src/main.nr b/test_programs/compile_failure/orphaned_trait_impl/src/main.nr index dfd88d8f074..1f8a3f5cda6 100644 --- a/test_programs/compile_failure/orphaned_trait_impl/src/main.nr +++ b/test_programs/compile_failure/orphaned_trait_impl/src/main.nr @@ -1,6 +1,6 @@ impl dep::crate1::MyTrait for dep::crate2::MyStruct { } -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y); } diff --git a/test_programs/compile_failure/package_name_empty/src/main.nr b/test_programs/compile_failure/package_name_empty/src/main.nr index faf1ba0045a..497009d1e5b 100644 --- a/test_programs/compile_failure/package_name_empty/src/main.nr +++ b/test_programs/compile_failure/package_name_empty/src/main.nr @@ -1 +1 @@ -fn main(x: Field) { } +fn main(x: field) { } diff --git a/test_programs/compile_failure/package_name_hyphen/src/main.nr b/test_programs/compile_failure/package_name_hyphen/src/main.nr index faf1ba0045a..497009d1e5b 100644 --- a/test_programs/compile_failure/package_name_hyphen/src/main.nr +++ b/test_programs/compile_failure/package_name_hyphen/src/main.nr @@ -1 +1 @@ -fn main(x: Field) { } +fn main(x: field) { } diff --git a/test_programs/compile_failure/primary_attribute_struct/src/main.nr b/test_programs/compile_failure/primary_attribute_struct/src/main.nr index 8922ef60091..a846d78f240 100644 --- a/test_programs/compile_failure/primary_attribute_struct/src/main.nr +++ b/test_programs/compile_failure/primary_attribute_struct/src/main.nr @@ -1,8 +1,8 @@ // An primary attribute should not be able to be added to a struct defintion #[oracle(some_oracle)] struct SomeStruct{ - x: Field, - y: Field + x: field, + y: field } fn main() {} diff --git a/test_programs/compile_failure/radix_non_constant_length/src/main.nr b/test_programs/compile_failure/radix_non_constant_length/src/main.nr index c6dd68d925c..8db367a9da2 100644 --- a/test_programs/compile_failure/radix_non_constant_length/src/main.nr +++ b/test_programs/compile_failure/radix_non_constant_length/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub u32) { +fn main(x: field, y: pub u32) { let bytes = x.to_be_bytes(y); assert(bytes[0] == 0); } diff --git a/test_programs/compile_failure/typevar_default/src/main.nr b/test_programs/compile_failure/typevar_default/src/main.nr index 1eb9cf63de3..bd850b770bf 100644 --- a/test_programs/compile_failure/typevar_default/src/main.nr +++ b/test_programs/compile_failure/typevar_default/src/main.nr @@ -3,7 +3,7 @@ fn main() { let _ = slice_to_array(&[1, 2, 3]); } -fn slice_to_array(slice: [Field]) -> [Field; N] { +fn slice_to_array(slice: [field]) -> [field; N] { let mut array = [0; N]; for i in 0 .. N { array[i] = slice[i]; diff --git a/test_programs/compile_failure/unconstrained_oracle/src/main.nr b/test_programs/compile_failure/unconstrained_oracle/src/main.nr index abc7bf51ab8..b3b1352ebac 100644 --- a/test_programs/compile_failure/unconstrained_oracle/src/main.nr +++ b/test_programs/compile_failure/unconstrained_oracle/src/main.nr @@ -1,5 +1,5 @@ #[oracle(getNoun)] -unconstrained fn external_fn() -> Field { +unconstrained fn external_fn() -> field { 100 / 5 } diff --git a/test_programs/compile_failure/unconstrained_ref/src/main.nr b/test_programs/compile_failure/unconstrained_ref/src/main.nr index 1491badaa49..537eb399719 100644 --- a/test_programs/compile_failure/unconstrained_ref/src/main.nr +++ b/test_programs/compile_failure/unconstrained_ref/src/main.nr @@ -1,4 +1,4 @@ -unconstrained fn uncon_ref() -> &mut Field { +unconstrained fn uncon_ref() -> &mut field { let lr = &mut 7; lr } diff --git a/test_programs/compile_failure/workspace_missing_toml/crates/a/src/main.nr b/test_programs/compile_failure/workspace_missing_toml/crates/a/src/main.nr index cf72627da2e..0b95af211b2 100644 --- a/test_programs/compile_failure/workspace_missing_toml/crates/a/src/main.nr +++ b/test_programs/compile_failure/workspace_missing_toml/crates/a/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x == y); } diff --git a/test_programs/compile_failure/workspace_missing_toml/crates/b/src/main.nr b/test_programs/compile_failure/workspace_missing_toml/crates/b/src/main.nr index 4e1fd3c9035..43e9fa2196f 100644 --- a/test_programs/compile_failure/workspace_missing_toml/crates/b/src/main.nr +++ b/test_programs/compile_failure/workspace_missing_toml/crates/b/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y); } diff --git a/test_programs/compile_success_contract/contract_with_impl/src/main.nr b/test_programs/compile_success_contract/contract_with_impl/src/main.nr index 1c6b6c217c4..8d55e89df96 100644 --- a/test_programs/compile_success_contract/contract_with_impl/src/main.nr +++ b/test_programs/compile_success_contract/contract_with_impl/src/main.nr @@ -1,5 +1,5 @@ contract Foo { - struct T { x: [Field] } + struct T { x: [field] } impl T { fn t(self) {} diff --git a/test_programs/compile_success_contract/fold_non_contract_method/src/main.nr b/test_programs/compile_success_contract/fold_non_contract_method/src/main.nr index 2e00ffa1381..423e37a0588 100644 --- a/test_programs/compile_success_contract/fold_non_contract_method/src/main.nr +++ b/test_programs/compile_success_contract/fold_non_contract_method/src/main.nr @@ -1,18 +1,18 @@ contract Foo { use crate::times_10; - fn double(x: Field) -> pub Field { + fn double(x: field) -> pub field { x * 2 } - fn triple(x: Field) -> pub Field { + fn triple(x: field) -> pub field { x * 3 } - fn times_40(x: Field) -> pub Field { + fn times_40(x: field) -> pub field { times_10(x) * 4 } } #[fold] -fn times_10(x: Field) -> Field { +fn times_10(x: field) -> field { x * 10 } diff --git a/test_programs/compile_success_contract/simple_contract/src/main.nr b/test_programs/compile_success_contract/simple_contract/src/main.nr index 7412e1386bf..6ad5b43f1f8 100644 --- a/test_programs/compile_success_contract/simple_contract/src/main.nr +++ b/test_programs/compile_success_contract/simple_contract/src/main.nr @@ -1,11 +1,11 @@ contract Foo { - fn double(x: Field) -> pub Field { + fn double(x: field) -> pub field { x * 2 } - fn triple(x: Field) -> pub Field { + fn triple(x: field) -> pub field { x * 3 } - fn quadruple(x: Field) -> pub Field { + fn quadruple(x: field) -> pub field { x * 4 } // Regression for issue #3344 diff --git a/test_programs/compile_success_empty/attributes_struct/src/main.nr b/test_programs/compile_success_empty/attributes_struct/src/main.nr index 0bad42aee57..1109bead753 100644 --- a/test_programs/compile_success_empty/attributes_struct/src/main.nr +++ b/test_programs/compile_success_empty/attributes_struct/src/main.nr @@ -1,8 +1,8 @@ #[some_attribute] #[another_attribute] struct SomeStruct { - a: Field, - b: Field + a: field, + b: field } fn main() {} diff --git a/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr b/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr index 3cf86628d94..5c821505be1 100644 --- a/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr +++ b/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr @@ -8,7 +8,7 @@ fn main() { let mut c1 = 0; for i in 0..2 { let mut as_bits = (arr[i] as field).to_le_bits(2); - c1 = c1 + as_bits[0] as Field; + c1 = c1 + as_bits[0] as field; if i == 0 { assert(arr[i] == 1); // 1 diff --git a/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr b/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr index becd3c8927a..a26599073f6 100644 --- a/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr +++ b/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr @@ -11,7 +11,7 @@ use dep::std::ec::montcurve::affine::Point as MGaffine; use dep::std::ec::montcurve::curvegroup::Point as MG; fn main() { - // This test only makes sense if Field is the right prime field. + // This test only makes sense if field is the right prime field. if 21888242871839275222246405745257275088548364400416034343698204186575808495617 == 0 { // Define Baby Jubjub (ERC-2494) parameters in affine representation let bjj_affine = AffineCurve::new( diff --git a/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr b/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr index 1ba16506cb1..1a3600d8758 100644 --- a/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr +++ b/test_programs/compile_success_empty/higher_order_fn_selector/src/main.nr @@ -16,13 +16,13 @@ fn selector(flag: &mut bool) -> fn(&mut field) -> () { fn main() { let mut flag: bool = true; - let mut x: Field = 100; + let mut x: field = 100; let returned_func = selector(&mut flag); returned_func(&mut x); assert(x == 200); - let mut y: Field = 100; + let mut y: field = 100; let returned_func2 = selector(&mut flag); returned_func2(&mut y); diff --git a/test_programs/compile_success_empty/impl_with_where_clause/src/main.nr b/test_programs/compile_success_empty/impl_with_where_clause/src/main.nr index 780512f04dc..1043dfb50bb 100644 --- a/test_programs/compile_success_empty/impl_with_where_clause/src/main.nr +++ b/test_programs/compile_success_empty/impl_with_where_clause/src/main.nr @@ -1,5 +1,5 @@ fn main() { - let array: [Field; 3] = [1, 2, 3]; + let array: [field; 3] = [1, 2, 3]; assert(array.my_eq(array)); // Ensure this still works if we have to infer the type of the integer literals let array = [1, 2, 3]; @@ -20,8 +20,8 @@ impl MyEq for [T; 3] where T: MyEq { } } -impl MyEq for Field { - fn my_eq(self, other: Field) -> bool { +impl MyEq for field { + fn my_eq(self, other: field) -> bool { self == other } } diff --git a/test_programs/compile_success_empty/numeric_generics/src/main.nr b/test_programs/compile_success_empty/numeric_generics/src/main.nr index c3583f4c3fe..24985a47a86 100644 --- a/test_programs/compile_success_empty/numeric_generics/src/main.nr +++ b/test_programs/compile_success_empty/numeric_generics/src/main.nr @@ -19,7 +19,7 @@ fn id(x: [field; I]) -> [field; I] { } struct MyStruct { - data: [Field; S], + data: [field; S], } impl MyStruct { diff --git a/test_programs/compile_success_empty/option/src/main.nr b/test_programs/compile_success_empty/option/src/main.nr index c5f321256b1..0690ebee22b 100644 --- a/test_programs/compile_success_empty/option/src/main.nr +++ b/test_programs/compile_success_empty/option/src/main.nr @@ -37,7 +37,7 @@ fn main() { assert(some.and(none).is_none()); assert(some.and(some).is_some()); - let add1_u64 = |value: Field| Option::some(value as u64 + 1); + let add1_u64 = |value: field| Option::some(value as u64 + 1); assert(none.and_then(|_value| none).is_none()); assert(none.and_then(add1_u64).is_none()); diff --git a/test_programs/compile_success_empty/regression_4635/src/main.nr b/test_programs/compile_success_empty/regression_4635/src/main.nr index 23918e30785..0bcac2b7e95 100644 --- a/test_programs/compile_success_empty/regression_4635/src/main.nr +++ b/test_programs/compile_success_empty/regression_4635/src/main.nr @@ -1,31 +1,31 @@ -trait FromField { - fn from_field(field: Field) -> Self; +trait Fromfield { + fn from_field(field: field) -> Self; } -impl FromField for Field { - fn from_field(value: Field) -> Self { +impl Fromfield for field { + fn from_field(value: field) -> Self { value } } trait Deserialize { - fn deserialize(fields: [Field; N]) -> Self; + fn deserialize(fields: [field; N]) -> Self; } global AZTEC_ADDRESS_LENGTH = 1; struct AztecAddress { - inner : Field + inner : field } -impl FromField for AztecAddress { - fn from_field(value: Field) -> Self { +impl Fromfield for AztecAddress { + fn from_field(value: field) -> Self { Self { inner: value } } } impl Deserialize for AztecAddress { - fn deserialize(fields: [Field; AZTEC_ADDRESS_LENGTH]) -> Self { + fn deserialize(fields: [field; AZTEC_ADDRESS_LENGTH]) -> Self { AztecAddress::from_field(fields[0]) } } @@ -43,8 +43,8 @@ struct MyStruct { } impl Deserialize<1> for MyStruct { - fn deserialize(fields: [Field; 1]) -> Self where T: FromField { - Self{ a: FromField::from_field(fields[0]) } + fn deserialize(fields: [field; 1]) -> Self where T: Fromfield { + Self{ a: Fromfield::from_field(fields[0]) } } } diff --git a/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr b/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr index a3644f9ceb7..834822321aa 100644 --- a/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr +++ b/test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr @@ -9,15 +9,15 @@ fn ret_fn() -> fn(field) -> field { // which would support higher-order functions in a better way // support returning closures: // -// fn ret_closure() -> fn(Field) -> Field { +// fn ret_closure() -> fn(field) -> field { // let y = 1; -// let inner_closure = |z| -> Field{ +// let inner_closure = |z| -> field{ // z + y // }; // inner_closure // } fn ret_lambda() -> fn(field) -> field { - let cl = |z: Field| -> Field { + let cl = |z: field| -> field { z + 1 }; cl diff --git a/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr b/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr index e4baa324692..05808d5047d 100644 --- a/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr +++ b/test_programs/compile_success_empty/trait_associated_member_names_clashes/src/main.nr @@ -1,9 +1,9 @@ trait Trait1 { - fn tralala() -> Field; + fn tralala() -> field; } trait Trait2 { - fn tralala() -> Field; + fn tralala() -> field; } struct Struct1 { @@ -16,13 +16,13 @@ impl Struct1 { } impl Trait1 for Struct1 { - fn tralala() -> Field { + fn tralala() -> field { 111111 } } impl Trait2 for Struct1 { - fn tralala() -> Field { + fn tralala() -> field { 222222 } } diff --git a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr index a8729d8dc40..8dc1491ac31 100644 --- a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr @@ -1,20 +1,20 @@ use dep::std; trait MyDefault { - fn my_default(x: Field, y: Field) -> Self; + fn my_default(x: field, y: field) -> Self; - fn method2(x: Field) -> Field { + fn method2(x: field) -> field { x } } struct Foo { - bar: Field, - array: [Field; 2], + bar: field, + array: [field; 2], } impl MyDefault for Foo { - fn my_default(x: Field,y: Field) -> Self { + fn my_default(x: field,y: field) -> Self { Self { bar: x, array: [x,y] } } } diff --git a/test_programs/compile_success_empty/trait_function_calls/src/main.nr b/test_programs/compile_success_empty/trait_function_calls/src/main.nr index 39d28a5a3b3..ea46cab5bc1 100644 --- a/test_programs/compile_success_empty/trait_function_calls/src/main.nr +++ b/test_programs/compile_success_empty/trait_function_calls/src/main.nr @@ -22,528 +22,528 @@ // 1) trait method -> trait method // 1a) trait default method -> trait default method trait Trait1a { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 7892 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 43278 } } -struct Struct1a { vl: Field } +struct Struct1a { vl: field } impl Trait1a for Struct1a { } // 1b) trait default method -> trait overriden method trait Trait1b { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 2832 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 9323 } } -struct Struct1b { vl: Field } +struct Struct1b { vl: field } impl Trait1b for Struct1b { - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 2394 } } // 1c) trait default method -> trait overriden (no default) method trait Trait1c { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 7635 - self.vl } - fn trait_method2(self) -> Field; + fn trait_method2(self) -> field; } -struct Struct1c { vl: Field } +struct Struct1c { vl: field } impl Trait1c for Struct1c { - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 5485 } } // 1d) trait overriden method -> trait default method trait Trait1d { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 2825 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 29341 } } -struct Struct1d { vl: Field } +struct Struct1d { vl: field } impl Trait1d for Struct1d { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 9342 - self.vl } } // 1e) trait overriden method -> trait overriden method trait Trait1e { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 85465 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 2381 } } -struct Struct1e { vl: Field } +struct Struct1e { vl: field } impl Trait1e for Struct1e { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 47324 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 58945 } } // 1f) trait overriden method -> trait overriden (no default) method trait Trait1f { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 43257 - self.vl } - fn trait_method2(self) -> Field; + fn trait_method2(self) -> field; } -struct Struct1f { vl: Field } +struct Struct1f { vl: field } impl Trait1f for Struct1f { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 34875 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 5748 } } // 1g) trait overriden (no default) method -> trait default method trait Trait1g { - fn trait_method1(self) -> Field; - fn trait_method2(self) -> Field { + fn trait_method1(self) -> field; + fn trait_method2(self) -> field { 37845 } } -struct Struct1g { vl: Field } +struct Struct1g { vl: field } impl Trait1g for Struct1g { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 7854 - self.vl } } // 1h) trait overriden (no default) method -> trait overriden method trait Trait1h { - fn trait_method1(self) -> Field; - fn trait_method2(self) -> Field { + fn trait_method1(self) -> field; + fn trait_method2(self) -> field { 7823 } } -struct Struct1h { vl: Field } +struct Struct1h { vl: field } impl Trait1h for Struct1h { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 3482 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 8542 } } // 1i) trait overriden (no default) method -> trait overriden (no default) method trait Trait1i { - fn trait_method1(self) -> Field; - fn trait_method2(self) -> Field; + fn trait_method1(self) -> field; + fn trait_method2(self) -> field; } -struct Struct1i { vl: Field } +struct Struct1i { vl: field } impl Trait1i for Struct1i { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { self.trait_method2() * 23478 - self.vl } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 98543 } } // 2) trait method -> trait function // 2a) trait default method -> trait default function trait Trait2a { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 2385 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 7843 } } -struct Struct2a { vl: Field } +struct Struct2a { vl: field } impl Trait2a for Struct2a { } // 2b) trait default method -> trait overriden function trait Trait2b { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 6583 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 3752 } } -struct Struct2b { vl: Field } +struct Struct2b { vl: field } impl Trait2b for Struct2b { - fn trait_function2() -> Field { + fn trait_function2() -> field { 8477 } } // 2c) trait default method -> trait overriden (no default) function trait Trait2c { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 2831 - self.vl } - fn trait_function2() -> Field; + fn trait_function2() -> field; } -struct Struct2c { vl: Field } +struct Struct2c { vl: field } impl Trait2c for Struct2c { - fn trait_function2() -> Field { + fn trait_function2() -> field { 8342 } } // 2d) trait overriden method -> trait default function trait Trait2d { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 924 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 384 } } -struct Struct2d { vl: Field } +struct Struct2d { vl: field } impl Trait2d for Struct2d { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 3984 - self.vl } } // 2e) trait overriden method -> trait overriden function trait Trait2e { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 3642 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 97342 } } -struct Struct2e { vl: Field } +struct Struct2e { vl: field } impl Trait2e for Struct2e { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 7363 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 39400 } } // 2f) trait overriden method -> trait overriden (no default) function trait Trait2f { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 2783 - self.vl } - fn trait_function2() -> Field; + fn trait_function2() -> field; } -struct Struct2f { vl: Field } +struct Struct2f { vl: field } impl Trait2f for Struct2f { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 6362 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 72311 } } // 2g) trait overriden (no default) method -> trait default function trait Trait2g { - fn trait_method1(self) -> Field; - fn trait_function2() -> Field { + fn trait_method1(self) -> field; + fn trait_function2() -> field { 19273 } } -struct Struct2g { vl: Field } +struct Struct2g { vl: field } impl Trait2g for Struct2g { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 9123 - self.vl } } // 2h) trait overriden (no default) method -> trait overriden function trait Trait2h { - fn trait_method1(self) -> Field; - fn trait_function2() -> Field { + fn trait_method1(self) -> field; + fn trait_function2() -> field { 1281 } } -struct Struct2h { vl: Field } +struct Struct2h { vl: field } impl Trait2h for Struct2h { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 4833 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 5335 } } // 2i) trait overriden (no default) method -> trait overriden (no default) function trait Trait2i { - fn trait_method1(self) -> Field; - fn trait_function2() -> Field; + fn trait_method1(self) -> field; + fn trait_function2() -> field; } -struct Struct2i { vl: Field } +struct Struct2i { vl: field } impl Trait2i for Struct2i { - fn trait_method1(self) -> Field { + fn trait_method1(self) -> field { Self::trait_function2() * 2291 - self.vl } - fn trait_function2() -> Field { + fn trait_function2() -> field { 3322 } } // 3 trait function -> trait method // 3a) trait default function -> trait default method trait Trait3a { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 8344 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 19212 } } -struct Struct3a { vl: Field } +struct Struct3a { vl: field } impl Trait3a for Struct3a { } // 3b) trait default function -> trait overriden method trait Trait3b { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 9233 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 9111 } } -struct Struct3b { vl: Field } +struct Struct3b { vl: field } impl Trait3b for Struct3b { - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 2392 } } // 3c) trait default function -> trait overriden (no default) method trait Trait3c { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 2822 - b.vl + a } - fn trait_method2(self) -> Field; + fn trait_method2(self) -> field; } -struct Struct3c { vl: Field } +struct Struct3c { vl: field } impl Trait3c for Struct3c { - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 7743 } } // 3d) trait overriden function -> trait default method trait Trait3d { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 291 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 3328 } } -struct Struct3d { vl: Field } +struct Struct3d { vl: field } impl Trait3d for Struct3d { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 4933 - b.vl + a } } // 3e) trait overriden function -> trait overriden method trait Trait3e { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 71231 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 373 } } -struct Struct3e { vl: Field } +struct Struct3e { vl: field } impl Trait3e for Struct3e { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 81232 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 80002 } } // 3f) trait overriden function -> trait overriden (no default) method trait Trait3f { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 28223 - b.vl + a } - fn trait_method2(self) -> Field; + fn trait_method2(self) -> field; } -struct Struct3f { vl: Field } +struct Struct3f { vl: field } impl Trait3f for Struct3f { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 29223 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 63532 } } // 3g) trait overriden (no default) function -> trait default method trait Trait3g { - fn trait_function1(a: Field, b: Self) -> Field; - fn trait_method2(self) -> Field { + fn trait_function1(a: field, b: Self) -> field; + fn trait_method2(self) -> field { 8887 } } -struct Struct3g { vl: Field } +struct Struct3g { vl: field } impl Trait3g for Struct3g { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 31337 - b.vl + a } } // 3h) trait overriden (no default) function -> trait overriden method trait Trait3h { - fn trait_function1(a: Field, b: Self) -> Field; - fn trait_method2(self) -> Field { + fn trait_function1(a: field, b: Self) -> field; + fn trait_method2(self) -> field { 293 } } -struct Struct3h { vl: Field } +struct Struct3h { vl: field } impl Trait3h for Struct3h { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 74747 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 6283 } } // 3i) trait overriden (no default) function -> trait overriden (no default) method trait Trait3i { - fn trait_function1(a: Field, b: Self) -> Field; - fn trait_method2(self) -> Field; + fn trait_function1(a: field, b: Self) -> field; + fn trait_method2(self) -> field; } -struct Struct3i { vl: Field } +struct Struct3i { vl: field } impl Trait3i for Struct3i { - fn trait_function1(a: Field, b: Self) -> Field { + fn trait_function1(a: field, b: Self) -> field { b.trait_method2() * 1237 - b.vl + a } - fn trait_method2(self) -> Field { + fn trait_method2(self) -> field { 84352 } } // 4) trait function -> trait function // 4a) trait default function -> trait default function trait Trait4a { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 3842 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 2932 } } -struct Struct4a { vl: Field } +struct Struct4a { vl: field } impl Trait4a for Struct4a { } // 4b) trait default function -> trait overriden function trait Trait4b { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 3842 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 2932 } } -struct Struct4b { vl: Field } +struct Struct4b { vl: field } impl Trait4b for Struct4b { - fn trait_function2() -> Field { + fn trait_function2() -> field { 9353 } } // 4c) trait default function -> trait overriden (no default) function trait Trait4c { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 7832 } - fn trait_function2() -> Field; + fn trait_function2() -> field; } -struct Struct4c { vl: Field } +struct Struct4c { vl: field } impl Trait4c for Struct4c { - fn trait_function2() -> Field { + fn trait_function2() -> field { 2928 } } // 4d) trait overriden function -> trait default function trait Trait4d { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 2283 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 9332 } } -struct Struct4d { vl: Field } +struct Struct4d { vl: field } impl Trait4d for Struct4d { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 8374 } } // 4e) trait overriden function -> trait overriden function trait Trait4e { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 94329 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 28328 } } -struct Struct4e { vl: Field } +struct Struct4e { vl: field } impl Trait4e for Struct4e { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 12323 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 38434 } } // 4f) trait overriden function -> trait overriden (no default) function trait Trait4f { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 23723 } - fn trait_function2() -> Field; + fn trait_function2() -> field; } -struct Struct4f { vl: Field } +struct Struct4f { vl: field } impl Trait4f for Struct4f { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 21392 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 4394 } } // 4g) trait overriden (no default) function -> trait default function trait Trait4g { - fn trait_function1() -> Field; - fn trait_function2() -> Field { + fn trait_function1() -> field; + fn trait_function2() -> field { 2932 } } -struct Struct4g { vl: Field } +struct Struct4g { vl: field } impl Trait4g for Struct4g { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 3345 } } // 4h) trait overriden (no default) function -> trait overriden function trait Trait4h { - fn trait_function1() -> Field; - fn trait_function2() -> Field { + fn trait_function1() -> field; + fn trait_function2() -> field { 5756 } } -struct Struct4h { vl: Field } +struct Struct4h { vl: field } impl Trait4h for Struct4h { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 6478 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 5435 } } // 4i) trait overriden (no default) function -> trait overriden (no default) function trait Trait4i { - fn trait_function1() -> Field; - fn trait_function2() -> Field; + fn trait_function1() -> field; + fn trait_function2() -> field; } -struct Struct4i { vl: Field } +struct Struct4i { vl: field } impl Trait4i for Struct4i { - fn trait_function1() -> Field { + fn trait_function1() -> field { Self::trait_function2() * 8239 } - fn trait_function2() -> Field { + fn trait_function2() -> field { 2032 } } diff --git a/test_programs/compile_success_empty/trait_generics/src/main.nr b/test_programs/compile_success_empty/trait_generics/src/main.nr index 0709a22d617..bc3c896a5f9 100644 --- a/test_programs/compile_success_empty/trait_generics/src/main.nr +++ b/test_programs/compile_success_empty/trait_generics/src/main.nr @@ -1,5 +1,5 @@ fn main() { - let xs: [Field; 1] = [3]; + let xs: [field; 1] = [3]; let ys: [u32; 1] = [3]; foo(xs, ys); @@ -21,7 +21,7 @@ impl MyInto<[U; N]> for [T; N] where T: MyInto { } } -impl MyInto for Field { +impl MyInto for field { fn into(self) -> u32 { self as u32 } @@ -30,16 +30,16 @@ impl MyInto for Field { /// Serialize example trait Serializable { - fn serialize(self) -> [Field; N]; + fn serialize(self) -> [field; N]; } struct Data { - a: Field, - b: Field, + a: field, + b: field, } impl Serializable<2> for Data { - fn serialize(self) -> [Field; 2] { + fn serialize(self) -> [field; 2] { [self.a, self.b] } } diff --git a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr index 56c059bf71d..b085b2c9a0a 100644 --- a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr @@ -1,47 +1,47 @@ use dep::std; trait MyDefault { - fn my_default(x: Field, y: Field) -> Self; + fn my_default(x: field, y: field) -> Self; - fn method2(x: Field) -> Field { + fn method2(x: field) -> field { x } } struct Foo { - bar: Field, - array: [Field; 2], + bar: field, + array: [field; 2], } impl MyDefault for Foo { - fn my_default(x: Field,y: Field) -> Self { + fn my_default(x: field,y: field) -> Self { Self { bar: x, array: [x,y] } } - fn method2(x: Field) -> Field { + fn method2(x: field) -> field { x * 3 } } trait F { - fn f1(self) -> Field; - fn f2(_self: Self) -> Field { 2 } - fn f3(_self: Self) -> Field { 3 } - fn f4(_self: Self) -> Field { 4 } - fn f5(_self: Self) -> Field { 5 } + fn f1(self) -> field; + fn f2(_self: Self) -> field { 2 } + fn f3(_self: Self) -> field { 3 } + fn f4(_self: Self) -> field { 4 } + fn f5(_self: Self) -> field { 5 } } struct Bar {} impl F for Bar { - fn f5(_self: Self) -> Field { 50 } - fn f1(_self: Self) -> Field { 10 } - fn f3(_self: Self) -> Field { 30 } + fn f5(_self: Self) -> field { 50 } + fn f1(_self: Self) -> field { 10 } + fn f3(_self: Self) -> field { 30 } } // Impls on mutable references are temporarily disabled // impl F for &mut Bar { -// fn f1(self) -> Field { 101 } -// fn f5(self) -> Field { 505 } +// fn f1(self) -> field { 101 } +// fn f5(self) -> field { 505 } // } fn main(x: field) { let first = Foo::method2(x); diff --git a/test_programs/compile_success_empty/trait_static_methods/src/main.nr b/test_programs/compile_success_empty/trait_static_methods/src/main.nr index 838e47ee82e..179f28dfab4 100644 --- a/test_programs/compile_success_empty/trait_static_methods/src/main.nr +++ b/test_programs/compile_success_empty/trait_static_methods/src/main.nr @@ -1,17 +1,17 @@ trait ATrait { fn asd() -> Self; - fn static_method() -> Field { + fn static_method() -> field { Self::static_method_2() } - fn static_method_2() -> Field { + fn static_method_2() -> field { 100 } } struct Foo { - x: Field + x: field } impl ATrait for Foo { fn asd() -> Self { @@ -21,7 +21,7 @@ impl ATrait for Foo { } struct Bar { - x: Field + x: field } impl ATrait for Bar { // The trait method is declared as returning `Self` @@ -30,7 +30,7 @@ impl ATrait for Bar { Bar{x: 100} } - fn static_method_2() -> Field { + fn static_method_2() -> field { 200 } } @@ -40,7 +40,7 @@ fn main() { assert(Bar::static_method() == 200); // Regression for #3773 - let zero: Field = MyDefault::my_default(); + let zero: field = MyDefault::my_default(); assert(zero == 0); } @@ -49,16 +49,16 @@ trait MyDefault { } // This impl is first, so if the type directed search picks the first impl -// instead of the correct Field impl below, we'll get a panic in SSA from +// instead of the correct field impl below, we'll get a panic in SSA from // a type mismatch. -impl MyDefault for (Field, Field) { - fn my_default() -> (Field, Field) { +impl MyDefault for (field, field) { + fn my_default() -> (field, field) { (0, 0) } } -impl MyDefault for Field { - fn my_default() -> Field { +impl MyDefault for field { + fn my_default() -> field { 0 } } diff --git a/test_programs/compile_success_empty/trait_where_clause/src/main.nr b/test_programs/compile_success_empty/trait_where_clause/src/main.nr index 9c483bbf082..7f85ff06087 100644 --- a/test_programs/compile_success_empty/trait_where_clause/src/main.nr +++ b/test_programs/compile_success_empty/trait_where_clause/src/main.nr @@ -7,17 +7,17 @@ mod the_trait; use crate::the_trait::Asd; use crate::the_trait::StaticTrait; -struct Add10 { x: Field, } -struct Add20 { x: Field, } -struct Add30 { x: Field, } -struct AddXY { x: Field, y: Field, } +struct Add10 { x: field, } +struct Add20 { x: field, } +struct Add30 { x: field, } +struct AddXY { x: field, y: field, } -impl Asd for Add10 { fn asd(self) -> Field { self.x + 10 } } -impl Asd for Add20 { fn asd(self) -> Field { self.x + 20 } } -impl Asd for Add30 { fn asd(self) -> Field { self.x + 30 } } +impl Asd for Add10 { fn asd(self) -> field { self.x + 10 } } +impl Asd for Add20 { fn asd(self) -> field { self.x + 20 } } +impl Asd for Add30 { fn asd(self) -> field { self.x + 30 } } impl Asd for AddXY { - fn asd(self) -> Field { + fn asd(self) -> field { self.x + self.y } } @@ -29,7 +29,7 @@ impl StaticTrait for Static100 { struct Static200 {} impl StaticTrait for Static200 { - fn static_function(slf: Self) -> Field { 200 } + fn static_function(slf: Self) -> field { 200 } } fn assert_asd_eq_100(t: T) where T: crate::the_trait::Asd { diff --git a/test_programs/compile_success_empty/trait_where_clause/src/the_trait.nr b/test_programs/compile_success_empty/trait_where_clause/src/the_trait.nr index c5cac4a1186..f61cb431963 100644 --- a/test_programs/compile_success_empty/trait_where_clause/src/the_trait.nr +++ b/test_programs/compile_success_empty/trait_where_clause/src/the_trait.nr @@ -1,9 +1,9 @@ trait Asd { - fn asd(self) -> Field; + fn asd(self) -> field; } trait StaticTrait { - fn static_function(slf: Self) -> Field { + fn static_function(slf: Self) -> field { 100 } } diff --git a/test_programs/compile_success_empty/traits/src/main.nr b/test_programs/compile_success_empty/traits/src/main.nr index 15942057c55..709c6323fd1 100644 --- a/test_programs/compile_success_empty/traits/src/main.nr +++ b/test_programs/compile_success_empty/traits/src/main.nr @@ -1,16 +1,16 @@ use dep::std; trait MyDefault { - fn my_default(x: Field, y: Field) -> Self; + fn my_default(x: field, y: field) -> Self; } struct Foo { - bar: Field, - array: [Field; 2], + bar: field, + array: [field; 2], } impl MyDefault for Foo { - fn my_default(x: Field,y: Field) -> Self { + fn my_default(x: field,y: field) -> Self { Self { bar: x, array: [x,y] } } } diff --git a/test_programs/compile_success_empty/workspace_reexport_bug/library2/src/lib.nr b/test_programs/compile_success_empty/workspace_reexport_bug/library2/src/lib.nr index 7e5a29a1424..4b16803aad3 100644 --- a/test_programs/compile_success_empty/workspace_reexport_bug/library2/src/lib.nr +++ b/test_programs/compile_success_empty/workspace_reexport_bug/library2/src/lib.nr @@ -1,5 +1,5 @@ // When we re-export this type from another library and then use it in // main, we get a panic struct ReExportMeFromAnotherLib { - x : Field, + x : field, } diff --git a/test_programs/execution_failure/assert_msg_runtime/src/main.nr b/test_programs/execution_failure/assert_msg_runtime/src/main.nr index fa21442e816..1d136b274fe 100644 --- a/test_programs/execution_failure/assert_msg_runtime/src/main.nr +++ b/test_programs/execution_failure/assert_msg_runtime/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y, f"Expected x != y, but got both equal {x}"); assert(x != y); let z = x + y; diff --git a/test_programs/execution_failure/brillig_assert_fail/src/main.nr b/test_programs/execution_failure/brillig_assert_fail/src/main.nr index da9d4ec1ac8..f0512f764bb 100644 --- a/test_programs/execution_failure/brillig_assert_fail/src/main.nr +++ b/test_programs/execution_failure/brillig_assert_fail/src/main.nr @@ -1,11 +1,11 @@ // Tests a very simple program. // // The features being tested is using assert on brillig -fn main(x: Field) { +fn main(x: field) { assert(1 == conditional(x as bool)); } -unconstrained fn conditional(x: bool) -> Field { +unconstrained fn conditional(x: bool) -> field { assert(x); 1 } diff --git a/test_programs/execution_failure/brillig_assert_msg_runtime/src/main.nr b/test_programs/execution_failure/brillig_assert_msg_runtime/src/main.nr index bd77551e304..8a2af232e36 100644 --- a/test_programs/execution_failure/brillig_assert_msg_runtime/src/main.nr +++ b/test_programs/execution_failure/brillig_assert_msg_runtime/src/main.nr @@ -1,8 +1,8 @@ -fn main(x: Field) { +fn main(x: field) { assert(1 == conditional(x)); } -unconstrained fn conditional(x: Field) -> Field { +unconstrained fn conditional(x: field) -> field { let z = x as u8 + 20; assert_eq(z, 25, f"Expected 25 but got {z}"); assert(x == 10, f"Expected x to equal 10, but got {x}"); diff --git a/test_programs/execution_failure/div_by_zero_constants/src/main.nr b/test_programs/execution_failure/div_by_zero_constants/src/main.nr index 58adc5444b1..b182d9b660d 100644 --- a/test_programs/execution_failure/div_by_zero_constants/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_constants/src/main.nr @@ -1,6 +1,6 @@ use dep::std; fn main() { - let a: Field = 3 / 0; + let a: field = 3 / 0; std::println(a); } diff --git a/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr b/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr index f51b26d5ba1..8284a405af5 100644 --- a/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr @@ -1,6 +1,6 @@ use dep::std; -fn main(x: Field) { - let a: Field = x / 0; +fn main(x: field) { + let a: field = x / 0; std::println(a); } diff --git a/test_programs/execution_failure/div_by_zero_witness/src/main.nr b/test_programs/execution_failure/div_by_zero_witness/src/main.nr index a814f88f320..001e9ac8df4 100644 --- a/test_programs/execution_failure/div_by_zero_witness/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_witness/src/main.nr @@ -1,6 +1,6 @@ use dep::std; // It is expected that `y` must be equal to 0. -fn main(x: Field, y: pub Field) { - let a: Field = x / y; +fn main(x: field, y: pub field) { + let a: field = x / y; std::println(a); } diff --git a/test_programs/execution_failure/dyn_index_fail_nested_array/src/main.nr b/test_programs/execution_failure/dyn_index_fail_nested_array/src/main.nr index 954d2e77c6e..92112298f21 100644 --- a/test_programs/execution_failure/dyn_index_fail_nested_array/src/main.nr +++ b/test_programs/execution_failure/dyn_index_fail_nested_array/src/main.nr @@ -1,8 +1,8 @@ struct Foo { - a: Field, - b: Field, + a: field, + b: field, } -fn main(mut x: [Foo; 3], y: pub Field) { +fn main(mut x: [Foo; 3], y: pub field) { assert(x[y + 2].a == 5); } diff --git a/test_programs/execution_failure/dynamic_index_failure/src/main.nr b/test_programs/execution_failure/dynamic_index_failure/src/main.nr index 0af5f90eea6..8760f4a82f1 100644 --- a/test_programs/execution_failure/dynamic_index_failure/src/main.nr +++ b/test_programs/execution_failure/dynamic_index_failure/src/main.nr @@ -1,4 +1,4 @@ -fn main(mut x: [u32; 5], z: Field) { +fn main(mut x: [u32; 5], z: field) { let idx = z + 10; x[z] = 4; diff --git a/test_programs/execution_failure/fold_dyn_index_fail/src/main.nr b/test_programs/execution_failure/fold_dyn_index_fail/src/main.nr index b12dea630b0..163d36194e4 100644 --- a/test_programs/execution_failure/fold_dyn_index_fail/src/main.nr +++ b/test_programs/execution_failure/fold_dyn_index_fail/src/main.nr @@ -1,10 +1,10 @@ -fn main(mut x: [u32; 5], z: Field) { +fn main(mut x: [u32; 5], z: field) { x[z] = 4; dynamic_index_check(x, z + 10); } #[fold] -fn dynamic_index_check(x: [u32; 5], idx: Field) { +fn dynamic_index_check(x: [u32; 5], idx: field) { // Dynamic index is greater than length of the array assert(x[idx] != 0); } diff --git a/test_programs/execution_failure/fold_nested_brillig_assert_fail/src/main.nr b/test_programs/execution_failure/fold_nested_brillig_assert_fail/src/main.nr index 0a5038c179b..7d9009306da 100644 --- a/test_programs/execution_failure/fold_nested_brillig_assert_fail/src/main.nr +++ b/test_programs/execution_failure/fold_nested_brillig_assert_fail/src/main.nr @@ -2,25 +2,25 @@ // // The features being tested is using assert on brillig that is triggered through nested ACIR calls. // We want to make sure we get a call stack from the original call in main to the failed assert. -fn main(x: Field) { +fn main(x: field) { assert(1 == fold_conditional_wrapper(x as bool)); } #[fold] -fn fold_conditional_wrapper(x: bool) -> Field { +fn fold_conditional_wrapper(x: bool) -> field { fold_conditional(x) } #[fold] -fn fold_conditional(x: bool) -> Field { +fn fold_conditional(x: bool) -> field { conditional_wrapper(x) } -unconstrained fn conditional_wrapper(x: bool) -> Field { +unconstrained fn conditional_wrapper(x: bool) -> field { conditional(x) } -unconstrained fn conditional(x: bool) -> Field { +unconstrained fn conditional(x: bool) -> field { assert(x); 1 } diff --git a/test_programs/execution_failure/hashmap_load_factor/src/main.nr b/test_programs/execution_failure/hashmap_load_factor/src/main.nr index 907c3628142..569d4128a42 100644 --- a/test_programs/execution_failure/hashmap_load_factor/src/main.nr +++ b/test_programs/execution_failure/hashmap_load_factor/src/main.nr @@ -3,14 +3,14 @@ use dep::std::hash::BuildHasherDefault; use dep::std::hash::poseidon2::Poseidon2Hasher; struct Entry{ - key: Field, - value: Field + key: field, + value: field } global HASHMAP_CAP = 8; global HASHMAP_LEN = 6; -fn allocate_hashmap() -> HashMap> { +fn allocate_hashmap() -> HashMap> { HashMap::default() } diff --git a/test_programs/execution_failure/slice_access_failure/src/main.nr b/test_programs/execution_failure/slice_access_failure/src/main.nr index 6e8b5c7d841..e527e8d42ea 100644 --- a/test_programs/execution_failure/slice_access_failure/src/main.nr +++ b/test_programs/execution_failure/slice_access_failure/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let mut slice = [0; 2]; if x == y { slice = slice.push_back(y); diff --git a/test_programs/execution_failure/slice_insert_failure/src/main.nr b/test_programs/execution_failure/slice_insert_failure/src/main.nr index 38892f01e12..cdd6a2887ff 100644 --- a/test_programs/execution_failure/slice_insert_failure/src/main.nr +++ b/test_programs/execution_failure/slice_insert_failure/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let mut slice = [0; 2]; if x == y { slice = slice.push_back(y); diff --git a/test_programs/execution_failure/slice_remove_failure/src/main.nr b/test_programs/execution_failure/slice_remove_failure/src/main.nr index f9faa25384b..70ff23740b1 100644 --- a/test_programs/execution_failure/slice_remove_failure/src/main.nr +++ b/test_programs/execution_failure/slice_remove_failure/src/main.nr @@ -1,4 +1,4 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let mut slice = [0; 2]; if x == y { slice = slice.push_back(y); diff --git a/test_programs/execution_failure/workspace_fail/crates/a/src/main.nr b/test_programs/execution_failure/workspace_fail/crates/a/src/main.nr index cf72627da2e..0b95af211b2 100644 --- a/test_programs/execution_failure/workspace_fail/crates/a/src/main.nr +++ b/test_programs/execution_failure/workspace_fail/crates/a/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x == y); } diff --git a/test_programs/execution_failure/workspace_fail/crates/b/src/main.nr b/test_programs/execution_failure/workspace_fail/crates/b/src/main.nr index 4e1fd3c9035..43e9fa2196f 100644 --- a/test_programs/execution_failure/workspace_fail/crates/b/src/main.nr +++ b/test_programs/execution_failure/workspace_fail/crates/b/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y); } diff --git a/test_programs/execution_success/1327_concrete_in_generic/src/main.nr b/test_programs/execution_success/1327_concrete_in_generic/src/main.nr index 1c57b872ab1..30bcbe119a2 100644 --- a/test_programs/execution_success/1327_concrete_in_generic/src/main.nr +++ b/test_programs/execution_success/1327_concrete_in_generic/src/main.nr @@ -37,12 +37,12 @@ impl C { } // --- struct MethodInterface { - some_method_on_t_d: fn(T_D)->Field, + some_method_on_t_d: fn(T_D)->field, } // --- // Note struct D { - d: Field, + d: field, } fn d_method(input: D) -> field { diff --git a/test_programs/execution_success/7_function/src/main.nr b/test_programs/execution_success/7_function/src/main.nr index 68a30c938dc..52afab6b6d4 100644 --- a/test_programs/execution_success/7_function/src/main.nr +++ b/test_programs/execution_success/7_function/src/main.nr @@ -32,7 +32,7 @@ fn pow(base: field, exponent: field) -> field { let b = exponent.to_le_bits(32 as u32); for i in 1..33 { r = r*r; - r = (b[32-i] as Field) * (r * base) + (1 - b[32-i] as Field) * r; + r = (b[32-i] as field) * (r * base) + (1 - b[32-i] as field) * r; } r } @@ -127,9 +127,9 @@ fn main(x: u32, y: u32, a: field, arr1: [u32; 9], arr2: [u32; 9]) { } // Issue #628 fn arr_to_field(arr: [u32; 9]) -> [field; 9] { - let mut as_field: [Field; 9] = [0 as field; 9]; + let mut as_field: [field; 9] = [0 as field; 9]; for i in 0..9 { - as_field[i] = arr[i] as Field; + as_field[i] = arr[i] as field; } as_field } diff --git a/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr b/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr index c6bdd3cbb1a..008d193ba85 100644 --- a/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr +++ b/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr @@ -3,8 +3,8 @@ struct Bar { } struct Foo { - a: Field, - b: [Field; 3], + a: field, + b: [field; 3], bar: Bar, } diff --git a/test_programs/execution_success/array_to_slice/src/main.nr b/test_programs/execution_success/array_to_slice/src/main.nr index 0d0f9562d7b..16a44f0cc8d 100644 --- a/test_programs/execution_success/array_to_slice/src/main.nr +++ b/test_programs/execution_success/array_to_slice/src/main.nr @@ -8,15 +8,15 @@ fn as_slice_push(xs: [T; N]) -> [T] { } // Expected that x == 0 and y == 1 -fn main(x: Field, y: pub Field) { - let xs: [Field; 0] = []; - let ys: [Field; 1] = [1]; - let zs: [Field; 2] = [1, 2]; - let ws: [Field; 3] = [1; 3]; - let qs: [Field; 4] = [3, 2, 1, 0]; +fn main(x: field, y: pub field) { + let xs: [field; 0] = []; + let ys: [field; 1] = [1]; + let zs: [field; 2] = [1, 2]; + let ws: [field; 3] = [1; 3]; + let qs: [field; 4] = [3, 2, 1, 0]; - let mut dynamic: [Field; 4] = [3, 2, 1, 0]; - let dynamic_expected: [Field; 4] = [1000, 2, 1, 0]; + let mut dynamic: [field; 4] = [3, 2, 1, 0]; + let dynamic_expected: [field; 4] = [1000, 2, 1, 0]; dynamic[x] = 1000; assert(x != y); @@ -36,7 +36,7 @@ fn main(x: Field, y: pub Field) { regression_4609_append_dynamic_slices(x, y); } -fn regression_4609_append_slices(x: Field, y: Field) { +fn regression_4609_append_slices(x: field, y: field) { let sl = [x, 1, 2, 3].as_slice(); let sl2 = [y, 5, 6].as_slice(); let sl3 = sl.append(sl2); @@ -44,7 +44,7 @@ fn regression_4609_append_slices(x: Field, y: Field) { assert(sl3[4] == y); } -fn regression_4609_append_dynamic_slices(x: Field, y: Field) { +fn regression_4609_append_dynamic_slices(x: field, y: field) { let mut sl = [x, 1, 2, 3].as_slice(); sl[x] = x + 10; let mut sl2 = [y, 5, 6].as_slice(); diff --git a/test_programs/execution_success/array_to_slice_constant_length/src/main.nr b/test_programs/execution_success/array_to_slice_constant_length/src/main.nr index e81dd4a0c5f..a64547b3d0b 100644 --- a/test_programs/execution_success/array_to_slice_constant_length/src/main.nr +++ b/test_programs/execution_success/array_to_slice_constant_length/src/main.nr @@ -1,10 +1,10 @@ // Regression test for https://github.com/noir-lang/noir/issues/4722 -unconstrained fn return_array(val: Field) -> [Field; 1] { +unconstrained fn return_array(val: field) -> [field; 1] { [val; 1] } -fn main(val: Field) { +fn main(val: field) { let array = return_array(val); assert_constant(array.as_slice().len()); } diff --git a/test_programs/execution_success/bigint/src/main.nr b/test_programs/execution_success/bigint/src/main.nr index 5645e4e9e1b..51d354a180a 100644 --- a/test_programs/execution_success/bigint/src/main.nr +++ b/test_programs/execution_success/bigint/src/main.nr @@ -10,8 +10,8 @@ fn main(mut x: [u8; 5], y: [u8; 5]) { a_be_bytes[31-i] = x[i]; b_be_bytes[31-i] = y[i]; } - let a_field = dep::std::field::bytes32_to_field(a_be_bytes); - let b_field = dep::std::field::bytes32_to_field(b_be_bytes); + let a_field = dep::std::field_element::bytes32_to_field(a_be_bytes); + let b_field = dep::std::field_element::bytes32_to_field(b_be_bytes); // Regression for #4682 let c = if x[0] != 0 { diff --git a/test_programs/execution_success/brillig_array_to_slice/src/main.nr b/test_programs/execution_success/brillig_array_to_slice/src/main.nr index 8f7fcf24bae..0ca0694d4e0 100644 --- a/test_programs/execution_success/brillig_array_to_slice/src/main.nr +++ b/test_programs/execution_success/brillig_array_to_slice/src/main.nr @@ -1,5 +1,5 @@ -unconstrained fn brillig_as_slice(x: Field) -> (u64, Field, Field) { - let mut dynamic: [Field; 1] = [1]; +unconstrained fn brillig_as_slice(x: field) -> (u64, field, field) { + let mut dynamic: [field; 1] = [1]; dynamic[x] = 2; assert(dynamic[0] == 2); @@ -9,7 +9,7 @@ unconstrained fn brillig_as_slice(x: Field) -> (u64, Field, Field) { (brillig_slice.len(), dynamic[0], brillig_slice[0]) } -fn main(x: Field) { +fn main(x: field) { let (slice_len, dynamic_0, slice_0) = brillig_as_slice(x); assert(slice_len == 1); assert(dynamic_0 == 2); diff --git a/test_programs/execution_success/brillig_cow/src/main.nr b/test_programs/execution_success/brillig_cow/src/main.nr index 78615cb893b..36941c1b8d0 100644 --- a/test_programs/execution_success/brillig_cow/src/main.nr +++ b/test_programs/execution_success/brillig_cow/src/main.nr @@ -3,9 +3,9 @@ global ARRAY_SIZE = 5; struct ExecutionResult { - original: [Field; ARRAY_SIZE], - modified_once: [Field; ARRAY_SIZE], - modified_twice: [Field; ARRAY_SIZE], + original: [field; ARRAY_SIZE], + modified_once: [field; ARRAY_SIZE], + modified_twice: [field; ARRAY_SIZE], } impl ExecutionResult { diff --git a/test_programs/execution_success/brillig_cow_regression/src/main.nr b/test_programs/execution_success/brillig_cow_regression/src/main.nr index 04cb4765690..58d33c1557f 100644 --- a/test_programs/execution_success/brillig_cow_regression/src/main.nr +++ b/test_programs/execution_success/brillig_cow_regression/src/main.nr @@ -13,14 +13,14 @@ global TX_EFFECT_HASH_LOG_FIELDS = 4; global TX_EFFECT_HASH_FULL_FIELDS = 165; struct PublicDataUpdateRequest { - leaf_slot : Field, - old_value : Field, - new_value : Field + leaf_slot : field, + old_value : field, + new_value : field } struct NewContractData { - contract_address: Field, - portal_contract_address: Field, + contract_address: field, + portal_contract_address: field, } impl NewContractData { @@ -30,12 +30,12 @@ impl NewContractData { } struct DataToHash { - new_note_hashes: [Field; MAX_NEW_NOTE_HASHES_PER_TX], - new_nullifiers: [Field; MAX_NEW_NULLIFIERS_PER_TX], + new_note_hashes: [field; MAX_NEW_NOTE_HASHES_PER_TX], + new_nullifiers: [field; MAX_NEW_NULLIFIERS_PER_TX], public_data_update_requests: [PublicDataUpdateRequest; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], - new_l2_to_l1_msgs: [Field; MAX_NEW_L2_TO_L1_MSGS_PER_TX], - encrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256], - unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256], + new_l2_to_l1_msgs: [field; MAX_NEW_L2_TO_L1_MSGS_PER_TX], + encrypted_logs_hash: [field; NUM_FIELDS_PER_SHA256], + unencrypted_logs_hash: [field; NUM_FIELDS_PER_SHA256], new_contracts: [NewContractData; MAX_NEW_CONTRACTS_PER_TX], } diff --git a/test_programs/execution_success/brillig_identity_function/src/main.nr b/test_programs/execution_success/brillig_identity_function/src/main.nr index 720a5ee62d7..9db5d61d396 100644 --- a/test_programs/execution_success/brillig_identity_function/src/main.nr +++ b/test_programs/execution_success/brillig_identity_function/src/main.nr @@ -1,6 +1,6 @@ struct myStruct { - foo: Field, - foo_arr: [Field; 2], + foo: field, + foo_arr: [field; 2], } // Tests a very simple program. // diff --git a/test_programs/execution_success/brillig_keccak/src/main.nr b/test_programs/execution_success/brillig_keccak/src/main.nr index 0de00faafbd..fde9b9418c4 100644 --- a/test_programs/execution_success/brillig_keccak/src/main.nr +++ b/test_programs/execution_success/brillig_keccak/src/main.nr @@ -3,7 +3,7 @@ use dep::std; // // The features being tested is keccak256 in brillig fn main(x: field, result: [u8; 32]) { - // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field + // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x field // The padding is taken care of by the program let digest = keccak256([x as u8], 1); assert(digest == result); diff --git a/test_programs/execution_success/brillig_nested_arrays/src/main.nr b/test_programs/execution_success/brillig_nested_arrays/src/main.nr index 46f774e9f86..195cb0803a3 100644 --- a/test_programs/execution_success/brillig_nested_arrays/src/main.nr +++ b/test_programs/execution_success/brillig_nested_arrays/src/main.nr @@ -1,10 +1,10 @@ struct Header { - params: [Field; 3], + params: [field; 3], } struct MyNote { - plain: Field, - array: [Field; 2], + plain: field, + array: [field; 2], header: Header, } diff --git a/test_programs/execution_success/brillig_references/src/main.nr b/test_programs/execution_success/brillig_references/src/main.nr index e6b39f2ddcd..147c495e815 100644 --- a/test_programs/execution_success/brillig_references/src/main.nr +++ b/test_programs/execution_success/brillig_references/src/main.nr @@ -16,7 +16,7 @@ unconstrained fn main(mut x: field) { // Test nested struct allocations with a mutable reference to an array. let mut c = C { foo: 0, bar: &mut C2 { array: &mut [1, 2] } }; *c.bar.array = [3, 4]; - let arr: [Field; 2] = *c.bar.array; + let arr: [field; 2] = *c.bar.array; assert(arr[0] == 3); assert(arr[1] == 4); } @@ -25,17 +25,17 @@ unconstrained fn add1(x: &mut field) { *x += 1; } -struct S { y: Field } +struct S { y: field } -struct Nested { y: &mut &mut Field } +struct Nested { y: &mut &mut field } struct C { - foo: Field, + foo: field, bar: &mut C2, } struct C2 { - array: &mut [Field; 2] + array: &mut [field; 2] } impl S { diff --git a/test_programs/execution_success/brillig_scalar_mul/src/main.nr b/test_programs/execution_success/brillig_scalar_mul/src/main.nr index 7245af3f3db..d966b77caca 100644 --- a/test_programs/execution_success/brillig_scalar_mul/src/main.nr +++ b/test_programs/execution_success/brillig_scalar_mul/src/main.nr @@ -9,8 +9,8 @@ unconstrained fn main( b_pub_y: pub field ) { let mut priv_key = a; - let mut pub_x: Field = a_pub_x; - let mut pub_y: Field = a_pub_y; + let mut pub_x: field = a_pub_x; + let mut pub_y: field = a_pub_y; if a != 1 { // Change `a` in Prover.toml to test input `b` priv_key = b; diff --git a/test_programs/execution_success/brillig_sha256/src/main.nr b/test_programs/execution_success/brillig_sha256/src/main.nr index 7bd19c7ff44..bb4d8940788 100644 --- a/test_programs/execution_success/brillig_sha256/src/main.nr +++ b/test_programs/execution_success/brillig_sha256/src/main.nr @@ -7,7 +7,7 @@ fn main(x: field, result: [u8; 32]) { } unconstrained fn sha256(x: field) -> [u8; 32] { - // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field + // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x field // The padding is taken care of by the program std::hash::sha256([x as u8]) } diff --git a/test_programs/execution_success/brillig_slice_input/src/main.nr b/test_programs/execution_success/brillig_slice_input/src/main.nr index 8403cb7d4a0..c6c549a6bfb 100644 --- a/test_programs/execution_success/brillig_slice_input/src/main.nr +++ b/test_programs/execution_success/brillig_slice_input/src/main.nr @@ -1,9 +1,9 @@ struct Point { - x: Field, - y: Field, + x: field, + y: field, } -unconstrained fn sum_slice(slice: [[Point; 2]]) -> Field { +unconstrained fn sum_slice(slice: [[Point; 2]]) -> field { let mut sum = 0; for i in 0..slice.len() { for j in 0..slice[i].len() { diff --git a/test_programs/execution_success/brillig_slices/src/main.nr b/test_programs/execution_success/brillig_slices/src/main.nr index 71cbed7a8da..117cb5de3af 100644 --- a/test_programs/execution_success/brillig_slices/src/main.nr +++ b/test_programs/execution_success/brillig_slices/src/main.nr @@ -1,6 +1,6 @@ use dep::std::slice; unconstrained fn main(x: field, y: field) { - let mut slice: [Field] = &[y, x]; + let mut slice: [field] = &[y, x]; assert(slice.len() == 2); slice = slice.push_back(7); @@ -131,7 +131,7 @@ unconstrained fn merge_slices_mutate_in_loop(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { for i in 0..5 { - slice = slice.push_back(i as Field); + slice = slice.push_back(i as field); } } else { slice = slice.push_back(x); diff --git a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr index a5def2611ba..6b7eebfdab8 100644 --- a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr @@ -2,7 +2,7 @@ use dep::std; unconstrained fn main(x: field, _y: field) { // The result of this byte array will be big-endian - let y: Field = 2040124; + let y: field = 2040124; let be_byte_array = y.to_be_bytes(31); // The result of this byte array will be little-endian let le_byte_array = x.to_le_bytes(31); diff --git a/test_programs/execution_success/debug_logs/src/main.nr b/test_programs/execution_success/debug_logs/src/main.nr index 8afd3a2055e..db3b3c480ff 100644 --- a/test_programs/execution_success/debug_logs/src/main.nr +++ b/test_programs/execution_success/debug_logs/src/main.nr @@ -3,12 +3,12 @@ fn main(x: field, y: pub field) { println(string); // TODO: fmtstr cannot be printed - // let fmt_str: fmtstr<14, (Field, Field)> = f"i: {x}, j: {y}"; + // let fmt_str: fmtstr<14, (field, field)> = f"i: {x}, j: {y}"; // let fmt_fmt_str = f"fmtstr: {fmt_str}, i: {x}"; // println(fmt_fmt_str); // A `fmtstr` lets you easily perform string interpolation. - let fmt_str: fmtstr<14, (Field, Field)> = f"i: {x}, j: {y}"; + let fmt_str: fmtstr<14, (field, field)> = f"i: {x}, j: {y}"; let fmt_str = string_identity(fmt_str); println(fmt_str); @@ -73,7 +73,7 @@ fn main(x: field, y: pub field) { println(closured_lambda); } -fn string_identity(string: fmtstr<14, (Field, Field)>) -> fmtstr<14, (Field, Field)> { +fn string_identity(string: fmtstr<14, (field, field)>) -> fmtstr<14, (field, field)> { string } @@ -81,18 +81,18 @@ fn string_with_generics(string: fmtstr) -> fmtstr { string } -fn string_with_partial_generics(string: fmtstr) -> fmtstr { +fn string_with_partial_generics(string: fmtstr) -> fmtstr { string } struct myStruct { - y: Field, - x: Field, + y: field, + x: field, } struct fooStruct { my_struct: myStruct, - foo: Field, + foo: field, } fn regression_2903() { diff --git a/test_programs/execution_success/double_verify_proof_recursive/src/main.nr b/test_programs/execution_success/double_verify_proof_recursive/src/main.nr index 86b4971c3a6..8c9e37dd7b5 100644 --- a/test_programs/execution_success/double_verify_proof_recursive/src/main.nr +++ b/test_programs/execution_success/double_verify_proof_recursive/src/main.nr @@ -3,16 +3,16 @@ use dep::std; // This circuit aggregates two proofs from `assert_statement_recursive`. #[recursive] fn main( - verification_key: [Field; 114], + verification_key: [field; 114], // This is the proof without public inputs attached. // // This means: the size of this does not change with the number of public inputs. - proof: [Field; 93], - public_inputs: pub [Field; 1], + proof: [field; 93], + public_inputs: pub [field; 1], // This is currently not public. It is fine given that the vk is a part of the circuit definition. // I believe we want to eventually make it public too though. - key_hash: Field, - proof_b: [Field; 93] + key_hash: field, + proof_b: [field; 93] ) { std::verify_proof( verification_key.as_slice(), diff --git a/test_programs/execution_success/eddsa/src/main.nr b/test_programs/execution_success/eddsa/src/main.nr index ebb7fc3f142..1482e0234bd 100644 --- a/test_programs/execution_success/eddsa/src/main.nr +++ b/test_programs/execution_success/eddsa/src/main.nr @@ -25,14 +25,14 @@ fn main(msg: pub field, _priv_key_a: field, _priv_key_b: field) { let r8_a = bjj.curve.mul(r_a, bjj.base8); let r8_b = bjj.curve.mul(r_b, bjj.base8); - // let h_a: [Field; 6] = hash::poseidon::bn254::hash_5([ + // let h_a: [field; 6] = hash::poseidon::bn254::hash_5([ // r8_a.x, // r8_a.y, // pub_key_a.x, // pub_key_a.y, // msg, // ]); - // let h_b: [Field; 6] = hash::poseidon::bn254::hash_5([ + // let h_b: [field; 6] = hash::poseidon::bn254::hash_5([ // r8_b.x, // r8_b.y, // pub_key_b.x, diff --git a/test_programs/execution_success/fold_basic/src/main.nr b/test_programs/execution_success/fold_basic/src/main.nr index 6c17120660b..f2979dcdbd7 100644 --- a/test_programs/execution_success/fold_basic/src/main.nr +++ b/test_programs/execution_success/fold_basic/src/main.nr @@ -1,11 +1,11 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let z = foo(x, y); let z2 = foo(x, y); assert(z == z2); } #[fold] -fn foo(x: Field, y: Field) -> Field { +fn foo(x: field, y: field) -> field { assert(x != y); x } diff --git a/test_programs/execution_success/fold_basic_nested_call/src/main.nr b/test_programs/execution_success/fold_basic_nested_call/src/main.nr index 6d02b734727..56151021417 100644 --- a/test_programs/execution_success/fold_basic_nested_call/src/main.nr +++ b/test_programs/execution_success/fold_basic_nested_call/src/main.nr @@ -1,16 +1,16 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { let z = func_with_nested_foo_call(x, y); let z2 = func_with_nested_foo_call(x, y); assert(z == z2); } #[fold] -fn func_with_nested_foo_call(x: Field, y: Field) -> Field { +fn func_with_nested_foo_call(x: field, y: field) -> field { foo(x + 2, y) } #[fold] -fn foo(x: Field, y: Field) -> Field { +fn foo(x: field, y: field) -> field { assert(x != y); x } diff --git a/test_programs/execution_success/fold_call_witness_condition/src/main.nr b/test_programs/execution_success/fold_call_witness_condition/src/main.nr index 5dc75e4a99f..a146a590701 100644 --- a/test_programs/execution_success/fold_call_witness_condition/src/main.nr +++ b/test_programs/execution_success/fold_call_witness_condition/src/main.nr @@ -1,5 +1,5 @@ global NUM_RESULTS = 2; -fn main(x: Field, y: pub Field, enable: bool) -> pub [Field; NUM_RESULTS] { +fn main(x: field, y: pub field, enable: bool) -> pub [field; NUM_RESULTS] { let mut result = [0; NUM_RESULTS]; for i in 0..NUM_RESULTS { if enable { @@ -10,7 +10,7 @@ fn main(x: Field, y: pub Field, enable: bool) -> pub [Field; NUM_RESULTS] { } #[fold] -fn return_value(x: Field, y: Field) -> Field { +fn return_value(x: field, y: field) -> field { assert(x != y); x } diff --git a/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr b/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr index f9f3e75789b..1ce6de620e4 100644 --- a/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr +++ b/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr @@ -4,14 +4,14 @@ global NUM_HASHES = 2; global HASH_LENGTH = 10; #[fold] -pub fn poseidon_hash(inputs: [Field; N]) -> Field { +pub fn poseidon_hash(inputs: [field; N]) -> field { Poseidon2::hash(inputs, inputs.len()) } fn main( - to_hash: [[Field; HASH_LENGTH]; NUM_HASHES], + to_hash: [[field; HASH_LENGTH]; NUM_HASHES], enable: [bool; NUM_HASHES] -) -> pub [Field; NUM_HASHES + 1] { +) -> pub [field; NUM_HASHES + 1] { let mut result = [0; NUM_HASHES + 1]; for i in 0..NUM_HASHES { let enable = enable[i]; diff --git a/test_programs/execution_success/generics/src/main.nr b/test_programs/execution_success/generics/src/main.nr index b0ef17ab4e3..5736a62a09b 100644 --- a/test_programs/execution_success/generics/src/main.nr +++ b/test_programs/execution_success/generics/src/main.nr @@ -1,6 +1,6 @@ struct Bar { - one: Field, - two: Field, + one: field, + two: field, other: T, } @@ -25,14 +25,14 @@ impl BigInt { } } -impl Bar { +impl Bar { fn get_other(self) -> field { self.other } } fn main(x: field, y: field) { - let bar1: Bar = Bar { one: x, two: y, other: 0 }; + let bar1: Bar = Bar { one: x, two: y, other: 0 }; let bar2 = Bar { one: x, two: y, other: [0] }; foo(bar1); @@ -42,13 +42,13 @@ fn main(x: field, y: field) { let int2 = BigInt { limbs: [2] }; let BigInt { limbs } = int1.second(int2).first(int1); assert(limbs == int2.limbs); - // Test impl exclusively for Bar + // Test impl exclusively for Bar assert(bar1.get_other() == bar1.other); // Expected type error // assert(bar2.get_other() == bar2.other); let one = x; let two = y; - let nested_generics: Bar> = Bar { one, two, other: Bar { one, two, other: 0 } }; + let nested_generics: Bar> = Bar { one, two, other: Bar { one, two, other: 0 } }; assert(nested_generics.other.other == bar1.get_other()); let _ = regression_2055([1, 2, 3]); @@ -60,7 +60,7 @@ fn regression_2055(bytes: [u8; LEN]) -> field { let mut len = LEN - 1; // FAILS for i in 0..LEN { let j = len - i; - f += (bytes[j] as Field) * b; + f += (bytes[j] as field) * b; b *= 256; } f diff --git a/test_programs/execution_success/global_consts/src/main.nr b/test_programs/execution_success/global_consts/src/main.nr index b3770a55b04..fc7e36821e0 100644 --- a/test_programs/execution_success/global_consts/src/main.nr +++ b/test_programs/execution_success/global_consts/src/main.nr @@ -1,8 +1,8 @@ mod foo; mod baz; -global M: Field = 32; -global L: Field = 10; // Unused globals currently allowed +global M: field = 32; +global L: field = 10; // Unused globals currently allowed global N: u64 = 5; global T_LEN = 2; // Type inference is allowed on globals @@ -10,12 +10,12 @@ global T_LEN = 2; // Type inference is allowed on globals global DERIVED = M + L; struct Dummy { - x: [Field; N], - y: [Field; foo::MAGIC_NUMBER] + x: [field; N], + y: [field; foo::MAGIC_NUMBER] } struct Test { - v: Field, + v: field, } global VALS: [Test; 1] = [Test { v: 100 }]; global NESTED = [VALS, VALS]; @@ -25,7 +25,7 @@ unconstrained fn calculate_global_value() -> field { } // Regression test for https://github.com/noir-lang/noir/issues/4318 -global CALCULATED_GLOBAL: Field = calculate_global_value(); +global CALCULATED_GLOBAL: field = calculate_global_value(); fn main( a: [field; M + N - N], @@ -49,7 +49,7 @@ fn main( let mut y = 5; let mut x = M; for i in 0..N * N { - let M: Field = 10; + let M: field = 10; x = M; y = i; @@ -62,7 +62,7 @@ fn main( arrays_neq(a, b); - let t: [Field; T_LEN] = [N as field, M]; + let t: [field; T_LEN] = [N as field, M]; assert(t[1] == 32); assert(15 == my_submodule::my_helper()); @@ -75,7 +75,7 @@ fn main( let sugared = [0; my_submodule::N + 2]; assert(sugared[my_submodule::N + 1] == 0); - let arr: [Field; my_submodule::N] = [N as field; 10]; + let arr: [field; my_submodule::N] = [N as field; 10]; assert((arr[0] == 5) & (arr[9] == 5)); foo::from_foo(d); @@ -94,28 +94,28 @@ fn arrays_neq(a: [field; M], b: [field; M]) { } mod my_submodule { - global N: Field = 10; - global L: Field = 50; + global N: field = 10; + global L: field = 50; fn my_bool_or(x: u1, y: u1) { assert(x | y == 1); } pub fn my_helper() -> field { - let N: Field = 15; // Like in Rust, local variables override globals + let N: field = 15; // Like in Rust, local variables override globals let x = N; x } } struct Foo { - a: Field, + a: field, } struct Bar {} impl Bar { - fn get_a() -> Field { + fn get_a() -> field { 1 } } diff --git a/test_programs/execution_success/hashmap/src/main.nr b/test_programs/execution_success/hashmap/src/main.nr index 76daa594a89..2551281beaf 100644 --- a/test_programs/execution_success/hashmap/src/main.nr +++ b/test_programs/execution_success/hashmap/src/main.nr @@ -7,19 +7,19 @@ use dep::std::cmp::Eq; use utils::cut; -type K = Field; -type V = Field; +type K = field; +type V = field; // It is more convenient and readable to use structs as input. struct Entry{ - key: Field, - value: Field + key: field, + value: field } global HASHMAP_CAP = 8; global HASHMAP_LEN = 6; -global FIELD_CMP = |a: Field, b: Field| a.lt(b); +global FIELD_CMP = |a: field, b: field| a.lt(b); global K_CMP = FIELD_CMP; global V_CMP = FIELD_CMP; @@ -211,7 +211,7 @@ fn doc_tests() { // docs:end:with_hasher_example // docs:start:insert_example - let mut map: HashMap> = HashMap::default(); + let mut map: HashMap> = HashMap::default(); map.insert(12, 42); assert(map.len() == 1); // docs:end:insert_example @@ -255,7 +255,7 @@ fn doc_tests() { // docs:end:len_example // docs:start:capacity_example - let empty_map: HashMap> = HashMap::default(); + let empty_map: HashMap> = HashMap::default(); assert(empty_map.len() == 0); assert(empty_map.capacity() == 42); // docs:end:capacity_example @@ -283,8 +283,8 @@ fn doc_tests() { // docs:end:retain_example // docs:start:eq_example - let mut map1: HashMap> = HashMap::default(); - let mut map2: HashMap> = HashMap::default(); + let mut map1: HashMap> = HashMap::default(); + let mut map2: HashMap> = HashMap::default(); map1.insert(1, 2); map1.insert(3, 4); @@ -297,7 +297,7 @@ fn doc_tests() { } // docs:start:get_example -fn get_example(map: HashMap>) { +fn get_example(map: HashMap>) { let x = map.get(12); if x.is_some() { @@ -306,7 +306,7 @@ fn get_example(map: HashMap } // docs:end:get_example -fn entries_examples(map: HashMap>) { +fn entries_examples(map: HashMap>) { // docs:start:entries_example let entries = map.entries(); @@ -344,7 +344,7 @@ fn entries_examples(map: HashMap>) { +fn iter_examples(mut map: HashMap>) { // docs:start:iter_mut_example // Add 1 to each key in the map, and double the value associated with that key. map.iter_mut(|k, v| (k + 1, v * 2)); diff --git a/test_programs/execution_success/integer_array_indexing/src/main.nr b/test_programs/execution_success/integer_array_indexing/src/main.nr index 6a051bb639a..27581813da1 100644 --- a/test_programs/execution_success/integer_array_indexing/src/main.nr +++ b/test_programs/execution_success/integer_array_indexing/src/main.nr @@ -4,7 +4,7 @@ fn main(arr: [field; ARRAY_LEN], x: u32) -> pub field { let mut value = arr[ARRAY_LEN - 1]; value += arr[0 as u32]; - value += arr[1 as Field]; + value += arr[1 as field]; value + x as field } diff --git a/test_programs/execution_success/keccak256/src/main.nr b/test_programs/execution_success/keccak256/src/main.nr index d6694891896..4cda3cf542c 100644 --- a/test_programs/execution_success/keccak256/src/main.nr +++ b/test_programs/execution_success/keccak256/src/main.nr @@ -2,7 +2,7 @@ use dep::std; fn main(x: field, result: [u8; 32]) { - // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field + // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x field // The padding is taken care of by the program let digest = std::hash::keccak256([x as u8], 1); assert(digest == result); diff --git a/test_programs/execution_success/nested_array_dynamic/src/main.nr b/test_programs/execution_success/nested_array_dynamic/src/main.nr index ea09cb7c7f8..e050bc1fb08 100644 --- a/test_programs/execution_success/nested_array_dynamic/src/main.nr +++ b/test_programs/execution_success/nested_array_dynamic/src/main.nr @@ -1,15 +1,15 @@ struct Bar { - inner: [Field; 3], + inner: [field; 3], } struct Foo { - a: Field, - b: [Field; 3], + a: field, + b: [field; 3], bar: Bar, } struct FooParent { - array: [Field; 3], + array: [field; 3], foos: [Foo; 4], } diff --git a/test_programs/execution_success/nested_array_in_slice/src/main.nr b/test_programs/execution_success/nested_array_in_slice/src/main.nr index 0594fa77a78..44889caed88 100644 --- a/test_programs/execution_success/nested_array_in_slice/src/main.nr +++ b/test_programs/execution_success/nested_array_in_slice/src/main.nr @@ -1,10 +1,10 @@ struct Bar { - inner: [Field; 3], + inner: [field; 3], } struct Foo { - a: Field, - b: [Field; 3], + a: field, + b: [field; 3], bar: Bar, } diff --git a/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr b/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr index 27e9b892d69..a2a1e7dae98 100644 --- a/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr +++ b/test_programs/execution_success/nested_arrays_from_brillig/src/main.nr @@ -1,10 +1,10 @@ struct Header { - params: [Field; 3], + params: [field; 3], } struct MyNote { - plain: Field, - array: [Field; 2], + plain: field, + array: [field; 2], header: Header, } diff --git a/test_programs/execution_success/prelude/src/main.nr b/test_programs/execution_success/prelude/src/main.nr index 226341f1e7b..cc924775eab 100644 --- a/test_programs/execution_success/prelude/src/main.nr +++ b/test_programs/execution_success/prelude/src/main.nr @@ -1,6 +1,6 @@ fn main() { - let _xs: Vec = Vec::new(); - let _option: Option = Option::none(); + let _xs: Vec = Vec::new(); + let _option: Option = Option::none(); print("42\n"); println("42"); diff --git a/test_programs/execution_success/references/src/main.nr b/test_programs/execution_success/references/src/main.nr index e9a3407738f..88768090fd7 100644 --- a/test_programs/execution_success/references/src/main.nr +++ b/test_programs/execution_success/references/src/main.nr @@ -40,17 +40,17 @@ fn add1(x: &mut field) { *x += 1; } -struct S { y: Field } +struct S { y: field } -struct Nested { y: &mut &mut Field } +struct Nested { y: &mut &mut field } struct C { - foo: Field, + foo: field, bar: &mut C2, } struct C2 { - array: &mut [Field; 2] + array: &mut [field; 2] } impl S { @@ -75,7 +75,7 @@ fn regression_1887() { } struct Foo { bar: Bar } -struct Bar { x: Field } +struct Bar { x: field } impl Bar { fn mutate(&mut self) { diff --git a/test_programs/execution_success/regression_3889/src/main.nr b/test_programs/execution_success/regression_3889/src/main.nr index 730c811c03a..69dacef57c2 100644 --- a/test_programs/execution_success/regression_3889/src/main.nr +++ b/test_programs/execution_success/regression_3889/src/main.nr @@ -1,6 +1,6 @@ mod Foo { struct NewType{ - a: Field, + a: field, } } @@ -11,7 +11,7 @@ mod Bar { mod Baz { struct Works { - a: Field, + a: field, } use crate::Bar::BarStruct; use crate::Bar::NewType; diff --git a/test_programs/execution_success/regression_4088/src/main.nr b/test_programs/execution_success/regression_4088/src/main.nr index b17373c0d34..6b8fcdef10c 100644 --- a/test_programs/execution_success/regression_4088/src/main.nr +++ b/test_programs/execution_success/regression_4088/src/main.nr @@ -1,13 +1,13 @@ trait Serialize { - fn serialize(self) -> [Field; N]; + fn serialize(self) -> [field; N]; } struct ValueNote { - value: Field, + value: field, } impl Serialize<1> for ValueNote { - fn serialize(self) -> [Field; 1] { + fn serialize(self) -> [field; 1] { [self.value] } } diff --git a/test_programs/execution_success/regression_4124/src/main.nr b/test_programs/execution_success/regression_4124/src/main.nr index 547a6febf8e..56f1a828f99 100644 --- a/test_programs/execution_success/regression_4124/src/main.nr +++ b/test_programs/execution_success/regression_4124/src/main.nr @@ -1,11 +1,11 @@ use dep::std::option::Option; trait MyDeserialize { - fn deserialize(fields: [Field; N]) -> Self; + fn deserialize(fields: [field; N]) -> Self; } -impl MyDeserialize<1> for Field { - fn deserialize(fields: [Field; 1]) -> Self { +impl MyDeserialize<1> for field { + fn deserialize(fields: [field; 1]) -> Self { fields[0] } } @@ -15,7 +15,7 @@ pub fn storage_read() -> [field; N] { } struct PublicMutable { - storage_slot: Field, + storage_slot: field, } impl PublicMutable { @@ -26,13 +26,13 @@ impl PublicMutable { pub fn read(_self: Self) -> T where T: MyDeserialize { // storage_read returns slice here - let fields: [Field; T_SERIALIZED_LEN] = storage_read(); + let fields: [field; T_SERIALIZED_LEN] = storage_read(); T::deserialize(fields) } } fn main(value: field) { - let ps: PublicMutable = PublicMutable::new(27); + let ps: PublicMutable = PublicMutable::new(27); // error here assert(ps.read() == value); diff --git a/test_programs/execution_success/regression_4436/src/main.nr b/test_programs/execution_success/regression_4436/src/main.nr index 834ea3250cc..e763bc50ca5 100644 --- a/test_programs/execution_success/regression_4436/src/main.nr +++ b/test_programs/execution_success/regression_4436/src/main.nr @@ -1,10 +1,10 @@ trait LibTrait { fn broadcast(); - fn get_constant() -> Field; + fn get_constant() -> field; } -global STRUCT_A_LEN: Field = 3; -global STRUCT_B_LEN: Field = 5; +global STRUCT_A_LEN: field = 3; +global STRUCT_B_LEN: field = 5; struct StructA; struct StructB; @@ -14,7 +14,7 @@ impl LibTrait for StructA { Self::get_constant(); } - fn get_constant() -> Field { + fn get_constant() -> field { 1 } } @@ -23,7 +23,7 @@ impl LibTrait for StructB { Self::get_constant(); } - fn get_constant() -> Field { + fn get_constant() -> field { 1 } } diff --git a/test_programs/execution_success/regression_capacity_tracker/src/main.nr b/test_programs/execution_success/regression_capacity_tracker/src/main.nr index be645c811d2..3dad248591c 100644 --- a/test_programs/execution_success/regression_capacity_tracker/src/main.nr +++ b/test_programs/execution_success/regression_capacity_tracker/src/main.nr @@ -2,7 +2,7 @@ // for context. // We were not accurately accounting for situations where the slice capacity tracker // was expecting a capacity from slice intrinsic results. -fn main(expected: pub Field, first: Field, input: [Field; 20]) { +fn main(expected: pub field, first: field, input: [field; 20]) { let mut hasher_slice = input.as_slice(); hasher_slice = hasher_slice.push_front(first); assert(hasher_slice[0] == expected); diff --git a/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr b/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr index 1a6931a6870..09b08cdab27 100644 --- a/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr +++ b/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr @@ -1,6 +1,6 @@ use dep::std; struct Item { - id: Field, + id: field, } impl Item { diff --git a/test_programs/execution_success/scalar_mul/src/main.nr b/test_programs/execution_success/scalar_mul/src/main.nr index 3a4256c013c..6c36077a0ea 100644 --- a/test_programs/execution_success/scalar_mul/src/main.nr +++ b/test_programs/execution_success/scalar_mul/src/main.nr @@ -9,8 +9,8 @@ fn main( b_pub_y: pub field ) { let mut priv_key = a; - let mut pub_x: Field = a_pub_x; - let mut pub_y: Field = a_pub_y; + let mut pub_x: field = a_pub_x; + let mut pub_y: field = a_pub_y; if a != 1 { // Change `a` in Prover.toml to test input `b` priv_key = b; diff --git a/test_programs/execution_success/sha256/src/main.nr b/test_programs/execution_success/sha256/src/main.nr index 641972838fc..ed08a00e92a 100644 --- a/test_programs/execution_success/sha256/src/main.nr +++ b/test_programs/execution_success/sha256/src/main.nr @@ -12,7 +12,7 @@ use dep::std; fn main(x: field, result: [u8; 32]) { - // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field + // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x field // The padding is taken care of by the program let digest = std::hash::sha256([x as u8]); assert(digest == result); diff --git a/test_programs/execution_success/side_effects_constrain_array/src/main.nr b/test_programs/execution_success/side_effects_constrain_array/src/main.nr index c4a62603bc3..cea7562422e 100644 --- a/test_programs/execution_success/side_effects_constrain_array/src/main.nr +++ b/test_programs/execution_success/side_effects_constrain_array/src/main.nr @@ -1,5 +1,5 @@ struct Bar { - inner: [Field; 3], + inner: [field; 3], } fn main(y: pub u32) { diff --git a/test_programs/execution_success/simple_2d_array/src/main.nr b/test_programs/execution_success/simple_2d_array/src/main.nr index adc4623da36..5a30abce2ed 100644 --- a/test_programs/execution_success/simple_2d_array/src/main.nr +++ b/test_programs/execution_success/simple_2d_array/src/main.nr @@ -3,6 +3,6 @@ fn main(x: field, y: field, array_input: [[field; 2]; 2]) { assert(array_input[0][0] == x); assert(array_input[0][1] == y); - let arr: [[Field; 2]; 1] = [[3, 3]]; + let arr: [[field; 2]; 1] = [[3, 3]]; assert_eq(arr[0], array_input[1]); } diff --git a/test_programs/execution_success/slice_coercion/src/main.nr b/test_programs/execution_success/slice_coercion/src/main.nr index a3785e79afa..2de928b3a5c 100644 --- a/test_programs/execution_success/slice_coercion/src/main.nr +++ b/test_programs/execution_success/slice_coercion/src/main.nr @@ -1,5 +1,5 @@ struct Hasher { - fields: [Field], + fields: [field], } impl Hasher { @@ -7,12 +7,12 @@ impl Hasher { Self { fields: [] } } - pub fn add(&mut self, field: Field) { + pub fn add(&mut self, field: field) { self.fields = self.fields.push_back(field); } } -fn main(expected: pub Field, first: Field) { +fn main(expected: pub field, first: field) { let mut hasher = Hasher::new(); hasher.add(first); assert(hasher.fields[0] == expected); diff --git a/test_programs/execution_success/slice_dynamic_index/src/main.nr b/test_programs/execution_success/slice_dynamic_index/src/main.nr index 771efd80ff6..3b36480581e 100644 --- a/test_programs/execution_success/slice_dynamic_index/src/main.nr +++ b/test_programs/execution_success/slice_dynamic_index/src/main.nr @@ -6,7 +6,7 @@ fn main(x: field) { fn regression_dynamic_slice_index(x: field, y: field) { let mut slice = &[]; for i in 0..5 { - slice = slice.push_back(i as Field); + slice = slice.push_back(i as field); } assert(slice.len() == 5); diff --git a/test_programs/execution_success/slice_loop/src/main.nr b/test_programs/execution_success/slice_loop/src/main.nr index 4ff3e865b1f..bcbb97569fe 100644 --- a/test_programs/execution_success/slice_loop/src/main.nr +++ b/test_programs/execution_success/slice_loop/src/main.nr @@ -1,15 +1,15 @@ struct Point { - x: Field, - y: Field, + x: field, + y: field, } impl Point { - fn serialize(self) -> [Field; 2] { + fn serialize(self) -> [field; 2] { [self.x, self.y] } } -fn sum(values: [Field]) -> Field { +fn sum(values: [field]) -> field { let mut sum = 0; for value in values { sum = sum + value; diff --git a/test_programs/execution_success/slices/src/main.nr b/test_programs/execution_success/slices/src/main.nr index 5708f231840..97f757bdf3e 100644 --- a/test_programs/execution_success/slices/src/main.nr +++ b/test_programs/execution_success/slices/src/main.nr @@ -176,7 +176,7 @@ fn merge_slices_mutate_in_loop(x: field, y: field) -> [field] { let mut slice = [0; 2]; if x != y { for i in 0..5 { - slice = slice.push_back(i as Field); + slice = slice.push_back(i as field); } } else { slice = slice.push_back(x); @@ -332,6 +332,6 @@ fn regression_slice_call_result(x: field, y: field) { } fn regression_4506() { - let slice: [Field] = &[1, 2, 3]; + let slice: [field] = &[1, 2, 3]; assert(slice == slice); } diff --git a/test_programs/execution_success/strings/src/main.nr b/test_programs/execution_success/strings/src/main.nr index d25c0fb4166..61ac17cc050 100644 --- a/test_programs/execution_success/strings/src/main.nr +++ b/test_programs/execution_success/strings/src/main.nr @@ -32,7 +32,7 @@ fn main(message: pub str<11>, y: field, hex_as_string: str<4>, hex_as_field: fie std::print(hash); assert(hex_as_string == "0x41"); - // assert(hex_as_string != 0x41); This will fail with a type mismatch between str[4] and Field + // assert(hex_as_string != 0x41); This will fail with a type mismatch between str[4] and field assert(hex_as_field == 0x41); // Single digit & odd length hex literals are valid @@ -79,7 +79,7 @@ fn test_failed_constraint() { } struct Test { - a: Field, - b: Field, - c: [Field; 2], + a: field, + b: field, + c: [field; 2], } diff --git a/test_programs/execution_success/struct/src/main.nr b/test_programs/execution_success/struct/src/main.nr index d59a3be7ec4..bc3e9b0360f 100644 --- a/test_programs/execution_success/struct/src/main.nr +++ b/test_programs/execution_success/struct/src/main.nr @@ -1,11 +1,11 @@ struct Foo { - bar: Field, - array: [Field; 2], + bar: field, + array: [field; 2], } struct Pair { first: Foo, - second: Field, + second: field, } impl Foo { @@ -25,8 +25,8 @@ impl Pair { } struct Nested { - a: Field, - b: Field + a: field, + b: field } struct MyStruct { my_bool: bool, @@ -39,7 +39,7 @@ fn test_struct_in_tuple(a_bool: bool, x: field, y: field) -> (MyStruct, bool) { } struct Animal { - legs: Field, + legs: field, eyes: u8, } diff --git a/test_programs/execution_success/struct_array_inputs/src/main.nr b/test_programs/execution_success/struct_array_inputs/src/main.nr index 85dc59d8f0b..0d8c0363f9e 100644 --- a/test_programs/execution_success/struct_array_inputs/src/main.nr +++ b/test_programs/execution_success/struct_array_inputs/src/main.nr @@ -1,6 +1,6 @@ struct Foo { - bar: Field, - baz: Field, + bar: field, + baz: field, } fn main(foos: [Foo; 3]) -> pub field { diff --git a/test_programs/execution_success/struct_fields_ordering/src/main.nr b/test_programs/execution_success/struct_fields_ordering/src/main.nr index 1a2e2d462e2..45e7232c351 100644 --- a/test_programs/execution_success/struct_fields_ordering/src/main.nr +++ b/test_programs/execution_success/struct_fields_ordering/src/main.nr @@ -2,7 +2,7 @@ // We want to check that this ordering is maintained struct myStruct { foo: u32, - bar: Field, + bar: field, } fn main(y: pub myStruct) { diff --git a/test_programs/execution_success/struct_inputs/src/foo.nr b/test_programs/execution_success/struct_inputs/src/foo.nr index ea3a6bbe25f..7fd6aa4de5b 100644 --- a/test_programs/execution_success/struct_inputs/src/foo.nr +++ b/test_programs/execution_success/struct_inputs/src/foo.nr @@ -2,5 +2,5 @@ mod bar; struct fooStruct { bar_struct: bar::barStruct, - baz: Field, + baz: field, } diff --git a/test_programs/execution_success/struct_inputs/src/foo/bar.nr b/test_programs/execution_success/struct_inputs/src/foo/bar.nr index 6d879326677..adc94946443 100644 --- a/test_programs/execution_success/struct_inputs/src/foo/bar.nr +++ b/test_programs/execution_success/struct_inputs/src/foo/bar.nr @@ -1,7 +1,7 @@ global N = 2; struct barStruct { - val: Field, - array: [Field; 2], + val: field, + array: [field; 2], message: str<5>, } diff --git a/test_programs/execution_success/struct_inputs/src/main.nr b/test_programs/execution_success/struct_inputs/src/main.nr index d67d96df057..66ef166fc65 100644 --- a/test_programs/execution_success/struct_inputs/src/main.nr +++ b/test_programs/execution_success/struct_inputs/src/main.nr @@ -2,7 +2,7 @@ mod foo; struct myStruct { foo: u32, - bar: Field, + bar: field, message: str<5>, } diff --git a/test_programs/execution_success/to_bytes_integration/src/main.nr b/test_programs/execution_success/to_bytes_integration/src/main.nr index b16fb4782e5..ecb8ca4e871 100644 --- a/test_programs/execution_success/to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/to_bytes_integration/src/main.nr @@ -1,7 +1,7 @@ use dep::std; fn main(x: field, a: field) { - let y: Field = 2040124; + let y: field = 2040124; let be_byte_array = y.to_be_bytes(31); let le_byte_array = x.to_le_bytes(31); diff --git a/test_programs/execution_success/trait_as_return_type/src/main.nr b/test_programs/execution_success/trait_as_return_type/src/main.nr index 1b2738c2f77..2b53afaa583 100644 --- a/test_programs/execution_success/trait_as_return_type/src/main.nr +++ b/test_programs/execution_success/trait_as_return_type/src/main.nr @@ -1,27 +1,27 @@ trait SomeTrait { - fn magic_number(self) -> Field; + fn magic_number(self) -> field; } struct A {} struct B {} struct C { - x: Field + x: field } impl SomeTrait for A { - fn magic_number(self) -> Field { + fn magic_number(self) -> field { 2 } } impl SomeTrait for B { - fn magic_number(self) -> Field { + fn magic_number(self) -> field { 4 } } impl SomeTrait for C { - fn magic_number(self) -> Field { + fn magic_number(self) -> field { self.x } } diff --git a/test_programs/execution_success/trait_impl_base_type/src/main.nr b/test_programs/execution_success/trait_impl_base_type/src/main.nr index 9fc519cc0ac..80dd3a08f1b 100644 --- a/test_programs/execution_success/trait_impl_base_type/src/main.nr +++ b/test_programs/execution_success/trait_impl_base_type/src/main.nr @@ -1,23 +1,23 @@ -trait Fieldable { - fn to_field(self) -> Field; +trait fieldable { + fn to_field(self) -> field; } -impl Fieldable for u32 { - fn to_field(self) -> Field { - let res = self as Field; +impl fieldable for u32 { + fn to_field(self) -> field { + let res = self as field; res * 3 } } -impl Fieldable for [u32; 3] { - fn to_field(self) -> Field { +impl fieldable for [u32; 3] { + fn to_field(self) -> field { let res = self[0] + self[1] + self[2]; - res as Field + res as field } } -impl Fieldable for bool { - fn to_field(self) -> Field { +impl fieldable for bool { + fn to_field(self) -> field { if self { 14 } else { @@ -26,52 +26,52 @@ impl Fieldable for bool { } } -impl Fieldable for (u32, bool) { - fn to_field(self) -> Field { +impl fieldable for (u32, bool) { + fn to_field(self) -> field { if self.1 { - self.0 as Field + self.0 as field } else { 32 } } } -impl Fieldable for Field { - fn to_field(self) -> Field { +impl fieldable for field { + fn to_field(self) -> field { self } } -impl Fieldable for str<6> { - fn to_field(self) -> Field { +impl fieldable for str<6> { + fn to_field(self) -> field { 6 } } -impl Fieldable for () { - fn to_field(self) -> Field { +impl fieldable for () { + fn to_field(self) -> field { 0 } } -type Point2D = [Field; 2]; +type Point2D = [field; 2]; type Point2DAlias = Point2D; -impl Fieldable for Point2DAlias { - fn to_field(self) -> Field { +impl fieldable for Point2DAlias { + fn to_field(self) -> field { self[0] + self[1] } } -impl Fieldable for fmtstr<14, (Field, Field)> { - fn to_field(self) -> Field { +impl fieldable for fmtstr<14, (field, field)> { + fn to_field(self) -> field { 52 } } -impl Fieldable for fn(u32) -> u32 { - fn to_field(self) -> Field { - self(10) as Field +impl fieldable for fn(u32) -> u32 { + fn to_field(self) -> field { + self(10) as field } } @@ -79,9 +79,9 @@ fn some_func(x: u32) -> u32 { x * 2 - 3 } -impl Fieldable for u64 { - fn to_field(self) -> Field { - 66 as Field +impl fieldable for u64 { + fn to_field(self) -> field { + 66 as field } } // x = 15 @@ -105,8 +105,8 @@ fn main(x: u32) { assert(unit.to_field() == 0); let point: Point2DAlias = [2, 3]; assert(point.to_field() == 5); - let i: Field = 2; - let j: Field = 6; + let i: field = 2; + let j: field = 6; assert(f"i: {i}, j: {j}".to_field() == 52); assert(some_func.to_field() == 17); diff --git a/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr b/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr index c59bf0387c1..1c56a2585e2 100644 --- a/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr +++ b/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr @@ -1,3 +1,3 @@ struct MyStruct { - Q: Field, + Q: field, } diff --git a/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr b/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr index 38870489131..ab62974489c 100644 --- a/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr +++ b/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr @@ -1,5 +1,5 @@ struct MyStruct { - Q: Field, + Q: field, } impl dep::crate1::MyTrait for MyStruct { diff --git a/test_programs/execution_success/tuple_inputs/src/main.nr b/test_programs/execution_success/tuple_inputs/src/main.nr index 9e61be60eb1..b9301a16c2b 100644 --- a/test_programs/execution_success/tuple_inputs/src/main.nr +++ b/test_programs/execution_success/tuple_inputs/src/main.nr @@ -1,10 +1,10 @@ struct Bar { - inner: [Field; 3], + inner: [field; 3], } struct Foo { - a: Field, - b: [Field; 3], + a: field, + b: [field; 3], bar: Bar, } diff --git a/test_programs/execution_success/type_aliases/src/main.nr b/test_programs/execution_success/type_aliases/src/main.nr index 098e043ceeb..0ceae929d09 100644 --- a/test_programs/execution_success/type_aliases/src/main.nr +++ b/test_programs/execution_success/type_aliases/src/main.nr @@ -1,6 +1,6 @@ type Foo = [T; 2]; -type Bar = Field; +type Bar = field; type One = (A, B); type Two = One; @@ -11,7 +11,7 @@ struct MyStruct { } fn main(x: [field; 2]) { - let a: Foo = [1, 2]; + let a: Foo = [1, 2]; assert(a[0] != x[0]); let b: Bar = 2; diff --git a/test_programs/execution_success/witness_compression/src/main.nr b/test_programs/execution_success/witness_compression/src/main.nr index 3027d35b13a..532b39efd68 100644 --- a/test_programs/execution_success/witness_compression/src/main.nr +++ b/test_programs/execution_success/witness_compression/src/main.nr @@ -1,7 +1,7 @@ // This test should be used to regenerate the serialized witness used in the `acvm_js` integration tests. // The `acvm_js` test file containing the serialized witness should be also called `witness_compression`. // After recompiling Noir, you can manually print the witness byte array to be written to file after execution. -fn main(x: Field, y: pub Field) -> pub Field { +fn main(x: field, y: pub field) -> pub field { assert(x != y); x + y } diff --git a/test_programs/execution_success/workspace/crates/a/src/main.nr b/test_programs/execution_success/workspace/crates/a/src/main.nr index cf72627da2e..0b95af211b2 100644 --- a/test_programs/execution_success/workspace/crates/a/src/main.nr +++ b/test_programs/execution_success/workspace/crates/a/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x == y); } diff --git a/test_programs/execution_success/workspace/crates/b/src/main.nr b/test_programs/execution_success/workspace/crates/b/src/main.nr index 4e1fd3c9035..43e9fa2196f 100644 --- a/test_programs/execution_success/workspace/crates/b/src/main.nr +++ b/test_programs/execution_success/workspace/crates/b/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x != y); } diff --git a/test_programs/execution_success/workspace_default_member/a/src/main.nr b/test_programs/execution_success/workspace_default_member/a/src/main.nr index cf72627da2e..0b95af211b2 100644 --- a/test_programs/execution_success/workspace_default_member/a/src/main.nr +++ b/test_programs/execution_success/workspace_default_member/a/src/main.nr @@ -1,3 +1,3 @@ -fn main(x: Field, y: pub Field) { +fn main(x: field, y: pub field) { assert(x == y); } diff --git a/test_programs/execution_success/workspace_default_member/b/src/main.nr b/test_programs/execution_success/workspace_default_member/b/src/main.nr index 6e170de75fc..0712e8ed882 100644 --- a/test_programs/execution_success/workspace_default_member/b/src/main.nr +++ b/test_programs/execution_success/workspace_default_member/b/src/main.nr @@ -1,3 +1,3 @@ -fn main(x : Field, y : pub Field) { +fn main(x : field, y : pub field) { assert(x != y); } diff --git a/test_programs/noir_test_success/bounded_vec/src/main.nr b/test_programs/noir_test_success/bounded_vec/src/main.nr index 22ec291f9d6..bf48add0e23 100644 --- a/test_programs/noir_test_success/bounded_vec/src/main.nr +++ b/test_programs/noir_test_success/bounded_vec/src/main.nr @@ -9,9 +9,9 @@ fn test_vec_new_bad() { } // docs:start:new_example -fn foo() -> BoundedVec { +fn foo() -> BoundedVec { // Ok! MaxLen is specified with a type annotation - let v1: BoundedVec = BoundedVec::new(); + let v1: BoundedVec = BoundedVec::new(); let v2 = BoundedVec::new(); // Ok! MaxLen is known from the type of foo's return value @@ -28,7 +28,7 @@ fn bad() { #[test] fn test_vec_push_pop() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); assert(vec.len == 0); vec.push(2); assert(vec.len == 1); @@ -66,7 +66,7 @@ fn sum_of_first_three(v: BoundedVec) -> u32 { #[test(should_fail_with = "push out of bounds")] fn push_docs_example() { // docs:start:bounded-vec-push-example - let mut v: BoundedVec = BoundedVec::new(); + let mut v: BoundedVec = BoundedVec::new(); v.push(1); v.push(2); @@ -79,7 +79,7 @@ fn push_docs_example() { #[test] fn pop_docs_example() { // docs:start:bounded-vec-pop-example - let mut v: BoundedVec = BoundedVec::new(); + let mut v: BoundedVec = BoundedVec::new(); v.push(1); v.push(2); @@ -96,7 +96,7 @@ fn pop_docs_example() { #[test] fn len_docs_example() { // docs:start:bounded-vec-len-example - let mut v: BoundedVec = BoundedVec::new(); + let mut v: BoundedVec = BoundedVec::new(); assert(v.len() == 0); v.push(100); @@ -116,7 +116,7 @@ fn len_docs_example() { #[test] fn max_len_docs_example() { // docs:start:bounded-vec-max-len-example - let mut v: BoundedVec = BoundedVec::new(); + let mut v: BoundedVec = BoundedVec::new(); assert(v.max_len() == 5); v.push(10); @@ -127,7 +127,7 @@ fn max_len_docs_example() { #[test] fn storage_docs_example() { // docs:start:bounded-vec-storage-example - let mut v: BoundedVec = BoundedVec::new(); + let mut v: BoundedVec = BoundedVec::new(); assert(v.storage() == [0, 0, 0, 0, 0]); @@ -139,7 +139,7 @@ fn storage_docs_example() { #[test] fn test_vec_extend_from_array() { // docs:start:bounded-vec-extend-from-array-example - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.extend_from_array([2, 4]); assert(vec.len == 2); @@ -151,8 +151,8 @@ fn test_vec_extend_from_array() { #[test] fn test_vec_extend_from_bounded_vec() { // docs:start:bounded-vec-extend-from-bounded-vec-example - let mut v1: BoundedVec = BoundedVec::new(); - let mut v2: BoundedVec = BoundedVec::new(); + let mut v1: BoundedVec = BoundedVec::new(); + let mut v2: BoundedVec = BoundedVec::new(); v2.extend_from_array([1, 2, 3]); v1.extend_from_bounded_vec(v2); @@ -164,13 +164,13 @@ fn test_vec_extend_from_bounded_vec() { #[test(should_fail_with="extend_from_array out of bounds")] fn test_vec_extend_from_array_out_of_bound() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.extend_from_array([2, 4, 6]); } #[test(should_fail_with="extend_from_array out of bounds")] fn test_vec_extend_from_array_twice_out_of_bound() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.extend_from_array([2]); assert(vec.len == 1); vec.extend_from_array([4, 6]); @@ -178,36 +178,36 @@ fn test_vec_extend_from_array_twice_out_of_bound() { #[test(should_fail)] fn test_vec_get_out_of_bound() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.extend_from_array([2, 4]); let _x = vec.get(2); } #[test(should_fail)] fn test_vec_get_not_declared() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.extend_from_array([2]); let _x = vec.get(1); } #[test(should_fail)] fn test_vec_get_uninitialized() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); let _x = vec.get(0); } #[test(should_fail_with="push out of bounds")] fn test_vec_push_out_of_bound() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.push(1); vec.push(2); } #[test(should_fail_with="extend_from_bounded_vec out of bounds")] fn test_vec_extend_from_bounded_vec_out_of_bound() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); - let mut another_vec: BoundedVec = BoundedVec::new(); + let mut another_vec: BoundedVec = BoundedVec::new(); another_vec.extend_from_array([1, 2, 3]); vec.extend_from_bounded_vec(another_vec); @@ -215,10 +215,10 @@ fn test_vec_extend_from_bounded_vec_out_of_bound() { #[test(should_fail_with="extend_from_bounded_vec out of bounds")] fn test_vec_extend_from_bounded_vec_twice_out_of_bound() { - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.extend_from_array([1, 2]); - let mut another_vec: BoundedVec = BoundedVec::new(); + let mut another_vec: BoundedVec = BoundedVec::new(); another_vec.push(3); vec.extend_from_bounded_vec(another_vec); @@ -238,7 +238,7 @@ fn test_vec_any() { #[test] fn test_vec_any_not_default() { let default_value = 0; - let mut vec: BoundedVec = BoundedVec::new(); + let mut vec: BoundedVec = BoundedVec::new(); vec.extend_from_array([2, 4]); assert(!vec.any(|v| v == default_value)); } diff --git a/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr b/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr index 5d73ef96d49..1d013c8f2d6 100644 --- a/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr +++ b/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::field::bn254::{TWO_POW_128, assert_gt}; +use dep::std::field_element::bn254::{TWO_POW_128, assert_gt}; #[test(should_fail_with = "attempt to add with overflow")] unconstrained fn test_overflow_add() { diff --git a/test_programs/noir_test_success/mock_oracle/src/main.nr b/test_programs/noir_test_success/mock_oracle/src/main.nr index d840ffaef66..078b526a75b 100644 --- a/test_programs/noir_test_success/mock_oracle/src/main.nr +++ b/test_programs/noir_test_success/mock_oracle/src/main.nr @@ -1,8 +1,8 @@ use dep::std::test::OracleMock; struct Point { - x: Field, - y: Field, + x: field, + y: field, } impl Eq for Point { @@ -12,23 +12,23 @@ impl Eq for Point { } #[oracle(void_field)] -unconstrained fn void_field_oracle() -> Field {} +unconstrained fn void_field_oracle() -> field {} -unconstrained fn void_field() -> Field { +unconstrained fn void_field() -> field { void_field_oracle() } #[oracle(field_field)] -unconstrained fn field_field_oracle(_x: Field) -> Field {} +unconstrained fn field_field_oracle(_x: field) -> field {} -unconstrained fn field_field(x: Field) -> Field { +unconstrained fn field_field(x: field) -> field { field_field_oracle(x) } #[oracle(struct_field)] -unconstrained fn struct_field_oracle(_point: Point, _array: [Field; 4]) -> Field {} +unconstrained fn struct_field_oracle(_point: Point, _array: [field; 4]) -> field {} -unconstrained fn struct_field(point: Point, array: [Field; 4]) -> Field { +unconstrained fn struct_field(point: Point, array: [field; 4]) -> field { struct_field_oracle(point, array) } @@ -115,7 +115,7 @@ fn test_mock_struct_field() { assert_eq(0, struct_field(point, array)); - let last_params: (Point, [Field; 4]) = timeless_mock.get_last_params(); + let last_params: (Point, [field; 4]) = timeless_mock.get_last_params(); assert_eq(last_params.0, point); assert_eq(last_params.1, array); diff --git a/test_programs/noir_test_success/out_of_bounds_alignment/src/main.nr b/test_programs/noir_test_success/out_of_bounds_alignment/src/main.nr index a47ab37eb31..0d6dd5a4780 100644 --- a/test_programs/noir_test_success/out_of_bounds_alignment/src/main.nr +++ b/test_programs/noir_test_success/out_of_bounds_alignment/src/main.nr @@ -1,8 +1,8 @@ -fn out_of_bounds(arr_1: [Field; 50]) -> Field { +fn out_of_bounds(arr_1: [field; 50]) -> field { arr_1[50 + 1] } -unconstrained fn out_of_bounds_unconstrained_wrapper(arr_1: [Field; 50], arr_2: [Field; 50]) -> Field { +unconstrained fn out_of_bounds_unconstrained_wrapper(arr_1: [field; 50], arr_2: [field; 50]) -> field { out_of_bounds(arr_1) } diff --git a/test_programs/test_libraries/bad_impl/src/lib.nr b/test_programs/test_libraries/bad_impl/src/lib.nr index a96a6cbf91f..8394f0a86db 100644 --- a/test_programs/test_libraries/bad_impl/src/lib.nr +++ b/test_programs/test_libraries/bad_impl/src/lib.nr @@ -1,5 +1,5 @@ -impl Field { - fn something(self) -> Field { +impl field { + fn something(self) -> field { self } } diff --git a/test_programs/test_libraries/bin_dep/src/main.nr b/test_programs/test_libraries/bin_dep/src/main.nr index 042c85a8afb..ea26f76a36b 100644 --- a/test_programs/test_libraries/bin_dep/src/main.nr +++ b/test_programs/test_libraries/bin_dep/src/main.nr @@ -1,3 +1,3 @@ -fn call_dep1_then_dep2(x: Field, y: Field) { +fn call_dep1_then_dep2(x: field, y: field) { assert(x == y); } diff --git a/test_programs/test_libraries/diamond_deps_1/src/lib.nr b/test_programs/test_libraries/diamond_deps_1/src/lib.nr index 60c001ec64e..0a358491f35 100644 --- a/test_programs/test_libraries/diamond_deps_1/src/lib.nr +++ b/test_programs/test_libraries/diamond_deps_1/src/lib.nr @@ -1,5 +1,5 @@ use dep::dep2::call_dep2; -pub fn call_dep1_then_dep2(x: Field, y: Field) -> Field { +pub fn call_dep1_then_dep2(x: field, y: field) -> field { call_dep2(x, y) } diff --git a/test_programs/test_libraries/diamond_deps_2/src/lib.nr b/test_programs/test_libraries/diamond_deps_2/src/lib.nr index 46dce3d5600..ae482f712b3 100644 --- a/test_programs/test_libraries/diamond_deps_2/src/lib.nr +++ b/test_programs/test_libraries/diamond_deps_2/src/lib.nr @@ -1,5 +1,5 @@ global RESOLVE_THIS = 3; -pub fn call_dep2(x: Field, y: Field) -> Field { +pub fn call_dep2(x: field, y: field) -> field { x + y } diff --git a/test_programs/test_libraries/exporting_lib/src/lib.nr b/test_programs/test_libraries/exporting_lib/src/lib.nr index bfb1819132a..50c9195928b 100644 --- a/test_programs/test_libraries/exporting_lib/src/lib.nr +++ b/test_programs/test_libraries/exporting_lib/src/lib.nr @@ -1,5 +1,5 @@ struct MyStruct { - inner: Field + inner: field } type FooStruct = MyStruct; From e91ecf57c2836a1cc3177ca531712ebf5f0fa8e3 Mon Sep 17 00:00:00 2001 From: Tom French Date: Sat, 20 Apr 2024 15:39:55 +0100 Subject: [PATCH 16/19] chore: fix slices from merge --- .../brillig_nested_slices/src/main.nr | 2 +- .../nested_slice_literal/src/main.nr | 2 +- .../slice_access_failure/src/main.nr | 2 +- .../slice_insert_failure/src/main.nr | 2 +- .../slice_remove_failure/src/main.nr | 2 +- .../execution_success/brillig_slices/src/main.nr | 6 +++--- test_programs/execution_success/slices/src/main.nr | 14 +++++++------- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test_programs/compile_failure/brillig_nested_slices/src/main.nr b/test_programs/compile_failure/brillig_nested_slices/src/main.nr index 9828c71bb3c..7df3272dd91 100644 --- a/test_programs/compile_failure/brillig_nested_slices/src/main.nr +++ b/test_programs/compile_failure/brillig_nested_slices/src/main.nr @@ -16,7 +16,7 @@ unconstrained fn create_foo(id: field, value: field) -> NestedSliceStruct { } unconstrained fn main(a: field, b: field) { - let mut slice = [create_foo(a, b), create_foo(b, a)]; + let mut slice = &[create_foo(a, b), create_foo(b, a)]; assert(slice.len() == 2); assert(slice[0].id == a); diff --git a/test_programs/compile_failure/nested_slice_literal/src/main.nr b/test_programs/compile_failure/nested_slice_literal/src/main.nr index 8636e843c33..fb220e21add 100644 --- a/test_programs/compile_failure/nested_slice_literal/src/main.nr +++ b/test_programs/compile_failure/nested_slice_literal/src/main.nr @@ -17,7 +17,7 @@ fn main(x: field, y: pub field) { assert(x != y); let foo = Foo { a: 7, b: [8, 9, 22].as_slice(), bar: Bar { inner: [106, 107, 108] } }; - let mut slice = [foo, foo]; + let mut slice = &[foo, foo]; slice = slice.push_back(foo); assert(slice.len() == 3); } diff --git a/test_programs/execution_failure/slice_access_failure/src/main.nr b/test_programs/execution_failure/slice_access_failure/src/main.nr index e527e8d42ea..99e5fbe5829 100644 --- a/test_programs/execution_failure/slice_access_failure/src/main.nr +++ b/test_programs/execution_failure/slice_access_failure/src/main.nr @@ -1,5 +1,5 @@ fn main(x: field, y: pub field) { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x == y { slice = slice.push_back(y); slice = slice.push_back(x); diff --git a/test_programs/execution_failure/slice_insert_failure/src/main.nr b/test_programs/execution_failure/slice_insert_failure/src/main.nr index cdd6a2887ff..cbd7cdb7550 100644 --- a/test_programs/execution_failure/slice_insert_failure/src/main.nr +++ b/test_programs/execution_failure/slice_insert_failure/src/main.nr @@ -1,5 +1,5 @@ fn main(x: field, y: pub field) { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x == y { slice = slice.push_back(y); slice = slice.push_back(x); diff --git a/test_programs/execution_failure/slice_remove_failure/src/main.nr b/test_programs/execution_failure/slice_remove_failure/src/main.nr index 70ff23740b1..ad477291702 100644 --- a/test_programs/execution_failure/slice_remove_failure/src/main.nr +++ b/test_programs/execution_failure/slice_remove_failure/src/main.nr @@ -1,5 +1,5 @@ fn main(x: field, y: pub field) { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x == y { slice = slice.push_back(y); slice = slice.push_back(x); diff --git a/test_programs/execution_success/brillig_slices/src/main.nr b/test_programs/execution_success/brillig_slices/src/main.nr index 117cb5de3af..9b36befb335 100644 --- a/test_programs/execution_success/brillig_slices/src/main.nr +++ b/test_programs/execution_success/brillig_slices/src/main.nr @@ -108,7 +108,7 @@ unconstrained fn merge_slices_else(x: field) { } // Test returning a merged slice without a mutation unconstrained fn merge_slices_return(x: field, y: field) -> [field] { - let slice = [0; 2]; + let slice = &[0; 2]; if x != y { if x != 20 { slice.push_back(y) } else { slice } } else { @@ -117,7 +117,7 @@ unconstrained fn merge_slices_return(x: field, y: field) -> [field] { } // Test mutating a slice inside of an if statement unconstrained fn merge_slices_mutate(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { slice = slice.push_back(y); slice = slice.push_back(x); @@ -128,7 +128,7 @@ unconstrained fn merge_slices_mutate(x: field, y: field) -> [field] { } // Test mutating a slice inside of a loop in an if statement unconstrained fn merge_slices_mutate_in_loop(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { for i in 0..5 { slice = slice.push_back(i as field); diff --git a/test_programs/execution_success/slices/src/main.nr b/test_programs/execution_success/slices/src/main.nr index 97f757bdf3e..8f40ff308a1 100644 --- a/test_programs/execution_success/slices/src/main.nr +++ b/test_programs/execution_success/slices/src/main.nr @@ -161,7 +161,7 @@ fn merge_slices_return(x: field, y: field) -> [field] { // Test mutating a slice inside of an if statement fn merge_slices_mutate(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { slice = slice.push_back(y); slice = slice.push_back(x); @@ -173,7 +173,7 @@ fn merge_slices_mutate(x: field, y: field) -> [field] { // Test mutating a slice inside of a loop in an if statement fn merge_slices_mutate_in_loop(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { for i in 0..5 { slice = slice.push_back(i as field); @@ -185,7 +185,7 @@ fn merge_slices_mutate_in_loop(x: field, y: field) -> [field] { } fn merge_slices_mutate_two_ifs(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { slice = slice.push_back(y); slice = slice.push_back(x); @@ -204,7 +204,7 @@ fn merge_slices_mutate_two_ifs(x: field, y: field) -> [field] { } fn merge_slices_mutate_between_ifs(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { slice = slice.push_back(y); slice = slice.push_back(x); @@ -230,7 +230,7 @@ fn merge_slices_mutate_between_ifs(x: field, y: field) -> [field] { } fn merge_slices_push_then_pop(x: field, y: field) { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { slice = slice.push_back(y); slice = slice.push_back(x); @@ -254,7 +254,7 @@ fn merge_slices_push_then_pop(x: field, y: field) { } fn merge_slices_push_then_insert(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { slice = slice.push_back(y); slice = slice.push_back(x); @@ -277,7 +277,7 @@ fn merge_slices_push_then_insert(x: field, y: field) -> [field] { } fn merge_slices_remove_between_ifs(x: field, y: field) -> [field] { - let mut slice = [0; 2]; + let mut slice = &[0; 2]; if x != y { slice = slice.push_back(y); slice = slice.push_back(x); From f7305d3dab16eaea11297b566938218fc130c70a Mon Sep 17 00:00:00 2001 From: Tom French Date: Sat, 20 Apr 2024 15:42:55 +0100 Subject: [PATCH 17/19] chore: fix tests --- .../compile_success_empty/regression_4635/src/main.nr | 2 +- test_programs/execution_success/slice_coercion/src/main.nr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test_programs/compile_success_empty/regression_4635/src/main.nr b/test_programs/compile_success_empty/regression_4635/src/main.nr index 0bcac2b7e95..48671513fd4 100644 --- a/test_programs/compile_success_empty/regression_4635/src/main.nr +++ b/test_programs/compile_success_empty/regression_4635/src/main.nr @@ -1,5 +1,5 @@ trait Fromfield { - fn from_field(field: field) -> Self; + fn from_field(value: field) -> Self; } impl Fromfield for field { diff --git a/test_programs/execution_success/slice_coercion/src/main.nr b/test_programs/execution_success/slice_coercion/src/main.nr index 2de928b3a5c..e74986f6217 100644 --- a/test_programs/execution_success/slice_coercion/src/main.nr +++ b/test_programs/execution_success/slice_coercion/src/main.nr @@ -7,8 +7,8 @@ impl Hasher { Self { fields: [] } } - pub fn add(&mut self, field: field) { - self.fields = self.fields.push_back(field); + pub fn add(&mut self, field_element: field) { + self.fields = self.fields.push_back(field_element); } } From 5453a684ccb00b028bb3368009c8c75c84d98805 Mon Sep 17 00:00:00 2001 From: Tom French Date: Sat, 20 Apr 2024 15:43:47 +0100 Subject: [PATCH 18/19] chore: revert changes to trait name --- .../trait_impl_base_type/src/main.nr | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test_programs/execution_success/trait_impl_base_type/src/main.nr b/test_programs/execution_success/trait_impl_base_type/src/main.nr index 80dd3a08f1b..001943b5526 100644 --- a/test_programs/execution_success/trait_impl_base_type/src/main.nr +++ b/test_programs/execution_success/trait_impl_base_type/src/main.nr @@ -1,22 +1,22 @@ -trait fieldable { +trait Fieldable { fn to_field(self) -> field; } -impl fieldable for u32 { +impl Fieldable for u32 { fn to_field(self) -> field { let res = self as field; res * 3 } } -impl fieldable for [u32; 3] { +impl Fieldable for [u32; 3] { fn to_field(self) -> field { let res = self[0] + self[1] + self[2]; res as field } } -impl fieldable for bool { +impl Fieldable for bool { fn to_field(self) -> field { if self { 14 @@ -26,7 +26,7 @@ impl fieldable for bool { } } -impl fieldable for (u32, bool) { +impl Fieldable for (u32, bool) { fn to_field(self) -> field { if self.1 { self.0 as field @@ -36,19 +36,19 @@ impl fieldable for (u32, bool) { } } -impl fieldable for field { +impl Fieldable for field { fn to_field(self) -> field { self } } -impl fieldable for str<6> { +impl Fieldable for str<6> { fn to_field(self) -> field { 6 } } -impl fieldable for () { +impl Fieldable for () { fn to_field(self) -> field { 0 } @@ -57,19 +57,19 @@ impl fieldable for () { type Point2D = [field; 2]; type Point2DAlias = Point2D; -impl fieldable for Point2DAlias { +impl Fieldable for Point2DAlias { fn to_field(self) -> field { self[0] + self[1] } } -impl fieldable for fmtstr<14, (field, field)> { +impl Fieldable for fmtstr<14, (field, field)> { fn to_field(self) -> field { 52 } } -impl fieldable for fn(u32) -> u32 { +impl Fieldable for fn(u32) -> u32 { fn to_field(self) -> field { self(10) as field } @@ -79,7 +79,7 @@ fn some_func(x: u32) -> u32 { x * 2 - 3 } -impl fieldable for u64 { +impl Fieldable for u64 { fn to_field(self) -> field { 66 as field } From 0445ec53f01e191dab0cbec69df50141cba9506c Mon Sep 17 00:00:00 2001 From: Tom French Date: Sat, 20 Apr 2024 16:04:37 +0100 Subject: [PATCH 19/19] chore: update formatter tests --- tooling/nargo_fmt/src/visitor/item.rs | 2 ++ tooling/nargo_fmt/tests/expected/contract.nr | 2 +- tooling/nargo_fmt/tests/expected/module.nr | 2 +- tooling/nargo_fmt/tests/expected/struct.nr | 12 ++++++------ tooling/nargo_fmt/tests/input/contract.nr | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tooling/nargo_fmt/src/visitor/item.rs b/tooling/nargo_fmt/src/visitor/item.rs index 28aad3c551f..ff115814e59 100644 --- a/tooling/nargo_fmt/src/visitor/item.rs +++ b/tooling/nargo_fmt/src/visitor/item.rs @@ -220,6 +220,8 @@ impl super::FmtVisitor<'_> { self.push_rewrite(use_tree, span); self.last_position = span.end(); } + + // TODO: rewrite instances of "Field" into "field" in these items. ItemKind::Struct(_) | ItemKind::Trait(_) | ItemKind::TraitImpl(_) diff --git a/tooling/nargo_fmt/tests/expected/contract.nr b/tooling/nargo_fmt/tests/expected/contract.nr index 3e73d5f3344..07a83d7b910 100644 --- a/tooling/nargo_fmt/tests/expected/contract.nr +++ b/tooling/nargo_fmt/tests/expected/contract.nr @@ -16,7 +16,7 @@ contract Benchmarking { struct Storage { notes: Map>, - balances: Map>, + balances: Map>, } impl Storage { diff --git a/tooling/nargo_fmt/tests/expected/module.nr b/tooling/nargo_fmt/tests/expected/module.nr index 648e6f1fee8..c031d9d29c8 100644 --- a/tooling/nargo_fmt/tests/expected/module.nr +++ b/tooling/nargo_fmt/tests/expected/module.nr @@ -1,7 +1,7 @@ mod a { mod b { struct Data { - a: field + a: Field } } diff --git a/tooling/nargo_fmt/tests/expected/struct.nr b/tooling/nargo_fmt/tests/expected/struct.nr index 2c6dacc8123..9cec99bb2bd 100644 --- a/tooling/nargo_fmt/tests/expected/struct.nr +++ b/tooling/nargo_fmt/tests/expected/struct.nr @@ -1,11 +1,11 @@ struct Foo { - bar: field, - array: [field; 2], + bar: Field, + array: [Field; 2], } struct Pair { first: Foo, - second: field, + second: Field, } impl Foo { @@ -25,8 +25,8 @@ impl Pair { } struct Nested { - a: field, - b: field + a: Field, + b: Field } struct MyStruct { my_bool: bool, @@ -39,7 +39,7 @@ fn test_struct_in_tuple(a_bool: bool, x: field, y: field) -> (MyStruct, bool) { } struct Animal { - legs: field, + legs: Field, eyes: u8, } diff --git a/tooling/nargo_fmt/tests/input/contract.nr b/tooling/nargo_fmt/tests/input/contract.nr index 97a6ebd6b77..465316aa35a 100644 --- a/tooling/nargo_fmt/tests/input/contract.nr +++ b/tooling/nargo_fmt/tests/input/contract.nr @@ -63,7 +63,7 @@ contract Benchmarking { storage.balances.at(owner).write(current + value); let _callStackItem1 = context.call_public_function( context.this_address(), - FunctionSelector::from_signature("broadcast(Field)"), + FunctionSelector::from_signature("broadcast(field)"), [owner] ); }