optimize method in Run to get baseLen, expLen, modLen

This commit is contained in:
Kevaundray Wedderburn 2025-07-11 11:57:04 +01:00
parent 81184285ed
commit 4bc7187372

View file

@ -614,11 +614,19 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
} }
func (c *bigModExp) Run(input []byte) ([]byte, error) { func (c *bigModExp) Run(input []byte) ([]byte, error) {
var ( // Extract lengths - they're 32-byte big-endian integers
baseLen = new(uint256.Int).SetBytes(getData(input, 0, 32)).Uint64() // with the actual uint64 value in the last 8 bytes
expLen = new(uint256.Int).SetBytes(getData(input, 32, 32)).Uint64() var baseLen, expLen, modLen uint64
modLen = new(uint256.Int).SetBytes(getData(input, 64, 32)).Uint64() if len(input) >= 32 {
) baseLen = binary.BigEndian.Uint64(input[24:32])
}
if len(input) >= 64 {
expLen = binary.BigEndian.Uint64(input[56:64])
}
if len(input) >= 96 {
modLen = binary.BigEndian.Uint64(input[88:96])
}
if len(input) > 96 { if len(input) > 96 {
input = input[96:] input = input[96:]
} else { } else {