pub trait HasByteRepresentation {
const REPR_NUM_BYTES: usize;
// Required methods
fn from_bytes_le(bytes: &[u8]) -> Self;
fn to_bytes_le(&self) -> Vec<u8> ⓘ;
fn to_u64s_le(&self) -> Vec<u64>;
fn from_u64s_le(words: Vec<u64>) -> Self
where Self: Sized;
fn vec_from_bytes_le(bytes: &[u8]) -> Vec<Self>
where Self: Sized;
}Expand description
Simple trait which allows us to convert to and from a little-endian byte representation.
Required Associated Constants§
Sourceconst REPR_NUM_BYTES: usize
const REPR_NUM_BYTES: usize
Number of bytes within the element’s representation.
Required Methods§
Sourcefn from_bytes_le(bytes: &[u8]) -> Self
fn from_bytes_le(bytes: &[u8]) -> Self
Constructor which creates an instance of the element from a vec of
less than or equal to length REPR_NUM_BYTES.
If length less than REPR_NUM_BYTES, pads the most significant
bits with 0s until it is of equal length to REPR_NUM_BYTES.
Sourcefn to_bytes_le(&self) -> Vec<u8> ⓘ
fn to_bytes_le(&self) -> Vec<u8> ⓘ
Function which creates an equivalent representation of the element
in a byte array of length REPR_NUM_BYTES.
Sourcefn to_u64s_le(&self) -> Vec<u64>
fn to_u64s_le(&self) -> Vec<u64>
Similar to to_bytes_le but returns chunks of u64s.
Sourcefn from_u64s_le(words: Vec<u64>) -> Selfwhere
Self: Sized,
fn from_u64s_le(words: Vec<u64>) -> Selfwhere
Self: Sized,
Similar to from_bytes_le but takes chunks of u64s.
Sourcefn vec_from_bytes_le(bytes: &[u8]) -> Vec<Self>where
Self: Sized,
fn vec_from_bytes_le(bytes: &[u8]) -> Vec<Self>where
Self: Sized,
Creates a Vec of elements from an arbitrary string of bytes.
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 HasByteRepresentation for Fq
impl HasByteRepresentation for Fq
const REPR_NUM_BYTES: usize = 32
Source§impl HasByteRepresentation for Fr
TODO(ryancao): Test these implementations!
impl HasByteRepresentation for Fr
TODO(ryancao): Test these implementations!