Trait generic_ec_core::IntegerEncoding

source ·
pub trait IntegerEncoding
where Self: Sized,
{ type Bytes: ByteArray; // Required methods fn to_be_bytes(&self) -> Self::Bytes; fn to_le_bytes(&self) -> Self::Bytes; fn from_be_bytes_exact(bytes: &Self::Bytes) -> Option<Self>; fn from_le_bytes_exact(bytes: &Self::Bytes) -> Option<Self>; fn from_be_bytes_mod_order(bytes: &[u8]) -> Self; fn from_le_bytes_mod_order(bytes: &[u8]) -> Self; }
Expand description

Encodes an integer as bytes

Required Associated Types§

source

type Bytes: ByteArray

Byte array that fits the whole encoded integer

Required Methods§

source

fn to_be_bytes(&self) -> Self::Bytes

Encodes integer as bytes in big-endian byte order

source

fn to_le_bytes(&self) -> Self::Bytes

Encodes integer as bytes in little-endian byte order

source

fn from_be_bytes_exact(bytes: &Self::Bytes) -> Option<Self>

Decodes integer encoded as bytes in big-endian bytes order

Returns None if the bytes don’t correspond to a valid integer.

source

fn from_le_bytes_exact(bytes: &Self::Bytes) -> Option<Self>

Decodes integer encoded as bytes in little-endian bytes order

Returns None if the bytes don’t correspond to a valid integer.

source

fn from_be_bytes_mod_order(bytes: &[u8]) -> Self

Interprets bytes as big-endian encoding of an integer. Returns integer mod curve (prime) order.

source

fn from_le_bytes_mod_order(bytes: &[u8]) -> Self

Interprets bytes as little-endian encoding of an integer. Returns integer mod curve (prime) order.

Object Safety§

This trait is not object safe.

Implementors§