Skip to main content

Uair

Trait Uair 

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

    // Required methods
    fn signature() -> UairSignature<Self::Prime>;
    fn constrain_general<C, B, FromR, MulByScalar, IFromR, IFqFromR>(
        b: &mut B,
        expr_cfg: &C,
        up: TraceRow<'_, C::Element>,
        down: TraceRow<'_, C::Element>,
        from_ref: FromR,
        mbs: MulByScalar,
        ideal_from_ref: IFromR,
        fq_ideal_from_ref: IFqFromR,
    )
       where C: SemiringConfig,
             B: ConstraintBuilder<Expr = C::Element>,
             FromR: Fn(&Self::Scalar) -> C::Element,
             MulByScalar: Fn(&C::Element, &Self::Scalar) -> Option<C::Element>,
             IFromR: Fn(&Self::Ideal) -> B::Ideal,
             IFqFromR: Fn(&Self::FqIdeal) -> B::FqIdeal;
}
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 FqIdeal: Ideal

The ideal type for $F_{q_i}[X]$-constraints emitted via ConstraintBuilder::assert_in_fq_ideal. UAIRs that do not declare any primes should set this to ideal::ImpossibleIdeal.

Source

type Scalar: Semiring

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

Source

type Prime: Semiring

Type of primes defined in signature. Must be compatible with the field type we’re using.

Required Methods§

Source

fn signature() -> UairSignature<Self::Prime>

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<C, B, FromR, MulByScalar, IFromR, IFqFromR>( b: &mut B, expr_cfg: &C, up: TraceRow<'_, C::Element>, down: TraceRow<'_, C::Element>, from_ref: FromR, mbs: MulByScalar, ideal_from_ref: IFromR, fq_ideal_from_ref: IFqFromR, )
where C: SemiringConfig, B: ConstraintBuilder<Expr = C::Element>, FromR: Fn(&Self::Scalar) -> C::Element, MulByScalar: Fn(&C::Element, &Self::Scalar) -> Option<C::Element>, IFromR: Fn(&Self::Ideal) -> B::Ideal, IFqFromR: Fn(&Self::FqIdeal) -> B::FqIdeal,

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.
  • expr_cfg: the [SemiringConfig] providing arithmetic operations on B::Expr. Per-family builder runs pass the family’s config (e.g. a zinc_poly::univariate::dynamic::DynamicPolynomialConfig over the family’s field, or the field config itself); static analyses pass a FixedConfig.
  • 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.
  • ideal_from_ref: a closure that turns a Self::Ideal into B::Ideal for the $Q[X]$-ideal-membership family.
  • fq_ideal_from_ref: a closure that turns a Self::FqIdeal into B::FqIdeal for the new $F_{q_i}[X]$-ideal-membership family emitted via ConstraintBuilder::assert_in_fq_ideal. UAIRs without $F_q[X]$-constraints can ignore this closure.

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§