Skip to content

Commit

Permalink
Update montgomery sub implementation (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla authored Apr 18, 2024
1 parent a07cc7d commit 89430dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion precompiles/EcPairing.yul
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ object "EcPairing" {
/// @param subtrahend The subtrahend in Montgomery form.
/// @return ret The result of the Montgomery addition.
function montgomerySub(minuend, subtrahend) -> ret {
ret := montgomeryAdd(minuend, sub(P(), subtrahend))
ret := sub(minuend, subtrahend)
if lt(minuend, subtrahend) {
ret := add(ret, P())
}
}

/// @notice Computes the Montgomery multiplication using the Montgomery reduction algorithm (REDC).
Expand Down

0 comments on commit 89430dc

Please sign in to comment.