Skip to content

Commit

Permalink
nil-check inspired dsa.Verify issue: github.com/golang/go/issues/34960
Browse files Browse the repository at this point in the history
  • Loading branch information
savely-krasovsky committed Oct 28, 2019
1 parent 5a940da commit 1e3405e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion publickey.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func NewPublicKeyFromBytes(b []byte) (*PublicKey, error) {
x3b.Mul(&x3b, x)
x3b.Add(&x3b, curve.Params().B)
x3b.Mod(&x3b, curve.Params().P)
y.ModSqrt(&x3b, curve.Params().P)
if z := y.ModSqrt(&x3b, curve.Params().P); z == nil {
return nil, fmt.Errorf("cannot parse public key")
}

if y.Bit(0) != ybit {
y.Sub(curve.Params().P, &y)
Expand Down

0 comments on commit 1e3405e

Please sign in to comment.