mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
core/vm: fix modexp gas calculation
This commit is contained in:
parent
24c9f08c28
commit
5052910fba
1 changed files with 5 additions and 2 deletions
|
|
@ -469,9 +469,12 @@ func modexpIterationCount(expLen uint64, expHead uint256.Int, multiplier uint64)
|
|||
|
||||
// For large exponents (expLen > 32), add (expLen - 32) * multiplier
|
||||
if expLen > 32 {
|
||||
iterationCount = (expLen - 32) * multiplier
|
||||
carry, count := bits.Mul64(expLen-32, multiplier)
|
||||
if carry > 0 {
|
||||
return math.MaxUint64
|
||||
}
|
||||
iterationCount = count
|
||||
}
|
||||
|
||||
// Add the MSB position - 1 if expHead is non-zero
|
||||
if bitLen := expHead.BitLen(); bitLen > 0 {
|
||||
count, carry := bits.Add64(iterationCount, uint64(bitLen-1), 0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue