Skip to main content

FieldBytesEncoding

Trait FieldBytesEncoding 

pub trait FieldBytesEncoding<C>: ArrayEncoding + Integer
where C: Curve,
{ // Provided methods fn decode_field_bytes( field_bytes: &GenericArray<u8, <C as Curve>::FieldBytesSize>, ) -> Self { ... } fn encode_field_bytes( &self, ) -> GenericArray<u8, <C as Curve>::FieldBytesSize> { ... } }
Expand description

Trait for decoding/encoding Curve::Uint from/to FieldBytes using curve-specific rules.

Namely a curve’s modulus may be smaller than the big integer type used to internally represent field elements (since the latter are multiples of the limb size), such as in the case of curves like NIST P-224 and P-521, and so it may need to be padded/truncated to the right length.

Additionally, different curves have different endianness conventions, also captured here.

Provided Methods§

fn decode_field_bytes( field_bytes: &GenericArray<u8, <C as Curve>::FieldBytesSize>, ) -> Self

Decode unsigned integer from serialized field element.

The default implementation assumes a big endian encoding.

fn encode_field_bytes(&self) -> GenericArray<u8, <C as Curve>::FieldBytesSize>

Encode unsigned integer into serialized field element.

The default implementation assumes a big endian encoding.

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§

§

impl FieldBytesEncoding<Secp256k1> for Uint<crypto_bigint::::uint::U256::{constant#0}>

§

impl FieldBytesEncoding<NistP256> for Uint<crypto_bigint::::uint::U256::{constant#0}>