pub trait Field:
FieldAlgebra<F = Self>
+ Packable
+ 'static
+ Copy
+ Div<Self, Output = Self>
+ Eq
+ Hash
+ Send
+ Sync
+ Display
+ Serialize
+ DeserializeOwned {
type Packing: PackedField<Scalar = Self>;
const GENERATOR: Self;
// Required methods
fn try_inverse(&self) -> Option<Self>;
fn order() -> BigUint;
// Provided methods
fn is_zero(&self) -> bool { ... }
fn is_one(&self) -> bool { ... }
fn div_2exp_u64(&self, exp: u64) -> Self { ... }
fn exp_u64_generic<FA: FieldAlgebra<F = Self>>(val: FA, power: u64) -> FA { ... }
fn inverse(&self) -> Self { ... }
fn halve(&self) -> Self { ... }
fn multiplicative_group_factors() -> Vec<(BigUint, usize)> { ... }
fn bits() -> usize { ... }
}
Expand description
An element of a finite field.
Required Associated Constants§
Required Associated Types§
type Packing: PackedField<Scalar = Self>
Required Methods§
Sourcefn try_inverse(&self) -> Option<Self>
fn try_inverse(&self) -> Option<Self>
The multiplicative inverse of this field element, if it exists.
NOTE: The inverse of 0
is undefined and will return None
.
fn order() -> BigUint
Provided Methods§
fn is_zero(&self) -> bool
fn is_one(&self) -> bool
Sourcefn div_2exp_u64(&self, exp: u64) -> Self
fn div_2exp_u64(&self, exp: u64) -> Self
self / 2^exp
Sourcefn exp_u64_generic<FA: FieldAlgebra<F = Self>>(val: FA, power: u64) -> FA
fn exp_u64_generic<FA: FieldAlgebra<F = Self>>(val: FA, power: u64) -> FA
Exponentiation by a u64
power. This is similar to exp_u64
, but more general in that it
can be used with FieldAlgebra
s, not just this concrete field.
The default implementation uses naive square and multiply. Implementations may want to override this and handle certain powers with more optimal addition chains.
fn inverse(&self) -> Self
Sourcefn halve(&self) -> Self
fn halve(&self) -> Self
Computes input/2. Should be overwritten by most field implementations to use bitshifts. Will error if the field characteristic is 2.
Sourcefn multiplicative_group_factors() -> Vec<(BigUint, usize)>
fn multiplicative_group_factors() -> Vec<(BigUint, usize)>
A list of (factor, exponent) pairs.
fn bits() -> usize
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.