mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-09 23:41:33 +01:00
Allow CS being none for into_edwards (#15)
This commit is contained in:
@@ -112,15 +112,26 @@ mod montgomery_affine_impl {
|
|||||||
#[tracing::instrument(target = "r1cs")]
|
#[tracing::instrument(target = "r1cs")]
|
||||||
pub fn into_edwards(&self) -> Result<AffineVar<P, F>, SynthesisError> {
|
pub fn into_edwards(&self) -> Result<AffineVar<P, F>, SynthesisError> {
|
||||||
let cs = self.cs();
|
let cs = self.cs();
|
||||||
|
|
||||||
|
let mode = if cs.is_none() {
|
||||||
|
AllocationMode::Constant
|
||||||
|
} else {
|
||||||
|
AllocationMode::Witness
|
||||||
|
};
|
||||||
|
|
||||||
// Compute u = x / y
|
// Compute u = x / y
|
||||||
let u = F::new_witness(ark_relations::ns!(cs, "u"), || {
|
let u = F::new_variable(
|
||||||
let y_inv = self
|
ark_relations::ns!(cs, "u"),
|
||||||
.y
|
|| {
|
||||||
.value()?
|
let y_inv = self
|
||||||
.inverse()
|
.y
|
||||||
.ok_or(SynthesisError::DivisionByZero)?;
|
.value()?
|
||||||
Ok(self.x.value()? * &y_inv)
|
.inverse()
|
||||||
})?;
|
.ok_or(SynthesisError::DivisionByZero)?;
|
||||||
|
Ok(self.x.value()? * &y_inv)
|
||||||
|
},
|
||||||
|
mode,
|
||||||
|
)?;
|
||||||
|
|
||||||
u.mul_equals(&self.y, &self.x)?;
|
u.mul_equals(&self.y, &self.x)?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user