Skip to content

Commit

Permalink
Change result order of from_x_coordinate_flagged.
Browse files Browse the repository at this point in the history
  • Loading branch information
acoglio committed Dec 27, 2023
1 parent b4e1b09 commit 3435f20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion circuit/program/src/data/literal/cast_lossy/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<E: Environment> CastLossy<Group<E>> for Field<E> {
debug_assert!(console::Group::from_x_coordinate(<console::Field<E::Network> 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();
Expand Down
6 changes: 3 additions & 3 deletions circuit/types/group/src/helpers/from_x_coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<E: Environment> Group<E> {
/// 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<E>) -> (Boolean<E>, Self) {
pub fn from_x_coordinate_flagged(x: Field<E>) -> (Self, Boolean<E>) {
// 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));
Expand Down Expand Up @@ -94,7 +94,7 @@ impl<E: Environment> Group<E> {
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)
}
}

Expand Down Expand Up @@ -150,7 +150,7 @@ mod tests {
// Compute error flag and point in circuit-land.
let input = Field::<Circuit>::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);
Expand Down

0 comments on commit 3435f20

Please sign in to comment.