pub trait Field: Ring + CommunicativeMul + MulIdentity + MulInverse {
    // Required methods
    fn hlv(self) -> Self;
    fn is_zero(&self) -> bool;
}
Expand description

This is a trait for field, a field is constructed from

  1. A Abelian Group over add
  2. A ring over multiplication and addition
  3. Multiplication should be communicative
  4. There must exists multiplicative inverse
  5. There must exists multiplicative identity (and different from additive identity)

TODO: find a way to constraint a field has different multiplicative identity and addition identity via type system.

Required Methods§

source

fn hlv(self) -> Self

calculate self / 2 in field

if self.is_even 
    return self >> 1
else 
    return (self + P) >> 1
source

fn is_zero(&self) -> bool

check if self is zero

Implementors§

source§

impl<I, M> Field for FpElement<I, M>where I: BigIntOpsExt, M: Montgomery<I>,