This commit is contained in:
Nicholas Ward 2021-11-09 17:51:38 -08:00
parent 4d4605af1f
commit a4b7772c34
2 changed files with 27 additions and 1 deletions

View File

@ -110,8 +110,8 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
// Subtract two `BigUintTarget`s. We assume that the first is larger than the second.
pub fn sub_biguint(&mut self, a: &BigUintTarget, b: &BigUintTarget) -> BigUintTarget {
let num_limbs = a.limbs.len();
let (a, b) = self.pad_biguints(a, b);
let num_limbs = a.limbs.len();
let mut result_limbs = vec![];

View File

@ -155,4 +155,30 @@ mod tests {
verify(proof, &data.verifier_only, &data.common).unwrap();
}
#[test]
fn test_curve_double() -> Result<()> {
type F = CrandallField;
const D: usize = 4;
let config = CircuitConfig::large_config();
let pw = PartialWitness::new();
let mut builder = CircuitBuilder::<F, D>::new(config);
let g = Secp256K1::GENERATOR_AFFINE;
let g_target = builder.constant_affine_point(g);
let neg_g_target = builder.curve_neg(&g_target);
let double_g = builder.curve_double(&g_target);
let double_neg_g = builder.curve_double(&neg_g_target);
builder.curve_assert_valid(&double_g);
builder.curve_assert_valid(&double_neg_g);
let data = builder.build();
let proof = data.prove(pw).unwrap();
verify(proof, &data.verifier_only, &data.common)
}
}