pub trait CondSwapInstructions<F: Field>: UtilitiesInstructions<F> {
// Required method
fn swap(
&self,
layouter: impl Layouter<F>,
pair: (Self::Var, Value<F>),
swap: Value<bool>
) -> Result<(Self::Var, Self::Var), Error>;
}
Expand description
Instructions for a conditional swap gadget.
Required Methods§
sourcefn swap(
&self,
layouter: impl Layouter<F>,
pair: (Self::Var, Value<F>),
swap: Value<bool>
) -> Result<(Self::Var, Self::Var), Error>
fn swap( &self, layouter: impl Layouter<F>, pair: (Self::Var, Value<F>), swap: Value<bool> ) -> Result<(Self::Var, Self::Var), Error>
Given an input pair (a,b) and a swap
boolean flag, returns
(b,a) if swap
is set, else (a,b) if swap
is not set.
The second element of the pair is required to be a witnessed value, not a variable that already exists in the circuit.