Skip to content

Commit 76d7803

Browse files
committed
Use linear combination in ECDSA verification
1 parent ab26405 commit 76d7803

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

k256/src/ecdsa/verify.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! ECDSA verifier
22
33
use super::{recoverable, Error, Signature};
4+
use crate::arithmetic::lincomb;
45
use crate::{
56
AffinePoint, CompressedPoint, EncodedPoint, ProjectivePoint, PublicKey, Scalar, Secp256k1,
67
};
@@ -90,9 +91,15 @@ impl VerifyPrimitive<Secp256k1> for AffinePoint {
9091
let u1 = z * &s_inv;
9192
let u2 = *r * s_inv;
9293

93-
let x = ((ProjectivePoint::generator() * u1) + (ProjectivePoint::from(*self) * u2))
94-
.to_affine()
95-
.x;
94+
//let x = ((ProjectivePoint::generator() * u1) + (ProjectivePoint::from(*self) * u2))
95+
let x = lincomb(
96+
&ProjectivePoint::generator(),
97+
&ProjectivePoint::from(*self),
98+
&u1,
99+
&u2,
100+
)
101+
.to_affine()
102+
.x;
96103

97104
if Scalar::from_bytes_reduced(&x.to_bytes()).eq(&r) {
98105
Ok(())

0 commit comments

Comments
 (0)