Skip to content

Commit

Permalink
Use AffineCoordinates trait (#734)
Browse files Browse the repository at this point in the history
Switches to the newly consolidated `AffineCoordinates` trait.

See RustCrypto/traits#1237
  • Loading branch information
tarcieri authored Feb 1, 2023
1 parent 1f43726 commit 24bca78
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
9 changes: 3 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ members = [
]

[profile.dev]
opt-level = 2
opt-level = 2

[patch.crates-io]
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }
6 changes: 2 additions & 4 deletions k256/src/arithmetic/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{CompressedPoint, EncodedPoint, FieldBytes, PublicKey, Scalar, Secp25
use core::ops::{Mul, Neg};
use elliptic_curve::{
group::{prime::PrimeCurveAffine, GroupEncoding},
point::{AffineXCoordinate, AffineYIsOdd, DecompactPoint, DecompressPoint},
point::{AffineCoordinates, DecompactPoint, DecompressPoint},
sec1::{self, FromEncodedPoint, ToEncodedPoint},
subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption},
zeroize::DefaultIsZeroes,
Expand Down Expand Up @@ -107,15 +107,13 @@ impl PrimeCurveAffine for AffinePoint {
}
}

impl AffineXCoordinate for AffinePoint {
impl AffineCoordinates for AffinePoint {
type FieldRepr = FieldBytes;

fn x(&self) -> FieldBytes {
self.x.to_bytes()
}
}

impl AffineYIsOdd for AffinePoint {
fn y_is_odd(&self) -> Choice {
self.y.normalize().is_odd()
}
Expand Down
9 changes: 2 additions & 7 deletions primeorder/src/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use elliptic_curve::{
ff::{Field, PrimeField},
generic_array::ArrayLength,
group::{prime::PrimeCurveAffine, GroupEncoding},
point::{AffineXCoordinate, AffineYIsOdd, DecompactPoint, DecompressPoint, Double},
point::{AffineCoordinates, DecompactPoint, DecompressPoint, Double},
sec1::{
self, CompressedPoint, EncodedPoint, FromEncodedPoint, ModulusSize, ToCompactEncodedPoint,
ToEncodedPoint, UncompressedPointSize,
Expand Down Expand Up @@ -77,7 +77,7 @@ where
}
}

impl<C> AffineXCoordinate for AffinePoint<C>
impl<C> AffineCoordinates for AffinePoint<C>
where
C: PrimeCurveParams,
{
Expand All @@ -86,12 +86,7 @@ where
fn x(&self) -> FieldBytes<C> {
self.x.to_repr()
}
}

impl<C> AffineYIsOdd for AffinePoint<C>
where
C: PrimeCurveParams,
{
fn y_is_odd(&self) -> Choice {
self.y.is_odd()
}
Expand Down

0 comments on commit 24bca78

Please sign in to comment.