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

edwards: add SubgroupPoint traits #672

Merged
merged 1 commit into from
Jul 30, 2024
Merged
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
16 changes: 15 additions & 1 deletion curve25519-dalek/src/edwards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ impl GroupEncoding for EdwardsPoint {
/// A `SubgroupPoint` represents a point on the Edwards form of Curve25519, that is
/// guaranteed to be in the prime-order subgroup.
#[cfg(feature = "group")]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct SubgroupPoint(EdwardsPoint);

#[cfg(feature = "group")]
Expand Down Expand Up @@ -1510,6 +1510,20 @@ impl MulAssign<&Scalar> for SubgroupPoint {
#[cfg(feature = "group")]
define_mul_assign_variants!(LHS = SubgroupPoint, RHS = Scalar);

#[cfg(feature = "group")]
impl ConstantTimeEq for SubgroupPoint {
fn ct_eq(&self, other: &SubgroupPoint) -> Choice {
self.0.ct_eq(&other.0)
}
}

#[cfg(feature = "group")]
impl ConditionallySelectable for SubgroupPoint {
fn conditional_select(a: &SubgroupPoint, b: &SubgroupPoint, choice: Choice) -> SubgroupPoint {
SubgroupPoint(EdwardsPoint::conditional_select(&a.0, &b.0, choice))
}
}

#[cfg(feature = "group")]
impl group::Group for SubgroupPoint {
type Scalar = Scalar;
Expand Down
Loading