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§
Sourcetype Ideal: Ideal
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.
Required Methods§
Sourcefn signature() -> UairSignature
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.
Sourcefn 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,
)
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, )
A general method for describing constraints.
§Arguments
b: a builder encapsulating the constraint storing logic. Its typeBhas to have compatibleB::Idealwith theSelf::Ideal, i.e. it must implementFromRef<Self::Ideal>trait.up: aTraceRowof expressions representing the current row of UAIR.down: aTraceRowof expressions representing the shifted (down) row of the UAIR. Its layout matchesUairSignature::down(), which may have fewer columns thanupwhen only a subset of columns are shifted.from_ref: a closure that turns the underlying ringRintoB::Expr. Sometimes (e.g. when dealing with random fields) it is convenient to provide a closure instead of aFromRefimplementation.mbs: a closure that allows to multiply expressions byR. Same rationale as forfrom_ref.
Provided Methods§
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.