pub struct HypercubeStructure { /* private fields */ }Expand description
Represents a hypercube, which is a map
h: { 0, ..., m1 - 1 } x ... x { 0, ..., mr - 1 } -> (Z/nZ)^*
a1, ..., ar -> prod_i gi^aisuch that the composition (mod <p>) ∘ h is a bijection.
We use the following notation:
nandpas abovedis the order of<p>as subgroup of(Z/nZ)*miis the length of thei-th “hypercube dimension” as abovegiis the generator of thei-th hypercube dimension
Implementations§
Source§impl HypercubeStructure
impl HypercubeStructure
pub fn new( galois_group: CyclotomicGaloisGroup, p: CyclotomicGaloisGroupEl, d: usize, ms: Vec<usize>, gs: Vec<CyclotomicGaloisGroupEl>, ) -> Self
Sourcepub fn halevi_shoup_hypercube(
galois_group: CyclotomicGaloisGroup,
p: i64,
) -> Self
pub fn halevi_shoup_hypercube( galois_group: CyclotomicGaloisGroup, p: i64, ) -> Self
Computes “the” Halevi-Shoup hypercube as described in https://ia.cr/2014/873.
Note that the Halevi-Shoup hypercube is unique except for the ordering of prime
factors of n. This function uses a deterministic but unspecified ordering.
Sourcepub fn map_1d(&self, dim_idx: usize, steps: i64) -> CyclotomicGaloisGroupEl
pub fn map_1d(&self, dim_idx: usize, steps: i64) -> CyclotomicGaloisGroupEl
Applies the hypercube structure map to the unit vector multiple steps * e_(dim_idx),
i.e. computes the galois automorphism corresponding to the shift by steps steps
along the dim_idx-th hypercube dimension.
Sourcepub fn map(&self, idxs: &[i64]) -> CyclotomicGaloisGroupEl
pub fn map(&self, idxs: &[i64]) -> CyclotomicGaloisGroupEl
Applies the hypercube structure map to the given vector.
It is not enforced that the entries of the vector are contained in
{ 0, ..., m1 - 1 } x ... x { 0, ..., mr - 1 }, for values outside this
range the natural extension of h to Z^r is used, i.e.
h: Z^r -> (Z/nZ)^*
a1, ..., ar -> prod_i gi^aiSourcepub fn map_usize(&self, idxs: &[usize]) -> CyclotomicGaloisGroupEl
pub fn map_usize(&self, idxs: &[usize]) -> CyclotomicGaloisGroupEl
Same as HypercubeStructure::map(), but for a vector with
unsigned entries.
Sourcepub fn std_preimage(&self, g: CyclotomicGaloisGroupEl) -> &[usize]
pub fn std_preimage(&self, g: CyclotomicGaloisGroupEl) -> &[usize]
Computes the “standard preimage” of the given g under h.
This is the vector (a0, a1, ..., ar) such that g = p^a0 h(a1, ..., ar) and
each ai is within { 0, ..., mi - 1 }.
Sourcepub fn is_tensor_product_compatible(&self) -> bool
pub fn is_tensor_product_compatible(&self) -> bool
Returns whether each dimension of the hypercube corresponds to a factor ni of
n (with ni coprime to n/ni). This is the case for the Halevi-Shoup hypercube,
and very useful in some situations. If this is the case, you can query the factor
of n corresponding to some dimension by HypercubeStructure::factor_of_n().
Sourcepub fn factor_of_n(&self, dim_idx: usize) -> Option<i64>
pub fn factor_of_n(&self, dim_idx: usize) -> Option<i64>
Returns the factor ni of n (coprime to n/ni) which the i-th hypercube
dimension corresponds to. This is only applicable if the hypercube was constructed
from a (partial) factorization of n, i.e. HypercubeStructure::is_tensor_product_compatible()
returns true. Otherwise, this function will return None.
Sourcepub fn p(&self) -> CyclotomicGaloisGroupEl
pub fn p(&self) -> CyclotomicGaloisGroupEl
Returns p as an element of (Z/nZ)*.
Sourcepub fn frobenius(&self, power: i64) -> CyclotomicGaloisGroupEl
pub fn frobenius(&self, power: i64) -> CyclotomicGaloisGroupEl
Returns the Galois automorphism corresponding to the power-of-p^power
frobenius automorphism of the slot ring.
Sourcepub fn g(&self, i: usize) -> CyclotomicGaloisGroupEl
pub fn g(&self, i: usize) -> CyclotomicGaloisGroupEl
Returns the generator gi corresponding to the i-th hypercube dimension.
Sourcepub fn n(&self) -> usize
pub fn n(&self) -> usize
Returns n, i.e. the multiplicative order of the root of unity of the main ring.
Sourcepub fn galois_group(&self) -> &CyclotomicGaloisGroup
pub fn galois_group(&self) -> &CyclotomicGaloisGroup
Returns the Galois group isomorphic to (Z/nZ)* that this hypercube
describes.
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Returns the number of elements of { 0, ..., m1 - 1 } x ... x { 0, ..., mr - 1 }
or equivalently (Z/nZ)*/<p>, which is equal to the to the number of slots of
Fp[X]/(Phi_n(X)).
Sourcepub fn hypercube_iter<'b, G, T>(
&'b self,
for_slot: G,
) -> impl ExactSizeIterator<Item = T> + use<'b, G, T>
pub fn hypercube_iter<'b, G, T>( &'b self, for_slot: G, ) -> impl ExactSizeIterator<Item = T> + use<'b, G, T>
Creates an iterator that yields a value for each element of { 0, ..., m1 - 1 } x ... x { 0, ..., mr - 1 }
resp. (Z/nZ)*/<p>. Hence, these elements correspond to the slots of Fp[X]/(Phi_n(X)).
The given closure will be called on each element of { 0, ..., m1 - 1 } x ... x { 0, ..., mr - 1 }.
The returned iterator will iterate over the results of the closure.
Sourcepub fn element_iter<'b>(
&'b self,
) -> impl ExactSizeIterator<Item = CyclotomicGaloisGroupEl> + use<'b>
pub fn element_iter<'b>( &'b self, ) -> impl ExactSizeIterator<Item = CyclotomicGaloisGroupEl> + use<'b>
Creates an iterator that one representative of each element of (Z/nZ)*/<p>, which
also is in the image of this hypercube structure.
The order is compatible with HypercubeStructure::hypercube_iter().
Trait Implementations§
Source§impl Clone for HypercubeStructure
impl Clone for HypercubeStructure
Source§fn clone(&self) -> HypercubeStructure
fn clone(&self) -> HypercubeStructure
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de> Deserialize<'de> for HypercubeStructure
impl<'de> Deserialize<'de> for HypercubeStructure
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl PartialEq for HypercubeStructure
impl PartialEq for HypercubeStructure
Auto Trait Implementations§
impl Freeze for HypercubeStructure
impl RefUnwindSafe for HypercubeStructure
impl Send for HypercubeStructure
impl Sync for HypercubeStructure
impl Unpin for HypercubeStructure
impl UnwindSafe for HypercubeStructure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more