From b6337e9b66ee87682a80194d60b797754324a7a4 Mon Sep 17 00:00:00 2001 From: jangko Date: Thu, 3 Aug 2023 12:10:38 +0700 Subject: [PATCH] fix modexp bug --- nimbus/evm/modexp.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nimbus/evm/modexp.nim b/nimbus/evm/modexp.nim index 70f0983d6..c1f20c232 100644 --- a/nimbus/evm/modexp.nim +++ b/nimbus/evm/modexp.nim @@ -186,9 +186,6 @@ proc modExp*(b, e, m: openArray[byte]): seq[byte] = if m.len == 0: return @[0.byte] - if e.len == 0: - return @[1.byte] - if mp_init_multi(base, exp.addr, modulo.addr, nil) != MP_OKAY: return @@ -209,6 +206,9 @@ proc modExp*(b, e, m: openArray[byte]): seq[byte] = # For all x != 0, x^0 == 1 as well mp_clear_multi(base, exp.addr, modulo.addr, nil) return @[1.byte] + else: + mp_clear_multi(base, exp.addr, modulo.addr, nil) + return @[1.byte] if b.len > 0: discard mp_from_ubin(base, b[0].getPtr, b.len.csize_t)