From 3435f202632e019239c60875aa05c51601da55bc Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Tue, 26 Dec 2023 22:48:45 -0800 Subject: [PATCH] Change result order of from_x_coordinate_flagged. --- circuit/program/src/data/literal/cast_lossy/field.rs | 2 +- circuit/types/group/src/helpers/from_x_coordinate.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/circuit/program/src/data/literal/cast_lossy/field.rs b/circuit/program/src/data/literal/cast_lossy/field.rs index e9e7e054d6..310ec630cc 100644 --- a/circuit/program/src/data/literal/cast_lossy/field.rs +++ b/circuit/program/src/data/literal/cast_lossy/field.rs @@ -65,7 +65,7 @@ impl CastLossy> for Field { debug_assert!(console::Group::from_x_coordinate( as console::One>::one()).is_err()); // Attempt to find a group element with self as the x-coordinate. - let (x_is_not_in_group, point_with_x) = Group::from_x_coordinate_flagged(self.clone()); + let (point_with_x, x_is_not_in_group) = Group::from_x_coordinate_flagged(self.clone()); // Determine if the field element is zero. let is_x_zero = self.is_zero(); diff --git a/circuit/types/group/src/helpers/from_x_coordinate.rs b/circuit/types/group/src/helpers/from_x_coordinate.rs index 374549a940..e6e4245f32 100644 --- a/circuit/types/group/src/helpers/from_x_coordinate.rs +++ b/circuit/types/group/src/helpers/from_x_coordinate.rs @@ -30,7 +30,7 @@ impl Group { /// Initializes an affine group element from a given x-coordinate field element. /// Also returns an error flag, set if there is no group element with the given x-coordinate; /// in that case, the returned point is `(0, 0)`, but immaterial. - pub fn from_x_coordinate_flagged(x: Field) -> (Boolean, Self) { + pub fn from_x_coordinate_flagged(x: Field) -> (Self, Boolean) { // Obtain the A and D coefficients of the elliptic curve. let a = Field::constant(console::Field::new(E::EDWARDS_A)); let d = Field::constant(console::Field::new(E::EDWARDS_D)); @@ -94,7 +94,7 @@ impl Group { let neither_in_subgroup = point1_is_in_subgroup.not().bitand(point2_is_in_subgroup.not()); let error_flag = yy_is_not_square.bitor(&neither_in_subgroup); - (error_flag, Self { x, y }) + (Self { x, y }, error_flag) } } @@ -150,7 +150,7 @@ mod tests { // Compute error flag and point in circuit-land. let input = Field::::new(mode, x); Circuit::scope(format!("{mode} {i}"), || { - let (candidate_error_flag, candidate_point) = Group::from_x_coordinate_flagged(input); + let (candidate_point, candidate_error_flag) = Group::from_x_coordinate_flagged(input); assert_eq!(expected_error_flag, candidate_error_flag.eject_value()); assert_eq!(expected_point, candidate_point.eject_value()); assert_scope!(num_constants, num_public, num_private, num_constraints);