pub trait RandomizableConstraintSystem: ConstraintSystem {
type RandomizedCS: RandomizedConstraintSystem;
// Required method
fn specify_randomized_constraints<F>(
&mut self,
callback: F,
) -> Result<(), R1CSError>
where F: 'static + Fn(&mut Self::RandomizedCS) -> Result<(), R1CSError>;
}Expand description
An extension to the constraint system trait that permits randomized constraints.
Gadgets that do not use randomization should use trait bound CS: ConstraintSystem,
while gadgets that need randomization should use trait bound CS: RandomizedConstraintSystem.
Gadgets generally should not use this trait as a bound on the CS argument: it should be used
by the higher-order protocol that composes gadgets together.
Required Associated Types§
Sourcetype RandomizedCS: RandomizedConstraintSystem
type RandomizedCS: RandomizedConstraintSystem
Represents a concrete type for the CS in a randomization phase.
Required Methods§
Sourcefn specify_randomized_constraints<F>(
&mut self,
callback: F,
) -> Result<(), R1CSError>
fn specify_randomized_constraints<F>( &mut self, callback: F, ) -> Result<(), R1CSError>
Specify additional variables and constraints randomized using a challenge scalar bound to the assignments of the non-randomized variables.
If the constraint system’s low-level variables have not been committed yet,
the call returns Ok() and saves a callback until later.
If the constraint system’s low-level variables are committed already, the callback is invoked immediately and its result is return from this method.
§Usage
Inside the closure you can generate one or more challenges using challenge_scalar method.
cs.specify_randomized_constraints(move |cs| {
let z = cs.challenge_scalar(b"some challenge");
// ...
})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.