SubgroupBase

Struct SubgroupBase 

Source
pub struct SubgroupBase<G: AbelianGroupStore> { /* private fields */ }
Available on crate feature 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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>

Source§

type Element = <<G as AbelianGroupStore>::Type as AbelianGroupBase>::Element

Available on crate feature unstable-enable only.
Type used to represent elements of this group.
Source§

fn clone_el(&self, x: &Self::Element) -> Self::Element

Available on crate feature unstable-enable only.
Clones an element of the group.
Source§

fn eq_el(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Available on crate feature unstable-enable only.
Checks whether two group elements are equal.
Source§

fn hash<H: Hasher>(&self, x: &Self::Element, hasher: &mut H)

Available on crate feature unstable-enable only.
Hashes the group element. Read more
Source§

fn identity(&self) -> Self::Element

Available on crate feature unstable-enable only.
Returns the identity element of the group, i.e. the unique element 1 such that x * 1 = x for all group elements x.
Source§

fn inv(&self, x: &Self::Element) -> Self::Element

Available on crate feature unstable-enable only.
Computes the inverse of the give element, i.e. the unique group element x^-1 such that x * x^-1 is the identity element.
Source§

fn is_identity(&self, x: &Self::Element) -> bool

Available on crate feature unstable-enable only.
Checks whether the given element is the identity element of the group. Read more
Source§

fn op(&self, lhs: Self::Element, rhs: Self::Element) -> Self::Element

Available on crate feature unstable-enable only.
Applies the group operation to two elements.
Source§

fn pow(&self, x: &Self::Element, e: &El<BigIntRing>) -> Self::Element

Available on crate feature unstable-enable only.
Raises a group element to the given power, i.e. computes x * x * ... * x, in total e times.
Source§

fn op_ref(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element

Available on crate feature unstable-enable only.
Applies the group operation to two elements. Read more
Source§

fn op_ref_snd(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element

Available on crate feature unstable-enable only.
Applies the group operation to two elements. Read more
Source§

impl<G> Clone for SubgroupBase<G>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'de, G: AbelianGroupStore + Clone + Deserialize<'de>> Deserialize<'de> for SubgroupBase<G>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<G: AbelianGroupStore> PartialEq for SubgroupBase<G>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<G: AbelianGroupStore + Serialize> Serialize for SubgroupBase<G>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,