[][src]Trait classygroup::ClassGroup

pub trait ClassGroup: Sized + Clone + for<'a> MulAssign<&'a Self> + for<'a> Mul<&'a Self> + PartialEq + Debug {
    type BigNum: BigNum;
    fn from_ab_discriminant(
        a: Self::BigNum,
        b: Self::BigNum,
        discriminant: Self::BigNum
    ) -> Self;
fn from_bytes(bytearray: &[u8], discriminant: Self::BigNum) -> Self;
fn serialize(&self, buf: &mut [u8]) -> Result<(), usize>;
fn unsigned_deserialize_bignum(_: &[u8]) -> Self::BigNum;
fn reduce(&mut self);
fn normalize(&mut self);
fn size_in_bits(num: &Self::BigNum) -> usize;
fn discriminant(&self) -> &Self::BigNum;
fn inverse(&mut self);
fn pow(&mut self, exponent: Self::BigNum);
fn deserialize(buf: &[u8], discriminant: Self::BigNum) -> Self; fn identity_for_discriminant(discriminant: Self::BigNum) -> Self { ... }
fn square(&mut self) { ... }
fn identity(&self) -> Self { ... }
fn generator_for_discriminant(discriminant: Self::BigNum) -> Self { ... }
fn repeated_square(&mut self, iterations: u64) { ... } }

Associated Types

Loading content...

Required methods

fn from_ab_discriminant(
    a: Self::BigNum,
    b: Self::BigNum,
    discriminant: Self::BigNum
) -> Self

Produces a Self from a, b, and a discriminant.

fn from_bytes(bytearray: &[u8], discriminant: Self::BigNum) -> Self

Unmarshals a Self from a byte array and discriminant.

The byte array will be in the format of two big-endian byte sequences concatenated together.

fn serialize(&self, buf: &mut [u8]) -> Result<(), usize>

Serializes self to a byte array. Returns Err(s) if there is not enough space in the buffer.

The data must be serialized in twos-complement, big-endian format.

fn unsigned_deserialize_bignum(_: &[u8]) -> Self::BigNum

Deserializes a bignum from raw bytes. The bytes must be interpreted as a big-endian unsigned integer.

fn reduce(&mut self)

Reduce self in-place.

fn normalize(&mut self)

Normalize self.

fn size_in_bits(num: &Self::BigNum) -> usize

The length of num in bits

fn discriminant(&self) -> &Self::BigNum

Gets the discriminant of self.

fn inverse(&mut self)

Replaces *self with its inverse.

fn pow(&mut self, exponent: Self::BigNum)

Exponentiation

fn deserialize(buf: &[u8], discriminant: Self::BigNum) -> Self

Deserialization

Loading content...

Provided methods

fn identity_for_discriminant(discriminant: Self::BigNum) -> Self

Computes the identity element of Self for a given discriminant.

If the discriminant is not valid, the result is unspecified.

Panics

This may panic (but is not required to) if the discriminant is not valid. If this function does not panic, the results of future operations are unspecified: they will not invoke undefined behavior, but may panic, loop forever, or just compute garbage.

In debug builds, this will always panic if the discriminant is invalid.

fn square(&mut self)

Squares self, modifying it in-place.

A default implementation is provided, but implementations are suggested to override it for performance reasons.

fn identity(&self) -> Self

Computes the identity element of a ClassGroup.

fn generator_for_discriminant(discriminant: Self::BigNum) -> Self

Generates a generator for the class group of Self, given a discriminant.

If the discriminant is not valid, the result is unspecified.

Relation to Self::identity_for_discriminant

This is not the same as Self::identity_for_discriminant: the identity element is never a generator for any group. This follows from their definitions: the identity element, when multiplied by another element, always gives that other element, whereas every element in the group is some power of a generator.

Panics

This may panic (but is not required to) if the discriminant is not valid. If this function does not panic, the results of future operations are unspecified: they will not invoke undefined behavior, but may panic, loop forever, or just compute garbage.

If the global allocator panics on running out of memory, then this function may panic in the same situation, but it may also just abort the program instead.

In debug builds, this will always panic if the discriminant is invalid.

fn repeated_square(&mut self, iterations: u64)

Squares self repeatedly in-place.

Implementors of this trait are encouraged to override this with a more efficient implementation, if one exists.

Loading content...

Implementors

impl ClassGroup for GmpClassGroup[src]

type BigNum = Mpz

fn normalize(&mut self)[src]

Normalize self.

Panics

Panics if called within a call to Self::with_context.

fn discriminant(&self) -> &Self::BigNum[src]

Returns the discriminant of self.

fn reduce(&mut self)[src]

Reduce self.

Panics

Panics if called within a call to Self::with_context.

fn square(&mut self)[src]

Square self.ClassGroupPartial

Panics

Panics if called within the scope of a call to with_context.

fn repeated_square(&mut self, iterations: u64)[src]

Square self iterations times.

Panics

Panics if called within the scope of a call to with_context.

fn identity_for_discriminant(discriminant: Self::BigNum) -> Self[src]

fn identity(&self) -> Self[src]

Loading content...