Skip to content

Commit

Permalink
Small perf adjustments for ShortWeierstrassProjectivePoint operations (
Browse files Browse the repository at this point in the history
…#842)

Co-authored-by: Diego K <[email protected]>
  • Loading branch information
tcoratger and diegokingston authored Oct 4, 2024
1 parent 86b2789 commit e25a464
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions math/src/elliptic_curve/short_weierstrass/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ impl<E: IsShortWeierstrass> ShortWeierstrassProjectivePoint<E> {
}

pub fn double(&self) -> Self {
if self.is_neutral_element() {
return self.clone();
}
let [px, py, pz] = self.coordinates();

let px_square = px * px;
Expand Down Expand Up @@ -86,18 +89,18 @@ impl<E: IsShortWeierstrass> ShortWeierstrassProjectivePoint<E> {
}
// https://hyperelliptic.org/EFD/g1p/data/shortw/projective/addition/madd-1998-cmo
pub fn operate_with_affine(&self, other: &Self) -> Self {
let [px, py, pz] = self.coordinates();
let [qx, qy, _qz] = other.coordinates();
let u = qy * pz;
let v = qx * pz;

if self.is_neutral_element() {
return other.clone();
}
if other.is_neutral_element() {
return self.clone();
}

let [px, py, pz] = self.coordinates();
let [qx, qy, _qz] = other.coordinates();
let u = qy * pz;
let v = qx * pz;

if u == *py {
if v != *px || *py == FieldElement::zero() {
return Self::new([
Expand Down

0 comments on commit e25a464

Please sign in to comment.