]> Cypherpunks repositories - gostls13.git/commit
math/big: handle negative moduli in ModInverse
authorBrian Kessler <brian.m.kessler@gmail.com>
Thu, 19 Apr 2018 15:08:24 +0000 (09:08 -0600)
committerRobert Griesemer <gri@golang.org>
Tue, 1 May 2018 00:04:28 +0000 (00:04 +0000)
commit6f7ec484f67b7128b4158babd48cbf47f4443f32
treeb8112daed1b470a5ee315b24c29dc63ed03987c5
parent4d44a87243576bef5ec1e083eb85fe766f79727d
math/big: handle negative moduli in ModInverse

Currently, there is no check for a negative modulus in ModInverse.
Negative moduli are passed internally to GCD, which returns 0 for
negative arguments. Mod is symmetric with respect to negative moduli,
so the calculation can be done by just negating the modulus before
passing the arguments to GCD.

Fixes #24949

Change-Id: Ifd1e64c9b2343f0489c04ab65504e73a623378c7
Reviewed-on: https://go-review.googlesource.com/108115
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
src/math/big/int.go
src/math/big/int_test.go