pub struct SubgroupBase<G: AbelianGroupStore> { /* private fields */ }unstable-enable only.Expand description
Represents a subgroup of an AbelianGroupBase by a set of generators.
Supports computing discrete logarithms, i.e. representing a given element
as a combination of the generators.
Note that the used algorithms have a worst case complexity of O(sqrt(ord^n))
where ord is the given multiple of the orders of each generator, and n
is the number of generators. However, if ord is smooth, much faster algorithms
are used.
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Implementations§
Source§impl<G: AbelianGroupStore> SubgroupBase<G>
impl<G: AbelianGroupStore> SubgroupBase<G>
Sourcepub fn parent(&self) -> &G
pub fn parent(&self) -> &G
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn subgroup_order(&self) -> El<BigIntRing>
pub fn subgroup_order(&self) -> El<BigIntRing>
The number of elements in the subgroup generated by this generating set.
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn order_multiple(&self) -> &El<BigIntRing>
pub fn order_multiple(&self) -> &El<BigIntRing>
Returns a multiple of the order of each element in the subgroup generated by this generating set.
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn generators(&self) -> &[GroupEl<G>] ⓘ
pub fn generators(&self) -> &[GroupEl<G>] ⓘ
Returns a set of generators of this subgroup.
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn add_generator(self, new_gen_base: GroupEl<G>) -> Self
pub fn add_generator(self, new_gen_base: GroupEl<G>) -> Self
Extends the generating set by an additional generator, which is likely to grow the represented subgroup.
The new generator must be of order dividing [GeneratingSet::order_multiple()].
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn contains(&self, element: &GroupEl<G>) -> bool
pub fn contains(&self, element: &GroupEl<G>) -> bool
Returns true if the given element is contained in this subgroup.
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn dlog(&self, target: &GroupEl<G>) -> Option<Vec<i64>>
pub fn dlog(&self, target: &GroupEl<G>) -> Option<Vec<i64>>
Computes a discrete logarithm of target w.r.t. the stored set
if generators, or None if target is not in the subgroup generated by
these generators
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn rectangular_form<'a>(&'a self) -> Vec<(GroupEl<G>, usize)>
pub fn rectangular_form<'a>(&'a self) -> Vec<(GroupEl<G>, usize)>
Returns a list (g[i], l[i]) such that every element of the subgroup
can be uniquely written as prod_i g[i]^k[i] with 0 <= k[i] < l[i].
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn enumerate_elements<'a>(
&'a self,
) -> impl use<'a, G> + Clone + Iterator<Item = GroupEl<G>>
pub fn enumerate_elements<'a>( &'a self, ) -> impl use<'a, G> + Clone + Iterator<Item = GroupEl<G>>
Returns an iterator that yields every element contained in the subgroup exactly once.
§Availability
This API is marked as unstable and is only available when the unstable-enable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Trait Implementations§
Source§impl<G: AbelianGroupStore> AbelianGroupBase for SubgroupBase<G>
impl<G: AbelianGroupStore> AbelianGroupBase for SubgroupBase<G>
Source§type Element = <<G as AbelianGroupStore>::Type as AbelianGroupBase>::Element
type Element = <<G as AbelianGroupStore>::Type as AbelianGroupBase>::Element
unstable-enable only.Source§fn clone_el(&self, x: &Self::Element) -> Self::Element
fn clone_el(&self, x: &Self::Element) -> Self::Element
unstable-enable only.Source§fn eq_el(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool
fn eq_el(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool
unstable-enable only.Source§fn hash<H: Hasher>(&self, x: &Self::Element, hasher: &mut H)
fn hash<H: Hasher>(&self, x: &Self::Element, hasher: &mut H)
unstable-enable only.Source§fn identity(&self) -> Self::Element
fn identity(&self) -> Self::Element
unstable-enable only.1 such that
x * 1 = x for all group elements x.Source§fn inv(&self, x: &Self::Element) -> Self::Element
fn inv(&self, x: &Self::Element) -> Self::Element
unstable-enable only.x^-1 such that
x * x^-1 is the identity element.Source§fn is_identity(&self, x: &Self::Element) -> bool
fn is_identity(&self, x: &Self::Element) -> bool
unstable-enable only.Source§fn op(&self, lhs: Self::Element, rhs: Self::Element) -> Self::Element
fn op(&self, lhs: Self::Element, rhs: Self::Element) -> Self::Element
unstable-enable only.Source§fn pow(&self, x: &Self::Element, e: &El<BigIntRing>) -> Self::Element
fn pow(&self, x: &Self::Element, e: &El<BigIntRing>) -> Self::Element
unstable-enable only.x * x * ... * x,
in total e times.Source§impl<G> Clone for SubgroupBase<G>where
G: Clone + AbelianGroupStore,
impl<G> Clone for SubgroupBase<G>where
G: Clone + AbelianGroupStore,
Source§impl<'de, G: AbelianGroupStore + Clone + Deserialize<'de>> Deserialize<'de> for SubgroupBase<G>where
G::Type: SerializableElementGroup,
impl<'de, G: AbelianGroupStore + Clone + Deserialize<'de>> Deserialize<'de> for SubgroupBase<G>where
G::Type: SerializableElementGroup,
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<G: AbelianGroupStore> PartialEq for SubgroupBase<G>
impl<G: AbelianGroupStore> PartialEq for SubgroupBase<G>
Source§impl<G: AbelianGroupStore + Serialize> Serialize for SubgroupBase<G>where
G::Type: SerializableElementGroup,
impl<G: AbelianGroupStore + Serialize> Serialize for SubgroupBase<G>where
G::Type: SerializableElementGroup,
Auto Trait Implementations§
impl<G> Freeze for SubgroupBase<G>where
G: Freeze,
impl<G> RefUnwindSafe for SubgroupBase<G>where
G: RefUnwindSafe,
<<G as AbelianGroupStore>::Type as AbelianGroupBase>::Element: RefUnwindSafe,
impl<G> Send for SubgroupBase<G>
impl<G> Sync for SubgroupBase<G>
impl<G> Unpin for SubgroupBase<G>
impl<G> UnwindSafe for SubgroupBase<G>
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> 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