From bb32c1fe883bedb71ae947ae2ccefe37077de4dd Mon Sep 17 00:00:00 2001 From: Michael Connor Date: Sun, 3 Nov 2024 20:08:54 +0000 Subject: [PATCH 1/7] fix param bug --- src/fields/secp256r1Fq.nr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fields/secp256r1Fq.nr b/src/fields/secp256r1Fq.nr index 6f661aa6..6736a00a 100644 --- a/src/fields/secp256r1Fq.nr +++ b/src/fields/secp256r1Fq.nr @@ -4,13 +4,13 @@ use crate::utils::u60_representation::U60Repr; pub struct Secp256r1_Fq_Params {} -impl BigNumParamsGetter<3, 265> for Secp256r1_Fq_Params { - fn get_params() -> BigNumParams<3, 265> { +impl BigNumParamsGetter<3, 256> for Secp256r1_Fq_Params { + fn get_params() -> BigNumParams<3, 256> { Secp256r1_Fq_PARAMS } } -global Secp256r1_Fq_PARAMS: BigNumParams<3, 265> = BigNumParams { +global Secp256r1_Fq_PARAMS: BigNumParams<3, 256> = BigNumParams { has_multiplicative_inverse: true, modulus: [0xffffffffffffffffffffffff, 0xffff00000001000000000000000000, 0xffff], double_modulus: [ From 6eb9af492ab372bcf4a5d913508107c4001ca96f Mon Sep 17 00:00:00 2001 From: Michael Connor Date: Sun, 3 Nov 2024 20:09:09 +0000 Subject: [PATCH 2/7] rm N generic from BigNumTrait --- src/bignum.nr | 66 ++++++++++++++++++++++------------------ src/tests/bignum_test.nr | 52 +++++++++++++++---------------- 2 files changed, 62 insertions(+), 56 deletions(-) diff --git a/src/bignum.nr b/src/bignum.nr index 787d0ed0..7994f8ee 100644 --- a/src/bignum.nr +++ b/src/bignum.nr @@ -18,7 +18,7 @@ pub struct BigNum { pub limbs: [Field; N], } -pub(crate) trait BigNumTrait { +pub(crate) trait BigNumTrait { // TODO: this crashes the compiler? v0.32 // fn default() -> Self { std::default::Default::default () } pub fn new() -> Self; @@ -26,15 +26,15 @@ pub(crate) trait BigNumTrait { pub fn derive_from_seed(seed: [u8; SeedBytes]) -> Self; pub unconstrained fn __derive_from_seed(seed: [u8; SeedBytes]) -> Self; pub fn from_slice(limbs: [Field]) -> Self; - pub fn from_array(limbs: [Field; N]) -> Self; + // pub fn from_array(limbs: [Field; M]) -> Self; pub fn from_be_bytes(x: [u8; NBytes]) -> Self; pub fn to_le_bytes(self) -> [u8; NBytes]; pub fn modulus() -> Self; - pub fn modulus_bits() -> u32; - pub fn num_limbs() -> u32; - // pub fn get(self) -> [Field]; - pub fn get_limbs(self) -> [Field; N]; + pub fn modulus_bits(self) -> u32; + pub fn num_limbs(self) -> u32; + pub fn get_limbs_slice(self) -> [Field]; + // pub fn get_limbs(self) -> [Field; M]; pub fn get_limb(self, idx: u32) -> Field; pub fn set_limb(&mut self, idx: u32, value: Field); @@ -100,7 +100,7 @@ pub(crate) trait BigNumTrait { pub fn conditional_select(lhs: Self, rhs: Self, predicate: bool) -> Self; } -impl BigNumTrait for BigNum +impl BigNumTrait for BigNum where Params: BigNumParamsGetter, { @@ -129,9 +129,12 @@ where Self { limbs: limbs.as_array() } } - fn from_array(limbs: [Field; N]) -> Self { - Self { limbs } - } + // We avoid passing an array, because that would require the array length to be expressed as a generic param of BigNumTrait, and we don't want BigNumTrait to have any generic params, so that when we use BigNum, we can cleanly say `where BigNum: BigNumTrait`, without any extra generics being used. + // fn from_array(limbs: [Field; M]) -> Self { + // // This static assertion doesn't trick the compiler. + // std::static_assert(M == N, ""); + // Self { limbs } + // } fn from_be_bytes(x: [u8; NBytes]) -> Self { Self { limbs: from_be_bytes::<_, MOD_BITS, _>(x) } @@ -145,22 +148,25 @@ where Self { limbs: Params::get_params().modulus } } - fn modulus_bits() -> u32 { + fn modulus_bits(_: Self) -> u32 { MOD_BITS } - fn num_limbs() -> u32 { + fn num_limbs(_: Self) -> u32 { N } - // fn get(self) -> [Field] { - // self.get_limbs() - // } - - fn get_limbs(self) -> [Field; N] { + fn get_limbs_slice(self) -> [Field] { self.limbs } + // We avoid returning an array, because that would require the array length to be expressed as a generic param of BigNumTrait, and we don't want BigNumTrait to have any generic params, so that when we use BigNum, we can cleanly say `where BigNum: BigNumTrait`, without any extra generics being used. + // fn get_limbs(self) -> [Field; M] { + // // This static assertion doesn't trick the compiler. + // std::static_assert(M == N, ""); + // self.limbs + // } + fn get_limb(self, idx: u32) -> Field { self.limbs[idx] } @@ -179,27 +185,27 @@ where unconstrained fn __neg(self) -> Self { let params = Params::get_params(); - Self::from_array(__neg(params, self.limbs)) + Self::from_slice(__neg(params, self.limbs)) } unconstrained fn __add(self, other: Self) -> Self { let params = Params::get_params(); - Self::from_array(__add(params, self.limbs, other.limbs)) + Self::from_slice(__add(params, self.limbs, other.limbs)) } unconstrained fn __sub(self, other: Self) -> Self { let params = Params::get_params(); - Self::from_array(__sub(params, self.limbs, other.limbs)) + Self::from_slice(__sub(params, self.limbs, other.limbs)) } unconstrained fn __mul(self, other: Self) -> Self { let params = Params::get_params(); - Self::from_array(__mul::<_, MOD_BITS>(params, self.limbs, other.limbs)) + Self::from_slice(__mul::<_, MOD_BITS>(params, self.limbs, other.limbs)) } unconstrained fn __div(self, divisor: Self) -> Self { let params = Params::get_params(); - Self::from_array(__div::<_, MOD_BITS>(params, self.limbs, divisor.limbs)) + Self::from_slice(__div::<_, MOD_BITS>(params, self.limbs, divisor.limbs)) } unconstrained fn __udiv_mod(self, divisor: Self) -> (Self, Self) { @@ -221,7 +227,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(bn))).map(|limbs| { + __batch_invert::<_, MOD_BITS, _>(params, x.map(|bn| Self::get_limbs_slice(bn).as_array())).map(|limbs| { Self { limbs } }) } @@ -229,7 +235,7 @@ where 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::get_limbs(bn))).map(|limbs| { + __batch_invert_slice::<_, MOD_BITS>(params, x.map(|bn| Self::get_limbs_slice(bn).as_array())).map(|limbs| { Self { limbs } }) } @@ -251,11 +257,11 @@ 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::get_limbs(bn))), + map(lhs_terms, |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array())), lhs_flags, - map(rhs_terms, |bns| map(bns, |bn| Self::get_limbs(bn))), + map(rhs_terms, |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array())), rhs_flags, - map(linear_terms, |bn| Self::get_limbs(bn)), + map(linear_terms, |bn| Self::get_limbs_slice(bn).as_array()), linear_flags, ); (Self { limbs: q_limbs }, Self { limbs: r_limbs }) @@ -272,11 +278,11 @@ where let params = Params::get_params(); evaluate_quadratic_expression::<_, MOD_BITS, _, _, _, _>( params, - map(lhs_terms, |bns| map(bns, |bn| Self::get_limbs(bn))), + map(lhs_terms, |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array())), lhs_flags, - map(rhs_terms, |bns| map(bns, |bn| Self::get_limbs(bn))), + map(rhs_terms, |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array())), rhs_flags, - map(linear_terms, |bn| Self::get_limbs(bn)), + map(linear_terms, |bn| Self::get_limbs_slice(bn).as_array()), linear_flags, ) } diff --git a/src/tests/bignum_test.nr b/src/tests/bignum_test.nr index a728e7e9..ffc8f524 100644 --- a/src/tests/bignum_test.nr +++ b/src/tests/bignum_test.nr @@ -238,16 +238,16 @@ fn test_bls_reduction() { fn test_eq() where - BN: BigNumTrait, + BN: BigNumTrait, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let c = unsafe { BN::__derive_from_seed([2, 2, 3, 4]) }; let modulus = BN::modulus(); - let t0: U60Repr = (U60Repr::from(modulus.get_limbs())); - let t1: U60Repr = (U60Repr::from(b.get_limbs())); - let b_plus_modulus = BN::from_array(U60Repr::into(t0 + t1)); + let t0: U60Repr = (U60Repr::from(modulus.get_limbs_slice().as_array())); + let t1: U60Repr = (U60Repr::from(b.get_limbs_slice().as_array())); + let b_plus_modulus = BN::from_slice(U60Repr::into(t0 + t1)); assert(a.eq(b) == true); assert(a.eq(b_plus_modulus) == true); assert(c.eq(b) == false); @@ -275,7 +275,7 @@ where // // // 929 gates for a 2048 bit mul fn test_mul() where - BN: BigNumTrait + std::ops::Mul + std::ops::Add, + BN: BigNumTrait + std::ops::Mul + std::ops::Add, { let a: BN = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b: BN = unsafe { BN::__derive_from_seed([4, 5, 6, 7]) }; @@ -287,7 +287,7 @@ where fn test_add() where - BN: BigNumTrait + std::ops::Add + std::ops::Mul + std::cmp::Eq, + BN: BigNumTrait + std::ops::Add + std::ops::Mul + std::cmp::Eq, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b: BN = unsafe { BN::__derive_from_seed([4, 5, 6, 7]) }; @@ -301,7 +301,7 @@ where let d = (a + b) * (one + one); assert(c == (d)); let e = one + one; - let limbs = e.get_limbs(); + let limbs: [Field; N] = e.get_limbs_slice().as_array(); let mut first: bool = true; for limb in limbs { if first { @@ -315,7 +315,7 @@ where fn test_div() where - BN: BigNumTrait + std::ops::Div + std::ops::Mul + std::ops::Add + std::cmp::Eq, + BN: BigNumTrait + std::ops::Div + std::ops::Mul + std::ops::Add + std::cmp::Eq, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b = unsafe { BN::__derive_from_seed([4, 5, 6, 7]) }; @@ -326,7 +326,7 @@ where fn test_invmod() where - BN: BigNumTrait + std::cmp::Eq, + BN: BigNumTrait + std::cmp::Eq, { let u = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; for _ in 0..1 { @@ -339,7 +339,7 @@ where fn assert_is_not_equal() where - BN: BigNumTrait, + BN: BigNumTrait, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b = unsafe { BN::__derive_from_seed([4, 5, 6, 7]) }; @@ -349,7 +349,7 @@ where fn assert_is_not_equal_fail() where - BN: BigNumTrait, + BN: BigNumTrait, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; @@ -359,48 +359,48 @@ where fn assert_is_not_equal_overloaded_lhs_fail() where - BN: BigNumTrait, + BN: BigNumTrait, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let modulus = BN::modulus(); - let t0: U60Repr = U60Repr::from(a.get_limbs()); - let t1: U60Repr = U60Repr::from(modulus.get_limbs()); - let a_plus_modulus = BN::from_array(U60Repr::into(t0 + t1)); + let t0: U60Repr = U60Repr::from(a.get_limbs_slice().as_array()); + let t1: U60Repr = U60Repr::from(modulus.get_limbs_slice().as_array()); + let a_plus_modulus = BN::from_slice(U60Repr::into(t0 + t1)); a_plus_modulus.assert_is_not_equal(b); } fn assert_is_not_equal_overloaded_rhs_fail() where - BN: BigNumTrait, + BN: BigNumTrait, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let modulus = BN::modulus(); - let t0: U60Repr = U60Repr::from(b.get_limbs()); - let t1: U60Repr = U60Repr::from(modulus.get_limbs()); - let b_plus_modulus = BN::from_array(U60Repr::into(t0 + t1)); + let t0: U60Repr = U60Repr::from(b.get_limbs_slice().as_array()); + let t1: U60Repr = U60Repr::from(modulus.get_limbs_slice().as_array()); + let b_plus_modulus = BN::from_slice(U60Repr::into(t0 + t1)); a.assert_is_not_equal(b_plus_modulus); } fn assert_is_not_equal_overloaded_fail() where - BN: BigNumTrait, + BN: BigNumTrait, { let a = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let b = unsafe { BN::__derive_from_seed([1, 2, 3, 4]) }; let modulus = BN::modulus(); - let t0: U60Repr = U60Repr::from(a.get_limbs()); - let t1: U60Repr = U60Repr::from(b.get_limbs()); - let t2: U60Repr = U60Repr::from(modulus.get_limbs()); - let a_plus_modulus: BN = BN::from_array(U60Repr::into(t0 + t2)); - let b_plus_modulus: BN = BN::from_array(U60Repr::into(t1 + t2)); + let t0: U60Repr = U60Repr::from(a.get_limbs_slice().as_array()); + let t1: U60Repr = U60Repr::from(b.get_limbs_slice().as_array()); + let t2: U60Repr = U60Repr::from(modulus.get_limbs_slice().as_array()); + let a_plus_modulus: BN = BN::from_slice(U60Repr::into(t0 + t2)); + let b_plus_modulus: BN = BN::from_slice(U60Repr::into(t1 + t2)); a_plus_modulus.assert_is_not_equal(b_plus_modulus); } @@ -623,7 +623,7 @@ type U256 = BN256; #[test] fn test_udiv_mod_U256() { let a: U256 = unsafe { BigNum::__derive_from_seed([1, 2, 3, 4]) }; - let b: U256 = BigNum::from_array([12, 0, 0]); + let b: U256 = BigNum::from_slice([12, 0, 0]); let (q, r) = a.udiv_mod(b); From aa944aa504d3870a1e673450104b1f6e261b9b01 Mon Sep 17 00:00:00 2001 From: Michael Connor Date: Sun, 3 Nov 2024 20:38:17 +0000 Subject: [PATCH 3/7] export bignum trait --- src/lib.nr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.nr b/src/lib.nr index 60b25d8d..43f8c3ab 100644 --- a/src/lib.nr +++ b/src/lib.nr @@ -16,6 +16,7 @@ pub(crate) mod utils; // Re-export the main structs so that users don't have to specify the paths pub use bignum::BigNum; +pub use bignum::BigNumTrait; // So that external code can operate on a generic BigNum, `where BigNum: BigNumTrait`. pub use runtime_bignum::RuntimeBigNum; // Tests From c3162ac752f7dd1973c81ea79bd703310340423a Mon Sep 17 00:00:00 2001 From: Michael Connor Date: Sun, 3 Nov 2024 20:46:59 +0000 Subject: [PATCH 4/7] fix --- src/bignum.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bignum.nr b/src/bignum.nr index 7994f8ee..dbb4e4fe 100644 --- a/src/bignum.nr +++ b/src/bignum.nr @@ -18,7 +18,7 @@ pub struct BigNum { pub limbs: [Field; N], } -pub(crate) trait BigNumTrait { +pub trait BigNumTrait { // TODO: this crashes the compiler? v0.32 // fn default() -> Self { std::default::Default::default () } pub fn new() -> Self; From 6fcc99059d1763c09d6d5ba7a0bb4f50255b34f3 Mon Sep 17 00:00:00 2001 From: Michael Connor Date: Sun, 3 Nov 2024 21:14:18 +0000 Subject: [PATCH 5/7] fmt --- src/bignum.nr | 33 +++++++++++++++++++++++---------- src/lib.nr | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/bignum.nr b/src/bignum.nr index dbb4e4fe..83f42275 100644 --- a/src/bignum.nr +++ b/src/bignum.nr @@ -227,17 +227,18 @@ 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())).map(|limbs| { - Self { limbs } - }) + __batch_invert::<_, MOD_BITS, _>(params, x.map(|bn| Self::get_limbs_slice(bn).as_array())) + .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::get_limbs_slice(bn).as_array())).map(|limbs| { - Self { limbs } - }) + __batch_invert_slice::<_, MOD_BITS>( + params, + x.map(|bn| Self::get_limbs_slice(bn).as_array()), + ) + .map(|limbs| { Self { limbs } }) } unconstrained fn __tonelli_shanks_sqrt(self) -> std::option::Option { @@ -257,9 +258,15 @@ 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::get_limbs_slice(bn).as_array())), + map( + lhs_terms, + |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + ), lhs_flags, - map(rhs_terms, |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array())), + map( + rhs_terms, + |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + ), rhs_flags, map(linear_terms, |bn| Self::get_limbs_slice(bn).as_array()), linear_flags, @@ -278,9 +285,15 @@ where let params = Params::get_params(); evaluate_quadratic_expression::<_, MOD_BITS, _, _, _, _>( params, - map(lhs_terms, |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array())), + map( + lhs_terms, + |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + ), lhs_flags, - map(rhs_terms, |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array())), + map( + rhs_terms, + |bns| map(bns, |bn| Self::get_limbs_slice(bn).as_array()), + ), rhs_flags, map(linear_terms, |bn| Self::get_limbs_slice(bn).as_array()), linear_flags, diff --git a/src/lib.nr b/src/lib.nr index 43f8c3ab..fa8840ff 100644 --- a/src/lib.nr +++ b/src/lib.nr @@ -16,7 +16,7 @@ pub(crate) mod utils; // Re-export the main structs so that users don't have to specify the paths pub use bignum::BigNum; -pub use bignum::BigNumTrait; // So that external code can operate on a generic BigNum, `where BigNum: BigNumTrait`. +pub use bignum::BigNumTrait; // So that external code can operate on a generic BigNum, `where BigNum: BigNumTrait`. pub use runtime_bignum::RuntimeBigNum; // Tests From f92c12ee1012e4c4679f00c3654f15228b7d30fd Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:34:08 +0000 Subject: [PATCH 6/7] Apply suggestions from code review --- src/bignum.nr | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/bignum.nr b/src/bignum.nr index 83f42275..699d9882 100644 --- a/src/bignum.nr +++ b/src/bignum.nr @@ -17,7 +17,8 @@ use crate::fns::{ pub struct BigNum { pub limbs: [Field; N], } - +// We aim to avoid needing to add a generic parameter to this trait, for this reason we do not allow +// accessing the limbs of the bignum except through slices. pub trait BigNumTrait { // TODO: this crashes the compiler? v0.32 // fn default() -> Self { std::default::Default::default () } @@ -26,7 +27,6 @@ pub trait BigNumTrait { pub fn derive_from_seed(seed: [u8; SeedBytes]) -> Self; pub unconstrained fn __derive_from_seed(seed: [u8; SeedBytes]) -> Self; pub fn from_slice(limbs: [Field]) -> Self; - // pub fn from_array(limbs: [Field; M]) -> Self; pub fn from_be_bytes(x: [u8; NBytes]) -> Self; pub fn to_le_bytes(self) -> [u8; NBytes]; @@ -34,7 +34,6 @@ pub trait BigNumTrait { pub fn modulus_bits(self) -> u32; pub fn num_limbs(self) -> u32; pub fn get_limbs_slice(self) -> [Field]; - // pub fn get_limbs(self) -> [Field; M]; pub fn get_limb(self, idx: u32) -> Field; pub fn set_limb(&mut self, idx: u32, value: Field); @@ -129,12 +128,6 @@ where Self { limbs: limbs.as_array() } } - // We avoid passing an array, because that would require the array length to be expressed as a generic param of BigNumTrait, and we don't want BigNumTrait to have any generic params, so that when we use BigNum, we can cleanly say `where BigNum: BigNumTrait`, without any extra generics being used. - // fn from_array(limbs: [Field; M]) -> Self { - // // This static assertion doesn't trick the compiler. - // std::static_assert(M == N, ""); - // Self { limbs } - // } fn from_be_bytes(x: [u8; NBytes]) -> Self { Self { limbs: from_be_bytes::<_, MOD_BITS, _>(x) } @@ -160,13 +153,6 @@ where self.limbs } - // We avoid returning an array, because that would require the array length to be expressed as a generic param of BigNumTrait, and we don't want BigNumTrait to have any generic params, so that when we use BigNum, we can cleanly say `where BigNum: BigNumTrait`, without any extra generics being used. - // fn get_limbs(self) -> [Field; M] { - // // This static assertion doesn't trick the compiler. - // std::static_assert(M == N, ""); - // self.limbs - // } - fn get_limb(self, idx: u32) -> Field { self.limbs[idx] } From d0acce765331dc17e6ef63873e5f804292d37820 Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 8 Nov 2024 11:36:38 +0000 Subject: [PATCH 7/7] fmt --- src/bignum.nr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bignum.nr b/src/bignum.nr index 699d9882..b50a02b2 100644 --- a/src/bignum.nr +++ b/src/bignum.nr @@ -128,7 +128,6 @@ where Self { limbs: limbs.as_array() } } - fn from_be_bytes(x: [u8; NBytes]) -> Self { Self { limbs: from_be_bytes::<_, MOD_BITS, _>(x) } } @@ -214,7 +213,7 @@ where 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())) - .map(|limbs| { Self { limbs } }) + .map(|limbs| Self { limbs }) } unconstrained fn __batch_invert_slice(x: [Self]) -> [Self] { @@ -224,7 +223,7 @@ where params, x.map(|bn| Self::get_limbs_slice(bn).as_array()), ) - .map(|limbs| { Self { limbs } }) + .map(|limbs| Self { limbs }) } unconstrained fn __tonelli_shanks_sqrt(self) -> std::option::Option {