pub trait ClassGroup: Sized + Clone + for<'a> MulAssign<&'a Self> + for<'a> Mul<&'a Self> + PartialEq + Debug {
    type BigNum: BigNum;

Show 16 methods 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) { ... }
}

Required Associated Types§

Required Methods§

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

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.

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.

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

Reduce self in-place.

Normalize self.

The length of num in bits

Gets the discriminant of self.

Replaces *self with its inverse.

Exponentiation

Deserialization

Provided Methods§

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.

Squares self, modifying it in-place.

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

Computes the identity element of a ClassGroup.

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.

Squares self repeatedly in-place.

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

Implementors§