Trait PrimeFieldRepr

Source
pub trait PrimeFieldRepr:
    Sized
    + Copy
    + Clone
    + Eq
    + Ord
    + Send
    + Sync
    + Default
    + Debug
    + Display
    + 'static
    + Rand
    + AsRef<[u64]>
    + AsMut<[u64]>
    + From<u64>
    + Hash
    + Serialize
    + DeserializeOwned {
Show 14 methods // Required methods fn sub_noborrow(&mut self, other: &Self); fn add_nocarry(&mut self, other: &Self); fn num_bits(&self) -> u32; fn is_zero(&self) -> bool; fn is_odd(&self) -> bool; fn is_even(&self) -> bool; fn div2(&mut self); fn shr(&mut self, amt: u32); fn mul2(&mut self); fn shl(&mut self, amt: u32); // Provided methods fn write_be<W>(&self, writer: W) -> Result<(), Error> where W: Write { ... } fn read_be<R>(&mut self, reader: R) -> Result<(), Error> where R: Read { ... } fn write_le<W>(&self, writer: W) -> Result<(), Error> where W: Write { ... } fn read_le<R>(&mut self, reader: R) -> Result<(), Error> where R: Read { ... }
}
Expand description

This trait represents a wrapper around a biginteger which can encode any element of a particular prime field. It is a smart wrapper around a sequence of u64 limbs, least-significant digit first.

Required Methods§

Source

fn sub_noborrow(&mut self, other: &Self)

Subtract another represetation from this one.

Source

fn add_nocarry(&mut self, other: &Self)

Add another representation to this one.

Source

fn num_bits(&self) -> u32

Compute the number of bits needed to encode this number. Always a multiple of 64.

Source

fn is_zero(&self) -> bool

Returns true iff this number is zero.

Source

fn is_odd(&self) -> bool

Returns true iff this number is odd.

Source

fn is_even(&self) -> bool

Returns true iff this number is even.

Source

fn div2(&mut self)

Performs a rightwise bitshift of this number, effectively dividing it by 2.

Source

fn shr(&mut self, amt: u32)

Performs a rightwise bitshift of this number by some amount.

Source

fn mul2(&mut self)

Performs a leftwise bitshift of this number, effectively multiplying it by 2. Overflow is ignored.

Source

fn shl(&mut self, amt: u32)

Performs a leftwise bitshift of this number by some amount.

Provided Methods§

Source

fn write_be<W>(&self, writer: W) -> Result<(), Error>
where W: Write,

Writes this PrimeFieldRepr as a big endian integer.

Source

fn read_be<R>(&mut self, reader: R) -> Result<(), Error>
where R: Read,

Reads a big endian integer into this representation.

Source

fn write_le<W>(&self, writer: W) -> Result<(), Error>
where W: Write,

Writes this PrimeFieldRepr as a little endian integer.

Source

fn read_le<R>(&mut self, reader: R) -> Result<(), Error>
where R: Read,

Reads a little endian integer into this representation.

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 PrimeFieldRepr for pairing_ce::bls12_381::fq::FqRepr

Source§

impl PrimeFieldRepr for pairing_ce::bls12_381::fr::FrRepr

Source§

impl PrimeFieldRepr for pairing_ce::bn256::fq::FqRepr

Source§

impl PrimeFieldRepr for pairing_ce::bn256::fr::FrRepr