Trait snarkvm_wasm::CondSelectGadget[][src]

pub trait CondSelectGadget<F> where
    F: Field
{ fn conditionally_select<CS>(
        cs: CS,
        cond: &Boolean,
        first: &Self,
        second: &Self
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>
;
fn cost() -> usize; }
Expand description

If condition is true, return first; else, select second.

Required methods

fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Self,
    second: &Self
) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

fn cost() -> usize[src]

Implementors

impl<F> CondSelectGadget<F> for Boolean where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Boolean,
    second: &Boolean
) -> Result<Boolean, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for FpGadget<F> where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &FpGadget<F>,
    second: &FpGadget<F>
) -> Result<FpGadget<F>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

Conditionally selects one of first and second based on the value of self:

If cond is true, this outputs first; else, it outputs second.

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for Blake2sOutputGadget where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    _cs: CS,
    _cond: &Boolean,
    _first: &Blake2sOutputGadget,
    _second: &Blake2sOutputGadget
) -> Result<Blake2sOutputGadget, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for AllocatedFp<F> where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &AllocatedFp<F>,
    second: &AllocatedFp<F>
) -> Result<AllocatedFp<F>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for Int8 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Int8,
    second: &Int8
) -> Result<Int8, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for Int16 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Int16,
    second: &Int16
) -> Result<Int16, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for Int32 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Int32,
    second: &Int32
) -> Result<Int32, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for Int64 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Int64,
    second: &Int64
) -> Result<Int64, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for Int128 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Int128,
    second: &Int128
) -> Result<Int128, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for UInt8 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &UInt8,
    second: &UInt8
) -> Result<UInt8, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for UInt16 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &UInt16,
    second: &UInt16
) -> Result<UInt16, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for UInt32 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &UInt32,
    second: &UInt32
) -> Result<UInt32, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for UInt64 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &UInt64,
    second: &UInt64
) -> Result<UInt64, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for UInt128 where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &UInt128,
    second: &UInt128
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<F> CondSelectGadget<F> for AllocatedBit where
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &AllocatedBit,
    second: &AllocatedBit
) -> Result<AllocatedBit, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<P, F> CondSelectGadget<F> for Fp2Gadget<P, F> where
    P: Fp2Parameters<Fp = F>,
    F: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Fp2Gadget<P, F>,
    second: &Fp2Gadget<P, F>
) -> Result<Fp2Gadget<P, F>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<P, F> CondSelectGadget<F> for Fp6Gadget<P, F> where
    P: Fp6Parameters,
    F: PrimeField,
    <P as Fp6Parameters>::Fp2Params: Fp2Parameters,
    <<P as Fp6Parameters>::Fp2Params as Fp2Parameters>::Fp == F, 
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Fp6Gadget<P, F>,
    second: &Fp6Gadget<P, F>
) -> Result<Fp6Gadget<P, F>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<P, F> CondSelectGadget<F> for Fp12Gadget<P, F> where
    P: Fp12Parameters,
    F: PrimeField,
    <<P as Fp12Parameters>::Fp6Params as Fp6Parameters>::Fp2Params: Fp2Parameters,
    <<<P as Fp12Parameters>::Fp6Params as Fp6Parameters>::Fp2Params as Fp2Parameters>::Fp == F, 
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &Fp12Gadget<P, F>,
    second: &Fp12Gadget<P, F>
) -> Result<Fp12Gadget<P, F>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<P, F, FG> CondSelectGadget<F> for snarkvm_wasm::curves::templates::bls12::AffineGadget<P, F, FG> where
    P: SWModelParameters,
    F: PrimeField,
    FG: FieldGadget<<P as ModelParameters>::BaseField, F>, 
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &AffineGadget<P, F, FG>,
    second: &AffineGadget<P, F, FG>
) -> Result<AffineGadget<P, F, FG>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<P, F, FG> CondSelectGadget<F> for snarkvm_wasm::curves::templates::twisted_edwards::AffineGadget<P, F, FG> where
    P: TEModelParameters,
    F: Field,
    FG: FieldGadget<<P as ModelParameters>::BaseField, F>, 
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &AffineGadget<P, F, FG>,
    second: &AffineGadget<P, F, FG>
) -> Result<AffineGadget<P, F, FG>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

pub fn cost() -> usize[src]

impl<TargetField, BaseField> CondSelectGadget<BaseField> for NonNativeFieldVar<TargetField, BaseField> where
    BaseField: PrimeField,
    TargetField: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &NonNativeFieldVar<TargetField, BaseField>,
    second: &NonNativeFieldVar<TargetField, BaseField>
) -> Result<NonNativeFieldVar<TargetField, BaseField>, SynthesisError> where
    CS: ConstraintSystem<BaseField>, 
[src]

pub fn cost() -> usize[src]

impl<TargetField, BaseField> CondSelectGadget<BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField> where
    BaseField: PrimeField,
    TargetField: PrimeField
[src]

pub fn conditionally_select<CS>(
    cs: CS,
    cond: &Boolean,
    first: &AllocatedNonNativeFieldVar<TargetField, BaseField>,
    second: &AllocatedNonNativeFieldVar<TargetField, BaseField>
) -> Result<AllocatedNonNativeFieldVar<TargetField, BaseField>, SynthesisError> where
    CS: ConstraintSystem<BaseField>, 
[src]

pub fn cost() -> usize[src]