Skip to content

Commit

Permalink
Add extra checks to fix some edge cases (matter-labs#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla authored Sep 21, 2023
1 parent 062fbcf commit 6ff795d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions precompiles/Modexp.yul
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ object "ModExp" {
return(0, 0)
}

// Workaround to handle the case when all inputs are 0
if eq(calldatasize(), 96) {
return(0, modulus_length)
}

// Handle a special case when both the base and mod length is zero
if and(iszero(base_length), iszero(modulus_length)) {
return(0, 0)
}

if and(iszero(base_length), iszero(exponent_length)) {
return(0, modulus_length)
}

let base_pointer := 96
let base_padding := sub(WORD_SIZE(), base_length)
let padded_base_pointer := add(96, base_padding)
Expand Down

0 comments on commit 6ff795d

Please sign in to comment.