commit 16d6515d798a24b0f9e3de204cd3da08763d6557 parent f0fd1290bbc87259ce8bfd930d59bcbdc1cb4539 Author: Jared Tobin <jared@jtobin.io> Date: Wed, 16 Oct 2024 23:28:36 +0400 lib: more speedy/concise unroll elusive Diffstat:
M | lib/Crypto/Curve/Secp256k1.hs | | | 9 | +++++---- |
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/Crypto/Curve/Secp256k1.hs b/lib/Crypto/Curve/Secp256k1.hs @@ -69,9 +69,10 @@ import GHC.Generics import GHC.Natural import qualified GHC.Num.Integer as I --- note the use of GHC.Num.Integer-qualified functions throughout --- this module; in some cases explicit use of these functions yields --- tremendous speedups compared to more general versions +-- note the use of GHC.Num.Integer-qualified functions throughout this +-- module; in some cases explicit use of these functions (especially +-- I.integerPowMod# and I.integerRecipMod#) yields tremendous speedups +-- compared to more general versions -- keystroke savers & other utilities ----------------------------------------- @@ -108,7 +109,7 @@ roll = BS.foldl' alg 0 where unroll :: Integer -> BS.ByteString unroll i = case i of 0 -> BS.singleton 0 - _ -> BS.reverse $ BS.unfoldr step i -- XX looks slow + _ -> BS.reverse $ BS.unfoldr step i where step 0 = Nothing step m = Just (fi m, m `I.integerShiftR` 8)