zksync_pairing

Trait PrimeField

Source
pub trait PrimeField: Field {
    type Repr: PrimeFieldRepr + From<Self>;

    const NUM_BITS: u32;
    const CAPACITY: u32;
    const S: u32;

    // Required methods
    fn from_repr(repr: Self::Repr) -> Result<Self, PrimeFieldDecodingError>;
    fn from_raw_repr(repr: Self::Repr) -> Result<Self, PrimeFieldDecodingError>;
    fn into_repr(&self) -> Self::Repr;
    fn into_raw_repr(&self) -> Self::Repr;
    fn char() -> Self::Repr;
    fn multiplicative_generator() -> Self;
    fn root_of_unity() -> Self;

    // Provided method
    fn from_str(s: &str) -> Option<Self> { ... }
}
Expand description

This represents an element of a prime field.

Required Associated Constants§

Source

const NUM_BITS: u32

How many bits are needed to represent an element of this field.

Source

const CAPACITY: u32

How many bits of information can be reliably stored in the field element.

Source

const S: u32

2^s * t = char() - 1 with t odd.

Required Associated Types§

Source

type Repr: PrimeFieldRepr + From<Self>

The prime field can be converted back and forth into this biginteger representation.

Required Methods§

Source

fn from_repr(repr: Self::Repr) -> Result<Self, PrimeFieldDecodingError>

Convert this prime field element into a biginteger representation.

Source

fn from_raw_repr(repr: Self::Repr) -> Result<Self, PrimeFieldDecodingError>

Creates an element from raw representation in Montgommery form.

Source

fn into_repr(&self) -> Self::Repr

Convert a biginteger representation into a prime field element, if the number is an element of the field.

Source

fn into_raw_repr(&self) -> Self::Repr

Expose Montgommery represendation.

Source

fn char() -> Self::Repr

Returns the field characteristic; the modulus.

Source

fn multiplicative_generator() -> Self

Returns the multiplicative generator of char() - 1 order. This element must also be quadratic nonresidue.

Source

fn root_of_unity() -> Self

Returns the 2^s root of unity computed by exponentiating the multiplicative_generator() by t.

Provided Methods§

Source

fn from_str(s: &str) -> Option<Self>

Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string.

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§

Source§

impl PrimeField for zksync_pairing::bls12_381::fq::Fq

Source§

const NUM_BITS: u32 = 381u32

Source§

const CAPACITY: u32 = 380u32

Source§

const S: u32 = 1u32

Source§

type Repr = FqRepr

Source§

impl PrimeField for zksync_pairing::bls12_381::fr::Fr

Source§

const NUM_BITS: u32 = 255u32

Source§

const CAPACITY: u32 = 254u32

Source§

const S: u32 = 32u32

Source§

type Repr = FrRepr

Source§

impl PrimeField for zksync_pairing::bn256::fq::Fq

Source§

const NUM_BITS: u32 = 254u32

Source§

const CAPACITY: u32 = 253u32

Source§

const S: u32 = 1u32

Source§

type Repr = FqRepr

Source§

impl PrimeField for zksync_pairing::bn256::fr::Fr

Source§

const NUM_BITS: u32 = 254u32

Source§

const CAPACITY: u32 = 253u32

Source§

const S: u32 = 28u32

Source§

type Repr = FrRepr