repeatedCubicLaw ellipticCurve point times modulus
    | result == Left Inf = Left Inf -- skip recursion
    | rem == 0           = square
    | otherwise          = squarePlus1
    where (half, rem)  = divMod times 2 
          result       = repeatedCubicLaw ellipticCurve point half modulus
          square       = either (\x -> cubicLaw ellipticCurve x x modulus) Right result
          squarePlus1  = either (\x -> cubicLaw ellipticCurve x point modulus) Right square
repeatedCubicLaw ellipticCurve point times modulus
    | result == Left Inf = Left Inf -- skip recursion
    | rem == 0           = square
    | otherwise          = squarePlus1
    where (half, rem)  = divMod times 2 
          result       = repeatedCubicLaw ellipticCurve point half modulus
          square       = either (\x -> cubicLaw ellipticCurve x x modulus) Right result
          squarePlus1  = either (\x -> cubicLaw ellipticCurve x point modulus) Right square
repeatedCubicLaw ellipticCurve point times modulus
    | result == Left Inf = Left Inf -- skip recursion
    | rem == 0           = square
    | otherwise          = squarePlus1
    where (half, rem)  = divMod times 2 
          result       = repeatedCubicLaw ellipticCurve point half modulus
          square       = either (\x -> cubicLaw ellipticCurve x x modulus) Right result
          squarePlus1  = either (\x -> cubicLaw ellipticCurve x point modulus) Right square