fix modexp output, GST +53
This commit is contained in:
parent
89402af114
commit
fd7c447f18
4546
GeneralStateTests.md
4546
GeneralStateTests.md
File diff suppressed because it is too large
Load Diff
|
@ -165,16 +165,22 @@ proc modExpInternal(computation: BaseComputation, base_len, exp_len, mod_len: in
|
|||
result[0] = 1
|
||||
|
||||
# Start with EVM special cases
|
||||
if modulo <= 1:
|
||||
# If m == 0: EVM returns 0.
|
||||
# If m == 1: we can shortcut that to 0 as well
|
||||
computation.rawOutput = @(zero())
|
||||
elif exp.isZero():
|
||||
# If 0^0: EVM returns 1
|
||||
# For all x != 0, x^0 == 1 as well
|
||||
computation.rawOutput = @(one())
|
||||
let output = if modulo <= 1:
|
||||
# If m == 0: EVM returns 0.
|
||||
# If m == 1: we can shortcut that to 0 as well
|
||||
zero()
|
||||
elif exp.isZero():
|
||||
# If 0^0: EVM returns 1
|
||||
# For all x != 0, x^0 == 1 as well
|
||||
one()
|
||||
else:
|
||||
powmod(base, exp, modulo).toByteArrayBE
|
||||
|
||||
if output.len >= mod_len:
|
||||
computation.rawOutput = @(output[^mod_len..^1])
|
||||
else:
|
||||
computation.rawOutput = @(powmod(base, exp, modulo).toByteArrayBE)
|
||||
computation.rawOutput = newSeq[byte](mod_len)
|
||||
computation.rawOutput[^output.len..^1] = output[0..^1]
|
||||
|
||||
proc modExp*(computation: BaseComputation) =
|
||||
## Modular exponentiation precompiled contract
|
||||
|
|
|
@ -20,38 +20,14 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
|
|||
"CreateOOGafterInitCodeReturndataSize.json",
|
||||
"RevertInCreateInInit.json",
|
||||
|
||||
"modexpRandomInput.json",
|
||||
"modexp_9_37111_37111_1000000.json",
|
||||
"modexp_3_5_100_25000.json",
|
||||
"modexp_3_09984_39936_155000.json",
|
||||
"modexp_37120_37111_0_1000000.json",
|
||||
"modexp.json",
|
||||
"modexp_55190_55190_42965_20500.json",
|
||||
"modexp_39936_1_55201_20500.json",
|
||||
"modexp_55190_55190_42965_22000.json",
|
||||
"modexp_39936_1_55201_1000000.json",
|
||||
"modexp_3_09984_39936_25000.json",
|
||||
"modexp_3_5_100_22000.json",
|
||||
"modexp_37120_37111_1_1000000.json",
|
||||
"modexp_3_5_100_35000.json",
|
||||
"modexp_3_5_100_1000000.json",
|
||||
"modexp_3_09984_39936_1000000.json",
|
||||
"modexp_3_28948_11579_20500.json",
|
||||
"modexp_55190_55190_42965_25000.json",
|
||||
"modexp_3_09984_39936_35000.json",
|
||||
"modexp_3_09984_39936_22000.json",
|
||||
"modexp_55190_55190_42965_155000.json",
|
||||
"modexp_55190_55190_42965_1000000.json",
|
||||
"modexp_55190_55190_42965_35000.json",
|
||||
"modexp_3_5_100_20500.json",
|
||||
"modexp_39936_1_55201_35000.json",
|
||||
"modexp_39936_1_55201_25000.json",
|
||||
"modexp_37120_37111_97_1000000.json",
|
||||
"modexp_3_5_100_155000.json",
|
||||
"modexp_39936_1_55201_22000.json",
|
||||
"modexpRandomInput.json",
|
||||
"modexp_modsize0_returndatasize.json",
|
||||
"modexp_9_37111_37111_1000000.json",
|
||||
"modexp_37120_37111_0_1000000.json",
|
||||
"modexp_37120_37111_1_1000000.json",
|
||||
"modexp_37120_37111_97_1000000.json",
|
||||
"modexp_37120_37111_37111_1000000.json",
|
||||
"modexp_39936_1_55201_155000.json",
|
||||
|
||||
"ecpairing_perturb_g2_by_field_modulus_again.json",
|
||||
"ecpairing_perturb_zeropoint_by_field_modulus.json",
|
||||
|
|
Loading…
Reference in New Issue