Merge pull request #1479 from cfromknecht/normalize-decompress

btcec/pubkey: normalize sqrt(x^3) before checking parity
This commit is contained in:
Olaoluwa Osuntokun 2019-10-10 21:21:31 -07:00 committed by GitHub
commit c3151ef50d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,11 +38,10 @@ func decompressPoint(curve *KoblitzCurve, bigX *big.Int, ybit bool) (*big.Int, e
// but this was replaced by the algorithms referenced in // but this was replaced by the algorithms referenced in
// https://bitcointalk.org/index.php?topic=162805.msg1712294#msg1712294 // https://bitcointalk.org/index.php?topic=162805.msg1712294#msg1712294
var y fieldVal var y fieldVal
y.SqrtVal(&x3) y.SqrtVal(&x3).Normalize()
if ybit != y.IsOdd() { if ybit != y.IsOdd() {
y.Negate(1) y.Negate(1).Normalize()
} }
y.Normalize()
// Check that y is a square root of x^3 + B. // Check that y is a square root of x^3 + B.
var y2 fieldVal var y2 fieldVal