pub trait ScalarField: FieldExt + Hash {
    fn to_u64_limbs(self, num_limbs: usize, bit_len: usize) -> Vec<u64>;
    fn to_bytes_le(&self) -> Vec<u8>;

    fn from_bytes_le(bytes: &[u8]) -> Self { ... }
}
Expand description

Helper trait to represent a field element that can be converted into u64 limbs.

Note: Since the number of bits necessary to represent a field element is larger than the number of bits in a u64, we decompose the integer representation of the field element into multiple u64 values e.g. limbs.

Required Methods

Returns the base 2<sup>bit_len</sup> little endian representation of the ScalarField element up to num_limbs number of limbs (truncates any extra limbs).

Assumes bit_len < 64.

  • num_limbs: number of limbs to return
  • bit_len: number of bits in each limb

Returns the little endian byte representation of the element.

Provided Methods

Creates a field element from a little endian byte representation.

The default implementation assumes that PrimeField::from_repr is implemented for little-endian. It should be overriden if this is not the case.

Implementors

We do a blanket implementation in ‘community-edition’ to make it easier to integrate with other crates.

ASSUMING F::Repr is little-endian