From edc9a8ce025e1d43be2683fcd849411e3e76cf02 Mon Sep 17 00:00:00 2001 From: Weikeng Chen Date: Mon, 16 Nov 2020 01:39:07 -0800 Subject: [PATCH] Allow CS being none for into_edwards (#16) * allow cs being none for into_edwards --- src/groups/curves/twisted_edwards/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/groups/curves/twisted_edwards/mod.rs b/src/groups/curves/twisted_edwards/mod.rs index 04f8ceb..6753995 100644 --- a/src/groups/curves/twisted_edwards/mod.rs +++ b/src/groups/curves/twisted_edwards/mod.rs @@ -135,14 +135,18 @@ mod montgomery_affine_impl { u.mul_equals(&self.y, &self.x)?; - let v = F::new_witness(ark_relations::ns!(cs, "v"), || { - let mut t0 = self.x.value()?; - let mut t1 = t0; - t0 -= &P::BaseField::one(); - t1 += &P::BaseField::one(); + let v = F::new_variable( + ark_relations::ns!(cs, "v"), + || { + let mut t0 = self.x.value()?; + let mut t1 = t0; + t0 -= &P::BaseField::one(); + t1 += &P::BaseField::one(); - Ok(t0 * &t1.inverse().ok_or(SynthesisError::DivisionByZero)?) - })?; + Ok(t0 * &t1.inverse().ok_or(SynthesisError::DivisionByZero)?) + }, + mode, + )?; let xplusone = &self.x + P::BaseField::one(); let xminusone = &self.x - P::BaseField::one();