Skip to content

Commit

Permalink
curve: Implement ConditionallySelectable for MontgomeryPoint (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
elichai committed Jul 30, 2024
1 parent a7a9fff commit 79ab6c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion curve25519-dalek/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ff = { version = "0.13", default-features = false, optional = true }
group = { version = "0.13", default-features = false, optional = true }
rand_core = { version = "0.6.4", default-features = false, optional = true }
digest = { version = "0.10", default-features = false, optional = true }
subtle = { version = "2.6.0", default-features = false }
subtle = { version = "2.6.0", default-features = false, features = ["const-generics"]}
serde = { version = "1.0", default-features = false, optional = true, features = ["derive"] }
zeroize = { version = "1", default-features = false, optional = true }

Expand Down
6 changes: 6 additions & 0 deletions curve25519-dalek/src/montgomery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ impl ConstantTimeEq for MontgomeryPoint {
}
}

impl ConditionallySelectable for MontgomeryPoint {
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
Self(<[u8; 32]>::conditional_select(&a.0, &b.0, choice))
}
}

impl PartialEq for MontgomeryPoint {
fn eq(&self, other: &MontgomeryPoint) -> bool {
self.ct_eq(other).into()
Expand Down

0 comments on commit 79ab6c2

Please sign in to comment.