pub trait FieldBytesEncoding<C>: ArrayEncoding + Integerwhere
    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.

Implementors§