[DEV-323] fix one off bug in sign rfc6979 (#133)

This commit is contained in:
Evgeny Khirin 2018-12-26 14:25:21 +02:00 committed by stasatdaglabs
parent 4f1b8c1248
commit a45c01f9ab

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")