Trait pairing::PrimeFieldRepr
[−]
[src]
pub trait PrimeFieldRepr: Sized + Copy + Clone + Eq + Ord + Send + Sync + Default + Debug + Display + 'static + Rand + AsRef<[u64]> + AsMut<[u64]> + From<u64> { fn sub_noborrow(&mut self, other: &Self) -> bool; fn add_nocarry(&mut self, other: &Self) -> bool; 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 divn(&mut self, amt: u32); fn mul2(&mut self); fn muln(&mut self, amt: u32); fn write_be<W: Write>(&self, writer: W) -> Result<()> { ... } fn read_be<R: Read>(&mut self, reader: R) -> Result<()> { ... } }
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
fn sub_noborrow(&mut self, other: &Self) -> bool
Subtract another represetation from this one, returning the borrow bit.
fn add_nocarry(&mut self, other: &Self) -> bool
Add another representation to this one, returning the carry bit.
fn num_bits(&self) -> u32
Compute the number of bits needed to encode this number. Always a multiple of 64.
fn is_zero(&self) -> bool
Returns true iff this number is zero.
fn is_odd(&self) -> bool
Returns true iff this number is odd.
fn is_even(&self) -> bool
Returns true iff this number is even.
fn div2(&mut self)
Performs a rightwise bitshift of this number, effectively dividing it by 2.
fn divn(&mut self, amt: u32)
Performs a rightwise bitshift of this number by some amount.
fn mul2(&mut self)
Performs a leftwise bitshift of this number, effectively multiplying it by 2. Overflow is ignored.
fn muln(&mut self, amt: u32)
Performs a leftwise bitshift of this number by some amount.
Provided Methods
fn write_be<W: Write>(&self, writer: W) -> Result<()>
Writes this PrimeFieldRepr
as a big endian integer. Always writes
(num_bits
/ 8) bytes.
fn read_be<R: Read>(&mut self, reader: R) -> Result<()>
Reads a big endian integer occupying (num_bits
/ 8) bytes into this
representation.