Skip to content

Commit 2daab70

Browse files
hbakhtiyorenriquefynn
authored andcommitted
crypto/secp256k1: add checking z sign in affineFromJacobian (ethereum#18419)
The z == 0 check is hit whenever we Add two points with the same x1/x2 coordinate. crypto/elliptic uses the same check in their affineFromJacobian function. This change does not affect block processing or tx signature verification in any way, because it does not use the Add or Double methods.
1 parent 1d314a6 commit 2daab70

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crypto/secp256k1/curve.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool {
116116
// affineFromJacobian reverses the Jacobian transform. See the comment at the
117117
// top of the file.
118118
func (BitCurve *BitCurve) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big.Int) {
119+
if z.Sign() == 0 {
120+
return new(big.Int), new(big.Int)
121+
}
122+
119123
zinv := new(big.Int).ModInverse(z, BitCurve.P)
120124
zinvsq := new(big.Int).Mul(zinv, zinv)
121125

0 commit comments

Comments
 (0)