Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize y coord before checking parity #86

Merged
merged 5 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading