Skip to content

Commit

Permalink
crypto/secp256k1: add checking z sign in affineFromJacobian (ethereum…
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
hbakhtiyor authored and enriquefynn committed Feb 15, 2021
1 parent 1d314a6 commit 2daab70
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crypto/secp256k1/curve.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool {
// affineFromJacobian reverses the Jacobian transform. See the comment at the
// top of the file.
func (BitCurve *BitCurve) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big.Int) {
if z.Sign() == 0 {
return new(big.Int), new(big.Int)
}

zinv := new(big.Int).ModInverse(z, BitCurve.P)
zinvsq := new(big.Int).Mul(zinv, zinv)

Expand Down

0 comments on commit 2daab70

Please sign in to comment.