pub struct SmallFq<P> {
p: P,
d: u32,
q: u32,
table: &'static [SmallFqElement],
}Expand description
A field of order q = p^d, where q < 2^16 and d > 1. Fields of that size are small enough
that we can cache their Zech logarithms.
Note: This populates the Zech logarithm table eagerly, which can be rather expensive (several milliseconds). Only construct these fields if you’re going to use them.
Fields§
§p: P§d: u32§q: u32§table: &'static [SmallFqElement]Implementations§
Source§impl<P: Prime> SmallFq<P>
impl<P: Prime> SmallFq<P>
pub fn new(p: P, d: u32) -> Self
Sourcepub fn negative_one(self) -> FieldElement<Self>
pub fn negative_one(self) -> FieldElement<Self>
Return the element -1. If p = 2, this is a^0 = 1. Otherwise, it is a^((q - 1) / 2).
Sourcepub fn a(self) -> FieldElement<Self>
pub fn a(self) -> FieldElement<Self>
The distinguished primitive element that generates the multiplicative group of the field.
Trait Implementations§
Source§impl<P: Prime> Arbitrary for SmallFq<P>
Available on crate feature proptest only.
impl<P: Prime> Arbitrary for SmallFq<P>
Available on crate feature
proptest only.Source§type Parameters = ()
type Parameters = ()
The type of parameters that
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<SmallFq<P>>
type Strategy = BoxedStrategy<SmallFq<P>>
The type of
Strategy used to generate values of type Self.Source§fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
Source§impl<P: Prime> Field for SmallFq<P>
impl<P: Prime> Field for SmallFq<P>
type Characteristic = P
fn characteristic(self) -> Self::Characteristic
fn degree(self) -> u32
fn q(self) -> u32
fn zero(self) -> FieldElement<Self>
fn one(self) -> FieldElement<Self>
fn arb_element(self) -> impl Strategy<Value = FieldElement<Self>>
Source§impl<P: Prime> FieldInternal for SmallFq<P>
impl<P: Prime> FieldInternal for SmallFq<P>
Source§fn encode(self, element: FieldElement<Self>) -> u64
fn encode(self, element: FieldElement<Self>) -> u64
This is 2n + 1 if element is a^n, and 0 otherwise.
Source§type ElementContainer = SmallFqElement
type ElementContainer = SmallFqElement
The internal representation of a field element.
Source§fn el(self, value: Self::ElementContainer) -> FieldElement<Self>
fn el(self, value: Self::ElementContainer) -> FieldElement<Self>
Create a new field element. This is the method responsible for ensuring that the returned
value is in a consistent state. For example, for a prime field of characteristic
p, this
function is responsible for ensuring that the FieldElement that is returned contains a
value in the range 0..p.fn add_assign(self, a: &mut FieldElement<Self>, b: FieldElement<Self>)
fn add(self, a: FieldElement<Self>, b: FieldElement<Self>) -> FieldElement<Self>
fn mul_assign(self, a: &mut FieldElement<Self>, b: FieldElement<Self>)
fn neg(self, a: FieldElement<Self>) -> FieldElement<Self>
fn inv(self, a: FieldElement<Self>) -> Option<FieldElement<Self>>
fn frobenius(self, a: FieldElement<Self>) -> FieldElement<Self>
Source§fn decode(self, element: u64) -> FieldElement<Self>
fn decode(self, element: u64) -> FieldElement<Self>
Decode a
Limb into a field element. The argument will always contain a single encoded
field element, padded with zeros. This is the inverse of encode.Source§fn bit_length(self) -> usize
fn bit_length(self) -> usize
Return the number of bits a
Self::Element occupies in a limb.Source§fn fma_limb(self, limb_a: u64, limb_b: u64, coeff: FieldElement<Self>) -> u64
fn fma_limb(self, limb_a: u64, limb_b: u64, coeff: FieldElement<Self>) -> u64
Fused multiply-add. Return the
Limb whose ith entry is limb_a[i] + coeff * limb_b[i].
Both limb_a and limb_b are assumed to be reduced, and the result does not have to be
reduced.fn sub_assign(self, a: &mut FieldElement<Self>, b: FieldElement<Self>)
fn sub(self, a: FieldElement<Self>, b: FieldElement<Self>) -> FieldElement<Self>
fn mul(self, a: FieldElement<Self>, b: FieldElement<Self>) -> FieldElement<Self>
fn div( self, a: FieldElement<Self>, b: FieldElement<Self>, ) -> Option<FieldElement<Self>>
Source§fn bitmask(self) -> u64
fn bitmask(self) -> u64
If
l is a limb of Self::Elements, then l & F.bitmask() is the value of the
first entry of l.Source§fn entries_per_limb(self) -> usize
fn entries_per_limb(self) -> usize
The number of
Self::Elements that fit in a single limb.fn limb_bit_index_pair(self, idx: usize) -> LimbBitIndexPair
Source§fn is_reduced(self, limb: u64) -> bool
fn is_reduced(self, limb: u64) -> bool
Check whether or not a limb is reduced. This may potentially not be faster than calling
reduce directly.Source§fn pack<T: Iterator<Item = FieldElement<Self>>>(self, entries: T) -> u64
fn pack<T: Iterator<Item = FieldElement<Self>>>(self, entries: T) -> u64
Given an interator of
FieldElement<Self>s, pack all of them into a single limb in order.
It is assumed that the values of the iterator fit into a single limb. If this assumption is
violated, the result will be nonsense.impl<P: Copy> Copy for SmallFq<P>
impl<P: Prime> Eq for SmallFq<P>
impl<P: Prime> MaybeArbitrary<()> for SmallFq<P>
Auto Trait Implementations§
impl<P> Freeze for SmallFq<P>where
P: Freeze,
impl<P> RefUnwindSafe for SmallFq<P>where
P: RefUnwindSafe,
impl<P> Send for SmallFq<P>where
P: Send,
impl<P> Sync for SmallFq<P>where
P: Sync,
impl<P> Unpin for SmallFq<P>where
P: Unpin,
impl<P> UnwindSafe for SmallFq<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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