Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed Jan 25, 2022
1 parent 3b9eafb commit 3892615
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/Cryptol/PrimeEC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ module Cryptol.PrimeEC
) where


{-
import GHC.Num.BigNat (BigNat#)
import qualified GHC.Num.Backend as BN
import qualified GHC.Num.BigNat as BN
import qualified GHC.Num.Integer as BN
-}
import GHC.Num.Compat (BigNat#)
import qualified GHC.Num.Compat as BN
import GHC.Exts
Expand Down
6 changes: 6 additions & 0 deletions src/GHC/Num/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ import GHC.Exts
bigNatToInteger :: BigNat# -> Integer
bigNatToInteger = Integer.integerFromBigNat#

-- | @'integerRecipMod' x m@ computes the modular inverse of @x@ mod @m@.
--
-- PRECONDITION: @m@ must be strictly positive.
integerRecipMod :: Integer -> Integer -> Maybe Integer
integerRecipMod x y =
case Integer.integerRecipMod# x (Integer.integerToNaturalClamp y) of
Expand Down Expand Up @@ -134,6 +137,9 @@ integerToBigNat (GMP.S# i) = GMP.wordToBigNat (int2Word# i)
integerToBigNat (GMP.Jp# b) = b
integerToBigNat (GMP.Jn# b) = b

-- | @'integerRecipMod' x m@ computes the modular inverse of @x@ mod @m@.
--
-- PRECONDITION: @m@ must be strictly positive.
integerRecipMod :: Integer -> Integer -> Maybe Integer
integerRecipMod x y
| res == 0 = Nothing
Expand Down

0 comments on commit 3892615

Please sign in to comment.