SmallFq

Struct SmallFq 

Source
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>

Source

pub fn new(p: P, d: u32) -> Self

Source

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).

Source

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.
Source§

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>>

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

impl<P: Clone> Clone for SmallFq<P>

Source§

fn clone(&self) -> SmallFq<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Prime> Debug for SmallFq<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: Prime> Display for SmallFq<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: Prime> Field for SmallFq<P>

Source§

type Characteristic = P

Source§

fn characteristic(self) -> Self::Characteristic

Source§

fn degree(self) -> u32

Source§

fn q(self) -> u32

Source§

fn zero(self) -> FieldElement<Self>

Source§

fn one(self) -> FieldElement<Self>

Source§

fn arb_element(self) -> impl Strategy<Value = FieldElement<Self>>

Source§

impl<P: Prime> FieldInternal for SmallFq<P>

Source§

fn encode(self, element: FieldElement<Self>) -> u64

This is 2n + 1 if element is a^n, and 0 otherwise.

Source§

type ElementContainer = SmallFqElement

The internal representation of a field element.
Source§

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.
Source§

fn add_assign(self, a: &mut FieldElement<Self>, b: FieldElement<Self>)

Source§

fn add(self, a: FieldElement<Self>, b: FieldElement<Self>) -> FieldElement<Self>

Source§

fn mul_assign(self, a: &mut FieldElement<Self>, b: FieldElement<Self>)

Source§

fn neg(self, a: FieldElement<Self>) -> FieldElement<Self>

Source§

fn inv(self, a: FieldElement<Self>) -> Option<FieldElement<Self>>

Source§

fn frobenius(self, a: FieldElement<Self>) -> FieldElement<Self>

Source§

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

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

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.
Source§

fn reduce(self, limb: u64) -> u64

Reduce a limb, i.e. make it “canonical”. For example, in Fp, this replaces every entry by its value modulo p. Read more
Source§

fn sub_assign(self, a: &mut FieldElement<Self>, b: FieldElement<Self>)

Source§

fn sub(self, a: FieldElement<Self>, b: FieldElement<Self>) -> FieldElement<Self>

Source§

fn mul(self, a: FieldElement<Self>, b: FieldElement<Self>) -> FieldElement<Self>

Source§

fn div( self, a: FieldElement<Self>, b: FieldElement<Self>, ) -> Option<FieldElement<Self>>

Source§

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

The number of Self::Elements that fit in a single limb.
Source§

fn limb_bit_index_pair(self, idx: usize) -> LimbBitIndexPair

Source§

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

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.
Source§

fn unpack(self, limb: u64) -> LimbIterator<Self>

Give an iterator over the entries of limb.
Source§

fn number(self, dim: usize) -> usize

Return the number of limbs required to hold dim entries.
Source§

fn range(self, start: usize, end: usize) -> Range<usize>

Return the Range<usize> starting at the index of the limb containing the startth entry, and ending at the index of the limb containing the endth entry (including the latter).
Source§

fn truncate(self, sum: u64) -> Option<u64>

Return either Some(sum) if no carries happen in the limb, or None if some carry does happen.
Source§

impl<P: Prime> Hash for SmallFq<P>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<P: Prime> PartialEq for SmallFq<P>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: Copy> Copy for SmallFq<P>

Source§

impl<P: Prime> Eq for SmallFq<P>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V