Trait salty::FieldImplementation[][src]

pub trait FieldImplementation where
    Self: Copy,
    Self: Debug,
    Self: ConditionallySelectable,
    Self: ConstantTimeEq,
    Self: PartialEq,
    &'a Self: Add<&'b Self, Output = Self>,
    Self: AddAssign<&'b Self>,
    &'a Self: Neg<Output = Self>,
    &'a Self: Sub<&'b Self, Output = Self>,
    Self: SubAssign<&'b Self>,
    &'a Self: Mul<&'b Self, Output = Self>,
    Self: MulAssign<&'b Self>, 
{ type Limbs; const ZERO: Self; const ONE: Self; const D: Self; const D2: Self; const APLUS2_OVER_FOUR: Self; const EDWARDS_BASEPOINT_X: Self; const EDWARDS_BASEPOINT_Y: Self; const I: Self; const MONTGOMERY_BASEPOINT_U: Self; fn to_bytes(&self) -> [u8; 32];
fn from_bytes_unchecked(bytes: &[u8; 32]) -> Self;
fn inverse(&self) -> Self;
fn pow2523(&self) -> Self; fn from_unreduced_bytes(bytes: &[u8; 32]) -> Self { ... }
fn from_bytes(bytes: &[u8; 32]) -> Result<Self> { ... }
fn parity(&self) -> u8 { ... }
fn squared(&self) -> Self { ... } }

Requirements on an implementation of the base field.

There are many ways to implement field arithmetic in the base field of integers modulo 2**255 - 19.

This trait specifies our requirements, such that end users can experiment with their own ideas.

This crate, as of now, offers two implementations:

  • TweetNaCl: a transliteration of the TweetNaCl code to Rust
  • Haase: a fast implementation in assembly, due to Bjoern Haase

Planned: Schoolbook: our own attempt at a fast yet readable implementation

Originally, the plan was to have everything generic over the field implementation, so far we have not been successful in convincing the Rust compiler of this. Therefore, currently the implementations must be selected at compile time using feature flags.

Associated Types

type Limbs[src]

Internal representation as limbs

Loading content...

Associated Constants

const ZERO: Self[src]

const ONE: Self[src]

const D: Self[src]

const D2: Self[src]

const APLUS2_OVER_FOUR: Self[src]

const EDWARDS_BASEPOINT_X: Self[src]

const EDWARDS_BASEPOINT_Y: Self[src]

const I: Self[src]

const MONTGOMERY_BASEPOINT_U: Self[src]

Loading content...

Required methods

fn to_bytes(&self) -> [u8; 32][src]

to canonical representation as little-endian bytes

fn from_bytes_unchecked(bytes: &[u8; 32]) -> Self[src]

construct from canonical representation as little-endian bytes

fn inverse(&self) -> Self[src]

fn pow2523(&self) -> Self[src]

Loading content...

Provided methods

fn from_unreduced_bytes(bytes: &[u8; 32]) -> Self[src]

construct from possibly non-canonical representation as little-endian bytes

fn from_bytes(bytes: &[u8; 32]) -> Result<Self>[src]

construct from canonical representation as little-endian bytes, with validity check

fn parity(&self) -> u8[src]

parity of field element, viewed as integer modulo 2**255 - 19

fn squared(&self) -> Self[src]

default implementation, actual implementation may override this with a faster version

Loading content...

Implementors

impl FieldImplementation for FieldElement[src]

type Limbs = [i64; 16]

fn pow2523(&self) -> FieldElement[src]

TODO: figure out why this doesn’t pass the test at the end

Loading content...