44 lines
1.6 KiB
Nim
44 lines
1.6 KiB
Nim
|
# Constantine
|
||
|
# Copyright (c) 2018-2019 Status Research & Development GmbH
|
||
|
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy
|
||
|
# Licensed and distributed under either of
|
||
|
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
|
||
|
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||
|
|
||
|
import
|
||
|
../constantine/ethereum_evm_precompiles,
|
||
|
std/unittest
|
||
|
|
||
|
suite "EVM ModExp precompile (EIP-198)":
|
||
|
test "Audit #5 - Fuzz failure with even modulus":
|
||
|
let input = [
|
||
|
|
||
|
# Length of base (1)
|
||
|
uint8 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||
|
|
||
|
# Length of exponent (1)
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||
|
|
||
|
# Length of modulus (1)
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||
|
|
||
|
# Base
|
||
|
0x06,
|
||
|
|
||
|
# Exponent
|
||
|
0x02,
|
||
|
|
||
|
# Modulus
|
||
|
0x04
|
||
|
]
|
||
|
|
||
|
var r = newSeq[byte](1)
|
||
|
let status = r.eth_evm_modexp(input)
|
||
|
doAssert status == cttEVM_Success
|
||
|
doAssert r[0] == 0, ". Result was " & $r[0]
|