This commit is contained in:
Nicholas Ward 2022-01-31 10:49:06 -08:00
parent a471574f78
commit 5b5084b180
4 changed files with 12 additions and 14 deletions

View File

@ -214,13 +214,13 @@ impl<F: RichField + Extendable<D>, const D: usize> SimpleGenerator<F>
}
fn run_once(&self, witness: &PartitionWitness<F>, out_buffer: &mut GeneratedValues<F>) {
let x = witness.get_target(self.x.clone());
let x = witness.get_target(self.x);
let x_u64 = x.to_canonical_u64();
let low = x_u64 as u32;
let high = (x_u64 >> 32) as u32;
out_buffer.set_u32_target(self.low.clone(), low);
out_buffer.set_u32_target(self.high.clone(), high);
out_buffer.set_u32_target(self.low, low);
out_buffer.set_u32_target(self.high, high);
}
}

View File

@ -110,9 +110,9 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
let s_squared = self.mul_nonnative(&s, &s);
let x_sum = self.add_nonnative(x2, x1);
let x3 = self.sub_nonnative(&s_squared, &x_sum);
let x_diff = self.sub_nonnative(&x1, &x3);
let x_diff = self.sub_nonnative(x1, &x3);
let prod = self.mul_nonnative(&s, &x_diff);
let y3 = self.sub_nonnative(&prod, &y1);
let y3 = self.sub_nonnative(&prod, y1);
AffinePointTarget { x: x3, y: y3 }
}

View File

@ -74,7 +74,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
a: a.clone(),
b: b.clone(),
sum: sum.clone(),
overflow: overflow.clone(),
overflow,
_phantom: PhantomData,
});
@ -120,7 +120,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
self.add_simple_generator(NonNativeMultipleAddsGenerator::<F, D, FF> {
summands: summands.clone(),
sum: sum.clone(),
overflow: overflow.clone(),
overflow,
_phantom: PhantomData,
});
@ -161,7 +161,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
a: a.clone(),
b: b.clone(),
diff: diff.clone(),
overflow: overflow.clone(),
overflow,
_phantom: PhantomData,
});
@ -250,11 +250,10 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
let expected_product = self.add_biguint(&mod_times_div, &one);
self.connect_biguint(&product, &expected_product);
let inv = NonNativeTarget::<FF> {
NonNativeTarget::<FF> {
value: inv_biguint,
_phantom: PhantomData,
};
inv
}
}
/// Returns `x % |FF|` as a `NonNativeTarget`.
@ -362,8 +361,7 @@ impl<F: RichField + Extendable<D>, const D: usize, FF: Field> SimpleGenerator<F>
fn dependencies(&self) -> Vec<Target> {
self.summands
.iter()
.map(|summand| summand.value.limbs.iter().map(|limb| limb.0))
.flatten()
.flat_map(|summand| summand.value.limbs.iter().map(|limb| limb.0))
.collect()
}

View File

@ -141,7 +141,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for U32RangeCheckG
_local_constants: &[F],
) -> Vec<Box<dyn WitnessGenerator<F>>> {
let gen = U32RangeCheckGenerator {
gate: self.clone(),
gate: *self,
gate_index,
};
vec![Box::new(gen.adapter())]