From 79ab6c29bd90c37d89a34a6279b92ae594c44e94 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Tue, 30 Jul 2024 08:51:44 +0300 Subject: [PATCH] curve: Implement ConditionallySelectable for MontgomeryPoint (#677) --- curve25519-dalek/Cargo.toml | 2 +- curve25519-dalek/src/montgomery.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/curve25519-dalek/Cargo.toml b/curve25519-dalek/Cargo.toml index f0896ba74..c4fb28a38 100644 --- a/curve25519-dalek/Cargo.toml +++ b/curve25519-dalek/Cargo.toml @@ -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 } diff --git a/curve25519-dalek/src/montgomery.rs b/curve25519-dalek/src/montgomery.rs index 2be35cdc7..cb5e2fb87 100644 --- a/curve25519-dalek/src/montgomery.rs +++ b/curve25519-dalek/src/montgomery.rs @@ -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()