Fix one-off bug in signRFC6979

This commit is contained in:
junderw 2018-11-23 14:55:01 +09:00 committed by Dave Collins
parent 67e573d211
commit 3dcf298fed

View file

@ -427,9 +427,7 @@ func signRFC6979(privateKey *PrivateKey, hash []byte) (*Signature, error) {
k := nonceRFC6979(privkey.D, hash)
inv := new(big.Int).ModInverse(k, N)
r, _ := privkey.Curve.ScalarBaseMult(k.Bytes())
if r.Cmp(N) == 1 {
r.Sub(r, N)
}
r.Mod(r, N)
if r.Sign() == 0 {
return nil, errors.New("calculated R is zero")