Skip to content

Commit

Permalink
Normalize y coord before checking parity (#86)
Browse files Browse the repository at this point in the history
* Normalize y coord before checking parity

* Increment semver rev for non API change

* Add parity check test

* Remove copy pasta

* Remove namespace
  • Loading branch information
xoloki authored Dec 1, 2024
1 parent d3d77a5 commit e9db1c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion p256k1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "p256k1"
version = "7.2.0"
version = "7.2.1"
edition = "2021"
authors = ["Joey Yandle <[email protected]>"]
license = "Apache-2.0"
Expand Down
13 changes: 13 additions & 0 deletions p256k1/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ impl Point {

unsafe {
secp256k1_ge_set_gej(&mut ge, &self.gej);
secp256k1_fe_normalize_var(&mut ge.y);
secp256k1_fe_is_odd(&ge.y) == 0
}
}
Expand Down Expand Up @@ -944,4 +945,16 @@ mod tests {

assert_eq!(p, q);
}

#[test]
fn point_parity_check() {
let number = [
143, 155, 8, 85, 229, 228, 1, 179, 39, 101, 245, 99, 113, 81, 250, 4, 15, 22, 126, 74,
137, 110, 198, 25, 250, 142, 202, 51, 0, 241, 238, 168,
];
let scalar = Scalar::from(number);

let point = Point::from(scalar);
assert_eq!(point.has_even_y(), point.compress().data[0] == 2);
}
}

0 comments on commit e9db1c4

Please sign in to comment.