Skip to content

Commit ac5c866

Browse files
committed
ecdsa: use MulByGeneratorVartime for public key recovery
Uses the `mul_by_generator_and_mul_add_vartime` method which can leverage wNAF and/or variable-time basepoint tables for optimal performance
1 parent ac0c257 commit ac5c866

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

ecdsa/src/recovery.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ use {
1010
},
1111
digest::{Digest, Update},
1212
elliptic_curve::{
13-
AffinePoint, CurveArithmetic, FieldBytes, FieldBytesSize, Group, PrimeField,
13+
AffinePoint, CurveArithmetic, CurveGroup, FieldBytes, FieldBytesSize, PrimeField,
1414
ProjectivePoint, Scalar,
1515
bigint::CheckedAdd,
1616
field,
17-
ops::Invert,
18-
ops::LinearCombination,
17+
ops::{Invert, MulByGeneratorVartime},
1918
point::DecompressPoint,
2019
sec1::{self, FromSec1Point, ToSec1Point},
2120
subtle::CtOption,
@@ -383,8 +382,8 @@ where
383382
let r_inv = *r.invert();
384383
let u1 = -(r_inv * z);
385384
let u2 = r_inv * *s;
386-
let pk = ProjectivePoint::<C>::lincomb(&[(ProjectivePoint::<C>::generator(), u1), (R, u2)]);
387-
Self::from_affine(pk.into())
385+
let pk = ProjectivePoint::<C>::mul_by_generator_and_mul_add_vartime(&u1, &u2, &R);
386+
Self::from_affine(pk.to_affine())
388387
}
389388
}
390389

0 commit comments

Comments
 (0)