----------------------------------------------------------------------------- -- | -- Module : -- Copyright : (c) Marcel Fourné 2009 -- License : BSD3 -- Maintainer : Marcel Fourné (hecc@bitrot.dyndns.org -- -- benchmarking playground, not production quality -- ----------------------------------------------------------------------------- import Codec.Encryption.ECC.Base --import Examples import Criterion.Main import Codec.Encryption.ECC.StandardCurves import Control.Monad.Random import Char testfkt:: (ECP a) => a -> Integer -> EC -> Int -> a testfkt b k' c n = pmul b ((toInteger (n-n)) + k') c main = do --{- let c = EC (stdc_a p256,stdc_b p256,stdc_p p256) -- k' = 78260987815077071890976764339238653408132491773166348437934213365482899760747 -- k' = 2^254+2^253+2^252+2^251+2^250 -- k' = 2^254+1 k' <- evalRandIO $ getRandomR (1,stdc_p p256) defaultMain [ bench "NIST P-256" $ whnf (testfkt (EPp (stdc_xp p256,stdc_yp p256,1)) k' c) 10 ] ---} {- let c = EC (stdc_a p521, stdc_b p521,stdc_p p521) k' = 1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984 in defaultMain [ bench "NIST P-521" $ whnf (testfkt (EPp (stdc_xp p521,stdc_yp p521,1)) k' c) 10 ] ---} {- let c = EC (stdc_a p256,stdc_b p256,stdc_p p256) k' = 115792089210356248762697446949407573529996955224135760342422259061068512044368 x = getx (pmul (EPp (stdc_xp p256, stdc_yp p256, 1)) k' c) c y = gety (pmul (EPp (stdc_xp p256, stdc_yp p256, 1)) k' c) c in print (x,y) ---} {- let p = 6277101735386680763835789423207666416083908700390324961279 a = 6277101735386680763835789423207666416083908700390324961276 b = 2455155546008943817740293915197451784769108058161191238065 c = EC (a,b,p) x = 602046282375688656758213480587526111916698976636884684818 y = 174050332293622031404857552280219410364023488927386650641 alpha = EPa (x,y) kprivA = 5114103500503308041454439524093827019673558354999860770782 kprivB = 1748161650263518407976227277807126651450677841379957675747 in defaultMain [ bench "ecdh" $ print [ (x,y)|x <-[1], y <- [(ecdh c alpha kprivA kprivB)]] ] ---}