diff --git a/src/lib.rs b/src/lib.rs index cba3af3a..b2396d7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,6 @@ pub mod secp256k1; pub mod secp256r1; pub mod secq256k1; -pub mod utils; - #[macro_use] mod derive; diff --git a/src/secp256r1/fq.rs b/src/secp256r1/fq.rs index 86005d35..d611097e 100644 --- a/src/secp256r1/fq.rs +++ b/src/secp256r1/fq.rs @@ -118,7 +118,7 @@ const ZETA: Fq = Fq::from_raw([ const DELTA: Fq = Fq::from_raw([0x1e39a5057d81, 0, 0, 0]); use crate::{ - field_arithmetic, field_common, field_specific, impl_add_binop_specify_output, + field_arithmetic, field_bits, field_common, field_specific, impl_add_binop_specify_output, impl_binops_additive, impl_binops_additive_specify_output, impl_binops_multiplicative, impl_binops_multiplicative_mixed, impl_from_u64, impl_sub_binop_specify_output, impl_sum_prod, }; @@ -141,6 +141,11 @@ impl_from_u64!(Fq, R2); field_arithmetic!(Fq, MODULUS, INV, dense); impl_sum_prod!(Fq); +#[cfg(target_pointer_width = "64")] +field_bits!(Fq, MODULUS); +#[cfg(not(target_pointer_width = "64"))] +field_bits!(Fq, MODULUS, MODULUS_LIMBS_32); + impl Fq { pub const fn size() -> usize { 32 diff --git a/src/tests/curve.rs b/src/tests/curve.rs index 32c61aa3..9554e875 100644 --- a/src/tests/curve.rs +++ b/src/tests/curve.rs @@ -3,10 +3,13 @@ use crate::ff::Field; use crate::ff_ext::Legendre; use crate::group::prime::PrimeCurveAffine; -use crate::utils::fe_from_str; use crate::{group::GroupEncoding, serde::SerdeObject}; use crate::{hash_to_curve, CurveAffine, CurveExt}; +use ff::PrimeField; +use num_bigint::BigUint; +use num_traits::Num; use rand_core::{OsRng, RngCore}; +use std::borrow::Cow; use std::iter; #[cfg(feature = "derive_serde")] @@ -352,6 +355,16 @@ pub fn hash_to_curve_test() { } } +fn fe_from_str(string: impl AsRef) -> F { + let string = string.as_ref(); + let oct = if let Some(hex) = string.strip_prefix("0x") { + Cow::Owned(BigUint::from_str_radix(hex, 16).unwrap().to_string()) + } else { + Cow::Borrowed(string) + }; + F::from_str_vartime(&oct).unwrap() +} + pub fn svdw_map_to_curve_test( z: G::Base, precomputed_constants: [&'static str; 4], diff --git a/src/utils.rs b/src/utils.rs deleted file mode 100644 index 3b595672..00000000 --- a/src/utils.rs +++ /dev/null @@ -1,14 +0,0 @@ -use ff::PrimeField; -use num_bigint::BigUint; -use num_traits::Num; -use std::borrow::Cow; - -pub(crate) fn fe_from_str(string: impl AsRef) -> F { - let string = string.as_ref(); - let oct = if let Some(hex) = string.strip_prefix("0x") { - Cow::Owned(BigUint::from_str_radix(hex, 16).unwrap().to_string()) - } else { - Cow::Borrowed(string) - }; - F::from_str_vartime(&oct).unwrap() -}