We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2640caa commit e5cf81fCopy full SHA for e5cf81f
eth/precompiles/modexp.py
@@ -122,7 +122,13 @@ def modexp(computation):
122
result = _modexp(computation.msg.data)
123
124
_, _, modulus_length = _extract_lengths(computation.msg.data)
125
- result_bytes = zpad_left(int_to_big_endian(result), to_size=modulus_length)
+
126
+ # Modulo 0 is undefined, return zero
127
+ # https://math.stackexchange.com/questions/516251/why-is-n-mod-0-undefined
128
+ result_bytes = b'' if modulus_length == 0 else zpad_left(
129
+ int_to_big_endian(result),
130
+ to_size=modulus_length
131
+ )
132
133
computation.output = result_bytes
134
return computation
0 commit comments