use array::{
ArraySize,
typenum::{U1, U2, U3, U4, U5, U6, U7, U8, U16, U32, U64, Unsigned},
};
use ff::PrimeField;
use group::Group;
pub trait WindowSize: Unsigned {
type TableSize: ArraySize;
}
pub trait WnafGroup: Group {
fn recommended_wnaf_for_num_scalars(num_scalars: usize) -> usize;
}
pub trait WnafSize: PrimeField {
type StorageSize: ArraySize;
}
macro_rules! impl_window_sizes {
($($window_size:ty => $table_size:ty),+) => {
$(
impl WindowSize for $window_size {
type TableSize = $table_size;
}
)+
};
}
impl_window_sizes!(U2 => U1, U3 => U2, U4 => U4, U5 => U8, U6 => U16, U7 => U32, U8 => U64);
#[macro_export]
macro_rules! impl_wnaf_size_for_scalar {
($fe:ty) => {
impl $crate::WnafSize for $fe {
type StorageSize = $crate::array::typenum::U<{ (Self::NUM_BITS + 1) as usize }>;
}
};
}