openvm_algebra_guest::field

Trait FieldExtension

Source
pub trait FieldExtension<BaseField> {
    type Coeffs: Sized;

    const D: usize;

    // Required methods
    fn from_coeffs(coeffs: Self::Coeffs) -> Self;
    fn from_bytes(bytes: &[u8]) -> Self;
    fn to_coeffs(self) -> Self::Coeffs;
    fn to_bytes(&self) -> Vec<u8>;
    fn embed(base_elem: BaseField) -> Self;
    fn frobenius_map(&self, power: usize) -> Self;
    fn mul_base(&self, rhs: &BaseField) -> Self;
}
Expand description

Field extension trait. BaseField is the base field of the extension field.

Required Associated Constants§

Source

const D: usize

Extension field degree.

Required Associated Types§

Source

type Coeffs: Sized

This should be [BaseField; D]. It is an associated type due to rust const generic limitations.

Required Methods§

Source

fn from_coeffs(coeffs: Self::Coeffs) -> Self

Create an extension field element from its base field coefficients.

Source

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

Create an extension field element from little-endian bytes.

Source

fn to_coeffs(self) -> Self::Coeffs

Convert an extension field element to its base field coefficients.

Source

fn to_bytes(&self) -> Vec<u8>

Convert an extension field element to little-endian bytes.

Source

fn embed(base_elem: BaseField) -> Self

Embed a base field element into an extension field element.

Source

fn frobenius_map(&self, power: usize) -> Self

Frobenius map: take self to the p^powerth power, where p is the prime characteristic of the field.

Source

fn mul_base(&self, rhs: &BaseField) -> Self

Multiply an extension field element by an element in the base field

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.

Implementations on Foreign Types§

Source§

impl FieldExtension<Fp2> for Fq12

Note that halo2curves does not implement Field for Fq6, so we need to implement the intermediate points manually.

FieldExtension for Fq12 with Fq2 as base field since halo2curves does not implement Field for Fq6.

Source§

fn frobenius_map(&self, power: usize) -> Self

Raises this element to p^power, where p is prime characteristic of Self.

Source§

const D: usize = 6usize

Source§

type Coeffs = [Fp2; 6]

Source§

fn from_coeffs(coeffs: [Fq2; 6]) -> Self

Source§

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

Source§

fn to_coeffs(self) -> Self::Coeffs

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn embed(base_elem: Fq2) -> Self

Source§

fn mul_base(&self, rhs: &Fq2) -> Self

Source§

impl FieldExtension<Fp> for Fq2

FieldExtension for Fq2 with Fq as base field

Source§

const D: usize = 2usize

Source§

type Coeffs = [Fp; 2]

Source§

fn from_coeffs(coeffs: [Fq; 2]) -> Self

Source§

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

Source§

fn to_coeffs(self) -> Self::Coeffs

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn embed(c0: Fq) -> Self

Source§

fn frobenius_map(&self, power: usize) -> Self

Source§

fn mul_base(&self, rhs: &Fq) -> Self

Source§

impl FieldExtension<Fq2> for Fq12

FieldExtension for Fq12 with Fq6 as base field since halo2curves does not implement Field for Fq6.

Source§

const D: usize = 6usize

Source§

type Coeffs = [Fq2; 6]

Source§

fn from_coeffs(coeffs: Self::Coeffs) -> Self

Source§

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

Source§

fn to_coeffs(self) -> Self::Coeffs

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn embed(c0: Fq2) -> Self

Source§

fn frobenius_map(&self, power: usize) -> Self

Source§

fn mul_base(&self, rhs: &Fq2) -> Self

Source§

impl FieldExtension<Fq> for Fq2

FieldExtension for Fq2 with Fq as base field

Source§

const D: usize = 2usize

Source§

type Coeffs = [Fq; 2]

Source§

fn from_coeffs(coeffs: Self::Coeffs) -> Self

Source§

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

Source§

fn to_coeffs(self) -> Self::Coeffs

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn embed(c0: Fq) -> Self

Source§

fn frobenius_map(&self, power: usize) -> Self

Source§

fn mul_base(&self, rhs: &Fq) -> Self

Implementors§