Expand description
A framework for finite fields.
Modules§
- coset
- exponentiation
- extension
- integers
- A collection of traits and macros which convert primitive integer types into field elements.
Macros§
- impl_
raw_ serializable_ primefield32 - A simple macro which allows us to implement the
RawSerializabletrait for any 32-bit field. The field must implement PrimeField32. - impl_
raw_ serializable_ primefield64 - A simple macro which allows us to implement the
RawSerializabletrait for any 64-bit field. The field must implement PrimeField64 (and should not implement PrimeField32). - quotient_
map_ large_ iint - For large signed integer types, a simple method which is usually good enough is to simply check the sign and use this to pass to the equivalent unsigned method.
- quotient_
map_ large_ uint - If the unsigned integer type is large enough, there is often no method better for
from_intthan just doing a modular reduction to a smaller type. - quotient_
map_ small_ int - If the integer type is smaller than the field order all possible inputs are canonical.
In such a case we can easily implement
QuotientMap<SmallInt>as all three methods will coincide. - quotient_
map_ small_ internals - This allows us to avoid some duplication which arises when working with fields which contain a generic parameter.
Structs§
- Field
Array - Powers
- An iterator which returns the powers of a base element
bshifted by currentc:c, c * b, c * b^2, ....
Traits§
- Algebra
- A ring
RimplementsAlgebra<F>if there is an injective homomorphism fromFintoR; in particular onlyF::ZEROmaps toR::ZERO. - Based
Vector Space - A vector space
VoverFwith a fixed basis. Fixing the basis allows elements ofVto be converted to and fromDIMENSIONmany elements ofFwhich are interpreted as basis coefficients. - Extension
Field - A field
EFwhich is also an algebra over a fieldF. - Field
- A field
F. This permits both modular fieldsℤ/palong with their field extensions. - Injective
Monomial - A ring implements
InjectiveMonomial<N>if the algebraic functionf(x) = x^Nis an injective map on elements of the ring. - Packable
- A trait to constrain types that can be packed into a packed value.
- Packed
Field - An array of field elements which can be packed into a vector for SIMD operations.
- Packed
Field Extension - Fix a field
Fa packing widthWand an extension fieldEFofF. - Packed
Field Pow2 - Safety
- Packed
Value - A trait for array-like structs made up of multiple scalar elements.
- Permutation
Monomial - A ring implements
PermutationMonomial<N>if the algebraic functionf(x) = x^Nis invertible and thus acts as a permutation on elements of the ring. - Prime
Characteristic Ring - A commutative ring,
R, with prime characteristic,p. - Prime
Field - A field isomorphic to
ℤ/pfor some primep. - Prime
Field32 - A prime field
ℤ/pwith orderp < 2^32. - Prime
Field64 - A prime field
ℤ/pwith order,p < 2^64. - RawData
Serializable - A collection of methods designed to help hash field elements.
- TwoAdic
Field - A field which supplies information like the two-adicity of its multiplicative group, and methods for obtaining two-adic generators.
Functions§
- add_
scaled_ slice_ in_ place - Adds
other, scaled bys, to the mutablesliceusing packing, orslice += other * s. - batch_
multiplicative_ inverse - Batch multiplicative inverses with Montgomery’s trick This is Montgomery’s trick. At a high level, we invert the product of the given field elements, then derive the individual inverses from that via multiplication.
- cyclic_
subgroup_ coset_ known_ order - Computes a coset of a multiplicative subgroup whose order is known in advance.
- cyclic_
subgroup_ known_ order - Computes a multiplicative subgroup whose order is known in advance.
- dot_
product - Maximally generic dot product.
- field_
to_ array - Extend a ring
Relementxto an array of lengthDby filling zeros. - halve_
u32 - Given an element x from a 32 bit field F_P compute x/2.
- halve_
u64 - Given an element x from a 64 bit field F_P compute x/2.
- par_
add_ scaled_ slice_ in_ place - Adds
other, scaled bys, to the mutablesliceusing packing, orslice += other * s. - par_
scale_ slice_ in_ place - Scales each element of the slice by
susing packing and parallelization. - reduce_
32 - Reduce a slice of 32-bit field elements into a single element of a larger field.
- scale_
slice_ in_ place Deprecated - This function is deprecated. It is currently a wrapper for
par_scale_slice_in_place, which it should be replaced with if parallelization is required. - scale_
slice_ in_ place_ single_ core - Scales each element of the slice by
susing packing. - split_
32 - Split a large field element into
nbase-$2^{64}$ chunks and map each into a 32-bit field.