From 9a46a069dd8d868f7ba6b95f5aeb8bd4cff541fd Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Thu, 14 Nov 2024 23:46:51 +0000 Subject: [PATCH 1/2] don't convert to slice and back to array --- src/bignum.nr | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bignum.nr b/src/bignum.nr index b50a02b2..c4f50fd5 100644 --- a/src/bignum.nr +++ b/src/bignum.nr @@ -212,7 +212,7 @@ where unconstrained fn __batch_invert(x: [Self; M]) -> [Self; M] { let params = Params::get_params(); assert(params.has_multiplicative_inverse); - __batch_invert::<_, MOD_BITS, _>(params, x.map(|bn| Self::get_limbs_slice(bn).as_array())) + __batch_invert::<_, MOD_BITS, _>(params, x.map(|bn: Self| bn.limbs)) .map(|limbs| Self { limbs }) } @@ -221,7 +221,7 @@ where assert(params.has_multiplicative_inverse); __batch_invert_slice::<_, MOD_BITS>( params, - x.map(|bn| Self::get_limbs_slice(bn).as_array()), + x.map(|bn: Self| bn.limbs), ) .map(|limbs| Self { limbs }) } @@ -245,15 +245,15 @@ where params, map( lhs_terms, - |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + |bns| map(bns, |bn: Self| bn.limbs), ), lhs_flags, map( rhs_terms, - |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + |bns| map(bns, |bn: Self| bn.limbs), ), rhs_flags, - map(linear_terms, |bn| Self::get_limbs_slice(bn).as_array()), + map(linear_terms, |bn: Self| bn.limbs), linear_flags, ); (Self { limbs: q_limbs }, Self { limbs: r_limbs }) @@ -272,15 +272,15 @@ where params, map( lhs_terms, - |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + |bns| map(bns, |bn: Self| bn.limbs), ), lhs_flags, map( rhs_terms, - |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + |bns| map(bns, |bn: Self| bn.limbs), ), rhs_flags, - map(linear_terms, |bn| Self::get_limbs_slice(bn).as_array()), + map(linear_terms, |bn: Self| bn.limbs), linear_flags, ) } From 8cb9df62f5844e6df55af717c0650df4c1b05a60 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Thu, 14 Nov 2024 23:49:42 +0000 Subject: [PATCH 2/2] fmt --- src/bignum.nr | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/bignum.nr b/src/bignum.nr index c4f50fd5..52002bd7 100644 --- a/src/bignum.nr +++ b/src/bignum.nr @@ -212,18 +212,17 @@ where unconstrained fn __batch_invert(x: [Self; M]) -> [Self; M] { let params = Params::get_params(); assert(params.has_multiplicative_inverse); - __batch_invert::<_, MOD_BITS, _>(params, x.map(|bn: Self| bn.limbs)) - .map(|limbs| Self { limbs }) + __batch_invert::<_, MOD_BITS, _>(params, x.map(|bn: Self| bn.limbs)).map(|limbs| { + Self { limbs } + }) } unconstrained fn __batch_invert_slice(x: [Self]) -> [Self] { let params = Params::get_params(); assert(params.has_multiplicative_inverse); - __batch_invert_slice::<_, MOD_BITS>( - params, - x.map(|bn: Self| bn.limbs), - ) - .map(|limbs| Self { limbs }) + __batch_invert_slice::<_, MOD_BITS>(params, x.map(|bn: Self| bn.limbs)).map(|limbs| { + Self { limbs } + }) } unconstrained fn __tonelli_shanks_sqrt(self) -> std::option::Option { @@ -243,15 +242,9 @@ where let params = Params::get_params(); let (q_limbs, r_limbs) = __compute_quadratic_expression::<_, MOD_BITS, _, _, _, _>( params, - map( - lhs_terms, - |bns| map(bns, |bn: Self| bn.limbs), - ), + map(lhs_terms, |bns| map(bns, |bn: Self| bn.limbs)), lhs_flags, - map( - rhs_terms, - |bns| map(bns, |bn: Self| bn.limbs), - ), + map(rhs_terms, |bns| map(bns, |bn: Self| bn.limbs)), rhs_flags, map(linear_terms, |bn: Self| bn.limbs), linear_flags, @@ -270,15 +263,9 @@ where let params = Params::get_params(); evaluate_quadratic_expression::<_, MOD_BITS, _, _, _, _>( params, - map( - lhs_terms, - |bns| map(bns, |bn: Self| bn.limbs), - ), + map(lhs_terms, |bns| map(bns, |bn: Self| bn.limbs)), lhs_flags, - map( - rhs_terms, - |bns| map(bns, |bn: Self| bn.limbs), - ), + map(rhs_terms, |bns| map(bns, |bn: Self| bn.limbs)), rhs_flags, map(linear_terms, |bn: Self| bn.limbs), linear_flags,