Trait ClassGroup

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

Show 16 methods // Required 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; // Provided methods 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§

Source

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

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

Source

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.

Source

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.

Source

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

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

Source

fn reduce(&mut self)

Reduce self in-place.

Source

fn normalize(&mut self)

Normalize self.

Source

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

The length of num in bits

Source

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

Gets the discriminant of self.

Source

fn inverse(&mut self)

Replaces *self with its inverse.

Source

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

Exponentiation

Source

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

Deserialization

Provided Methods§

Source

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.

Source

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.

Source

fn identity(&self) -> Self

Computes the identity element of a ClassGroup.

Source

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.

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§