fn miller_rabin_round<CS: ConstraintSystem<E>>(
        &self,
        mut cs: CS,
        base: &Self,
    ) -> Result<Boolean, SynthesisError> {
        let bits = self.decompose(cs.namespace(|| "decomp"))?;
        if bits.bits.len() < 3 {
            eprintln!("Miller-Rabin too short");
            return Err(SynthesisError::Unsatisfiable);
        }
        // Unwraps are safe b/c of len check above
        bits.get(0)
            .unwrap()
            .constrain_value(cs.namespace(|| "odd"), true);
        bits.get(1)
            .unwrap()
            .constrain_value(cs.namespace(|| "= 3 mod 4"), true);
        let n_less_one = BigNat::recompose(&bits.clone().shr(1).shl(1), self.params.limb_width);
        let one = BigNat::alloc_from_nat(
            cs.namespace(|| "1"),
            || Ok(Integer::from(1)),
            self.params.limb_width,
            self.limbs.len(),
        )?;
        // 2a + 1 == n
        let a = BigNat::recompose(&bits.shr(1), self.params.limb_width);
        // Check that b^a == 1 (mod self) OR
        //            b^a == -1 (mod self)
        let pow = base.pow_mod(cs.namespace(|| "b^a"), &a, self)?;
        let is_1 = pow.is_equal(cs.namespace(|| "=1"), &n_less_one)?;
        let is_neg_1 = pow.is_equal(cs.namespace(|| "=-1"), &one)?;
        Ok(Boolean::and(cs.namespace(|| "or"), &is_1.not(), &is_neg_1.not())?.not())
    }
/// Assuming that the input is equivalent to 3 modulo 4, does a round of Miller-Rabin to check
/// for primality
Assuming that the input is equivalent to 3 modulo 4, does a round of Miller-Rabin to check
for primality
Assuming that the input is equivalent to 3 modulo 4 does a round of Miller - Rabin to check for primality
fn miller_rabin_round<CS: ConstraintSystem<E>>(
        &self,
        mut cs: CS,
        base: &Self,
    ) -> Result<Boolean, SynthesisError> {
        let bits = self.decompose(cs.namespace(|| "decomp"))?;
        if bits.bits.len() < 3 {
            eprintln!("Miller-Rabin too short");
            return Err(SynthesisError::Unsatisfiable);
        }
        // Unwraps are safe b/c of len check above
        bits.get(0)
            .unwrap()
            .constrain_value(cs.namespace(|| "odd"), true);
        bits.get(1)
            .unwrap()
            .constrain_value(cs.namespace(|| "= 3 mod 4"), true);
        let n_less_one = BigNat::recompose(&bits.clone().shr(1).shl(1), self.params.limb_width);
        let one = BigNat::alloc_from_nat(
            cs.namespace(|| "1"),
            || Ok(Integer::from(1)),
            self.params.limb_width,
            self.limbs.len(),
        )?;
        // 2a + 1 == n
        let a = BigNat::recompose(&bits.shr(1), self.params.limb_width);
        // Check that b^a == 1 (mod self) OR
        //            b^a == -1 (mod self)
        let pow = base.pow_mod(cs.namespace(|| "b^a"), &a, self)?;
        let is_1 = pow.is_equal(cs.namespace(|| "=1"), &n_less_one)?;
        let is_neg_1 = pow.is_equal(cs.namespace(|| "=-1"), &one)?;
        Ok(Boolean::and(cs.namespace(|| "or"), &is_1.not(), &is_neg_1.not())?.not())
    }
fn miller_rabin_round < CS : ConstraintSystem < E > > ( & self , mut cs : CS , base : & Self , ) -> Result < Boolean , SynthesisError > { let bits = self . decompose ( cs . namespace ( | | " " ) ) ? ; if bits . bits . len ( ) < 3 { eprintln ! ( " " ) ; return Err ( SynthesisError :: Unsatisfiable ) ; } // Unwraps are safe b/c of len check above bits . get ( 0 ) . unwrap ( ) . constrain_value ( cs . namespace ( | | " " ) , true ) ; bits . get ( 1 ) . unwrap ( ) . constrain_value ( cs . namespace ( | | " " ) , true ) ; let n_less_one = BigNat :: recompose ( & bits . clone ( ) . shr ( 1 ) . shl ( 1 ) , self . params . limb_width ) ; let one = BigNat :: alloc_from_nat ( cs . namespace ( | | " " ) , | | Ok ( Integer :: from ( 1 ) ) , self . params . limb_width , self . limbs . len ( ) , ) ? ; // 2a + 1 == n let a = BigNat :: recompose ( & bits . shr ( 1 ) , self . params . limb_width ) ; // Check that b^a == 1 (mod self) OR //            b^a == -1 (mod self) let pow = base . pow_mod ( cs . namespace ( | | " " ) , & a , self ) ? ; let is_1 = pow . is_equal ( cs . namespace ( | | " " ) , & n_less_one ) ? ; let is_neg_1 = pow . is_equal ( cs . namespace ( | | " " ) , & one ) ? ; Ok ( Boolean :: and ( cs . namespace ( | | " " ) , & is_1 . not ( ) , & is_neg_1 . not ( ) ) ? . not ( ) ) }
Assuming that the input is equivalent to 3 modulo 4, does a round of Miller-Rabin to check
for primality
Assuming that the input is equivalent to 3 modulo 4 does a round of Miller - Rabin to check for primality
&self
cs
CS
base
&Self
&self
cs
CS
base
&Self