File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ func ReadBits(bigint *big.Int, buf []byte) {
224224 }
225225}
226226
227- // U256 encodes as a 256 bit two's complement number. This operation is destructive.
227+ // U256 encodes x as a 256 bit two's complement number. This operation is destructive.
228228func U256 (x * big.Int ) * big.Int {
229229 return x .And (x , tt256m1 )
230230}
@@ -255,14 +255,15 @@ func S256(x *big.Int) *big.Int {
255255//
256256// Courtesy @karalabe and @chfast
257257func Exp (base , exponent * big.Int ) * big.Int {
258+ copyBase := new (big.Int ).Set (base )
258259 result := big .NewInt (1 )
259260
260261 for _ , word := range exponent .Bits () {
261262 for i := 0 ; i < wordBits ; i ++ {
262263 if word & 1 == 1 {
263- U256 (result .Mul (result , base ))
264+ U256 (result .Mul (result , copyBase ))
264265 }
265- U256 (base .Mul (base , base ))
266+ U256 (copyBase .Mul (copyBase , copyBase ))
266267 word >>= 1
267268 }
268269 }
You can’t perform that action at this time.
0 commit comments