packages feed

hecc 0.3.1 → 0.3.2

raw patch · 2 files changed

+15/−6 lines, 2 filesdep ~repaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: repa

API changes (from Hackage documentation)

Files

hecc.cabal view
@@ -1,5 +1,5 @@ Name:                hecc-Version:             0.3.1+Version:             0.3.2 Synopsis:	     Elliptic Curve Cryptography for Haskell Description:         Pure math & algorithms for Elliptic Curve Cryptography in Haskell License:             BSD3@@ -10,7 +10,7 @@ Category:	     Cryptography Stability:	     alpha Build-Type:          Simple-Cabal-Version:       >=1.2+Cabal-Version:       >=1.6 Data-Files:	     README Extra-Source-Files:  src/bench.hs 		     src/Examples.hs@@ -24,7 +24,7 @@ --  binary, --  cereal,   crypto-api,-  repa,+  repa == 3.0.*,   vector  Exposed-modules:   Codec.Crypto.ECC.Base
src/Codec/Crypto/ECC/F2.hs view
@@ -5,7 +5,7 @@ -- License     :  BSD3 -- Maintainer  :  Marcel Fourné (hecc@bitrot.dyndns.org) ----- F(2^e)-Backend+-- A parallelized F(2^e) backend -- ----------------------------------------------------------------------------- @@ -42,6 +42,7 @@                                                        else False)-} c == c' = c Prelude.== c' +-- |a custom XOR for the "bits", True being 1 and False being 0 bxor :: Bool -> Bool -> Bool bxor a b | a Prelude.== False = b          | a Prelude.== True = not b@@ -112,6 +113,7 @@                   in elimFalses pre  -- too much overhead, unroll for the only cases used: k = 2 and k = 3+-- | the power function, @b@ ^ @k@, atm only specialised for k in {2,3} f2ePow :: Array U DIM1 Bool -> Integer -> Array U DIM1 Bool {-f2ePow b k =   let zwo = (f2eFromInteger 2)@@ -125,7 +127,7 @@            | otherwise = b  -+-- | a helper function to fill the representation of @a@ with "0" up towards a length of @n@ fillTo :: Array U DIM1 Bool -> Int -> Array U DIM1 Bool fillTo a n = let vec = toUnboxed a                  l = V.length vec@@ -133,12 +135,14 @@                 then fromUnboxed (Z :. n) $ (V.replicate (n-l) False) V.++ vec                 else a +-- | a helper function to shorten @a@ to length @n@ shortenTo :: Array U DIM1 Bool -> Int -> Array U DIM1 Bool shortenTo a n = let vec = toUnboxed a                     l = V.length vec                     n' = abs n                 in fromUnboxed (Z :. n') $ V.drop (l - n') vec                    +-- | a helper function to shorten all leading "0" from @a@ elimFalses :: Array U DIM1 Bool -> Array U DIM1 Bool elimFalses a = let v = toUnboxed a                    i = V.length v@@ -147,16 +151,19 @@                                    else n                in shortenTo a (helper i) +-- |the binary representation of an Integer binary :: Integer -> String binary = flip (showIntAtBase (2::Integer) intToDigit) [] +-- |conversion helper function f2eFromInteger :: Integer -> Array U DIM1 Bool f2eFromInteger z = let helper a = if a Prelude.== '1' then True                                   else False                        bin = binary z                        len = length bin                    in fromListUnboxed (Z :. len) $ L.map helper bin-                      ++-- |conversion helper function                       f2eToInteger :: Array U DIM1 Bool -> Integer f2eToInteger z = let helper a = if a Prelude.== True then 1                                 else 0@@ -167,6 +174,7 @@                                     else n                  in it vec 0 +-- | test @k@ if bit on position @i@ is set f2eTestBit :: Array U DIM1 Bool -> Int -> Bool f2eTestBit k i = let l = V.length $ toUnboxed k                  in if i >= 0 && l >= 0 && i <= l then index k (Z :. i)@@ -184,4 +192,5 @@                             else helper (elimFalses (u `f2eAdd` (f2eBitshift v j))) v (elimFalses (g1 `f2eAdd` (f2eBitshift g2 j))) g2                in helper a f (f2eFromInteger 1) (f2eFromInteger 0) +-- |helper function to get the length of @a@ f2eLen a = V.length $ toUnboxed a