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

Use AffineCoordinates trait #734

Merged
merged 1 commit into from
Feb 1, 2023
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
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" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably forgot the newline at the end here.
Btw I am using Taplo in my CIs for a while now, to great success.

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