|
@ -232,15 +232,12 @@ pub trait FieldGadget: |
|
|
let mut res = Self::one(cs.ns(|| "Alloc result"))?;
|
|
|
let mut res = Self::one(cs.ns(|| "Alloc result"))?;
|
|
|
let mut found_one = false;
|
|
|
let mut found_one = false;
|
|
|
|
|
|
|
|
|
for i in BitIterator::new(exp)
|
|
|
|
|
|
{
|
|
|
|
|
|
if found_one
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
for (i, bit) in BitIterator::new(exp).enumerate() {
|
|
|
|
|
|
if found_one {
|
|
|
res.square_in_place(cs.ns(|| format!("square for bit {:?}", i)))?;
|
|
|
res.square_in_place(cs.ns(|| format!("square for bit {:?}", i)))?;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if !i
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
if !bit {
|
|
|
found_one = true;
|
|
|
found_one = true;
|
|
|
res.mul_in_place(cs.ns(|| format!("mul for bit {:?}", i)), self)?;
|
|
|
res.mul_in_place(cs.ns(|| format!("mul for bit {:?}", i)), self)?;
|
|
|
}
|
|
|
}
|
|
|