Skip to main content

FieldArithmetic

Trait FieldArithmetic 

Source
pub trait FieldArithmetic: CurveArithmetic {
    type FieldElement: BatchInvert + Generate + Invert<Output = CtOption<Self::FieldElement>> + PrimeField<Repr = Array<u8, Self::FieldBytesSize>> + Retrieve<Output = Self::Uint>;
}
Expand description

Access to a curve’s base field element type.

This trait is bounded on CurveArithmetic to provide a complete arithmetic implementation, and also make the associated FieldElement type completely inaccessible unless this trait is in scope, having been imported from this hazmat module so that text appears in the import. We also explicitly recommend against re-exporting it so the hazmat keyword is easy to search for.

Security Warning

Field elements are easily misused, unlike group-based abstractions. Some elliptic curves utilize lazy normalization, meaning that field elements may be non-canonical leading to miscomputations. We strongly recommend you avoid using this trait except for use cases that are truly dependent on coordinates, such as curve point encodings or hash2curve.

Required Associated Types§

Source

type FieldElement: BatchInvert + Generate + Invert<Output = CtOption<Self::FieldElement>> + PrimeField<Repr = Array<u8, Self::FieldBytesSize>> + Retrieve<Output = Self::Uint>

Base field element type.

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§