Remove FieldExt bound from SqrtHasher generic argument

This commit is contained in:
Jack Grigg 2022-11-24 09:33:21 +00:00
parent 0559163953
commit 4c86de5e10

View file

@ -60,14 +60,14 @@ pub trait FieldExt: ff::PrimeField + Ord + Group<Scalar = Self> {
#[cfg(feature = "sqrt-table")] #[cfg(feature = "sqrt-table")]
#[cfg_attr(docsrs, doc(cfg(feature = "sqrt-table")))] #[cfg_attr(docsrs, doc(cfg(feature = "sqrt-table")))]
#[derive(Debug)] #[derive(Debug)]
struct SqrtHasher<F: FieldExt> { struct SqrtHasher<F: SqrtTableHelpers> {
hash_xor: u32, hash_xor: u32,
hash_mod: usize, hash_mod: usize,
marker: PhantomData<F>, marker: PhantomData<F>,
} }
#[cfg(feature = "sqrt-table")] #[cfg(feature = "sqrt-table")]
impl<F: FieldExt + SqrtTableHelpers> SqrtHasher<F> { impl<F: SqrtTableHelpers> SqrtHasher<F> {
/// Returns a perfect hash of x for use with SqrtTables::inv. /// Returns a perfect hash of x for use with SqrtTables::inv.
fn hash(&self, x: &F) -> usize { fn hash(&self, x: &F) -> usize {
// This is just the simplest constant-time perfect hash construction that could // This is just the simplest constant-time perfect hash construction that could
@ -82,7 +82,7 @@ impl<F: FieldExt + SqrtTableHelpers> SqrtHasher<F> {
#[cfg(feature = "sqrt-table")] #[cfg(feature = "sqrt-table")]
#[cfg_attr(docsrs, doc(cfg(feature = "sqrt-table")))] #[cfg_attr(docsrs, doc(cfg(feature = "sqrt-table")))]
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct SqrtTables<F: FieldExt> { pub(crate) struct SqrtTables<F: SqrtTableHelpers> {
hasher: SqrtHasher<F>, hasher: SqrtHasher<F>,
inv: Vec<u8>, inv: Vec<u8>,
g0: Box<[F; 256]>, g0: Box<[F; 256]>,
@ -92,7 +92,7 @@ pub(crate) struct SqrtTables<F: FieldExt> {
} }
#[cfg(feature = "sqrt-table")] #[cfg(feature = "sqrt-table")]
impl<F: FieldExt + SqrtTableHelpers> SqrtTables<F> { impl<F: SqrtTableHelpers> SqrtTables<F> {
/// Build tables given parameters for the perfect hash. /// Build tables given parameters for the perfect hash.
pub fn new(hash_xor: u32, hash_mod: usize) -> Self { pub fn new(hash_xor: u32, hash_mod: usize) -> Self {
use alloc::vec; use alloc::vec;