Skip to main content

Uair

Trait Uair 

Source
pub trait Uair: Clone {
    type Ideal: Ideal;
    type Scalar: Semiring;

    // Required methods
    fn signature() -> UairSignature;
    fn constrain_general<B, FromR, MulByScalar, IFromR>(
        b: &mut B,
        up: TraceRow<'_, B::Expr>,
        down: TraceRow<'_, B::Expr>,
        from_ref: FromR,
        mbs: MulByScalar,
        ideal_from_ref: IFromR,
    )
       where B: ConstraintBuilder,
             FromR: Fn(&Self::Scalar) -> B::Expr,
             MulByScalar: Fn(&B::Expr, &Self::Scalar) -> Option<B::Expr>,
             IFromR: Fn(&Self::Ideal) -> B::Ideal;

    // Provided method
    fn constrain<B>(
        b: &mut B,
        up: TraceRow<'_, B::Expr>,
        down: TraceRow<'_, B::Expr>,
    )
       where B: ConstraintBuilder,
             B::Expr: FromRef<Self::Scalar> + for<'b> MulByScalar<&'b Self::Scalar>,
             B::Ideal: FromRef<Self::Ideal> { ... }
}
Expand description

The trait that a universal AIR description has to implement. This must include all the constraint description logic of an UAIR.

One type might implement different UAIR logics for different underlying semirings hence the generic type parameter.

Required Associated Types§

Source

type Ideal: Ideal

The ideal type the AIR operates with. Since a ConstraintBuilder is “opaque” for a Uair a Uair has to have a means to create ideals so ideals are fixed by this associated types. At the constrain* methods a Uair is given a way to convert its own ideals into builder’s ideals via the FromRef trait.

Source

type Scalar: Semiring

The type of scalars of the UAIR. For now, we assume they are of the type “arbitrary polynomials”.

Required Methods§

Source

fn signature() -> UairSignature

Signature of the UAIR.

TODO: Consider caching the signature to avoid recomputing it at every call site. Currently negligible since shifts are small (e.g. ~12 for SHA/ECDSA), but may matter if signatures grow more expensive to construct.

Source

fn constrain_general<B, FromR, MulByScalar, IFromR>( b: &mut B, up: TraceRow<'_, B::Expr>, down: TraceRow<'_, B::Expr>, from_ref: FromR, mbs: MulByScalar, ideal_from_ref: IFromR, )
where B: ConstraintBuilder, FromR: Fn(&Self::Scalar) -> B::Expr, MulByScalar: Fn(&B::Expr, &Self::Scalar) -> Option<B::Expr>, IFromR: Fn(&Self::Ideal) -> B::Ideal,

A general method for describing constraints.

§Arguments
  • b: a builder encapsulating the constraint storing logic. Its type B has to have compatible B::Ideal with the Self::Ideal, i.e. it must implement FromRef<Self::Ideal> trait.
  • up: a TraceRow of expressions representing the current row of UAIR.
  • down: a TraceRow of expressions representing the shifted (down) row of the UAIR. Its layout matches UairSignature::down(), which may have fewer columns than up when only a subset of columns are shifted.
  • from_ref: a closure that turns the underlying ring R into B::Expr. Sometimes (e.g. when dealing with random fields) it is convenient to provide a closure instead of a FromRef implementation.
  • mbs: a closure that allows to multiply expressions by R. Same rationale as for from_ref.

Provided Methods§

Source

fn constrain<B>( b: &mut B, up: TraceRow<'_, B::Expr>, down: TraceRow<'_, B::Expr>, )
where B: ConstraintBuilder, B::Expr: FromRef<Self::Scalar> + for<'b> MulByScalar<&'b Self::Scalar>, B::Ideal: FromRef<Self::Ideal>,

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§