Skip to main content

FieldFn

Trait FieldFn 

Source
pub trait FieldFn<F: Field> {
    // Required method
    fn call<E: FieldOps<Scalar = F> + From<F>>(&self, inputs: &[E]) -> E;

    // Provided method
    fn call_native(&self, inputs: &[F]) -> F { ... }
}
Expand description

An arithmetic function over field elements, generic in the field it evaluates in.

A closure FnOnce(&[F]) -> F is monomorphic: it runs in one fixed field. Carrying the genericity on the method instead lets one value run in many fields:

  • natively, in the verifier’s own base field F;
  • over any larger field E whose scalar is F.

Required Methods§

Source

fn call<E: FieldOps<Scalar = F> + From<F>>(&self, inputs: &[E]) -> E

Evaluates the function on inputs in the field E, returning one element.

The scalar of E is the base field F. The From<F> bound lets the function embed base-field constants into E.

Provided Methods§

Source

fn call_native(&self, inputs: &[F]) -> F

Evaluates the function on inputs natively in the base field F.

The default is self.call::<F>(inputs); implementors may override with a base-field specialized fast path (e.g. deferred WideMul reduction) that the generic call — which cannot assume E: WideMul — can’t express. Callers evaluating in F should prefer this.

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§