0

I have an assignment of implementing RSA for my cryptography course. One of the requirements is to plot the encryption time vs size of n, where n is the product of two large primes p and q in bits. Now I have this

benchmarks ::ByteString-> [(Int,ByteStrings)]
benchmarks str = zip keySizeList  cipherTexts

      smallestKeySize = calcKeySize testStringInt

      keySizeList = [smallestKeySize + 1 .. 10 * smallestKeySize]

      primePairs = [genPrimePairs nbits | nbits <- keySizeList]

      cipherTexts = [rsaEncryptionVsTime str (p, q) | (p, q) <- primePairs]

-- genPrimes, generates a pair of primes
-- smallestKeySize, the smallest integer i such that testStringInt < 2^i.
-- keySizeList , a list of integers denoting the number of bits in n, where n=p*q, p,q are two primes.
-- testStringInt, the integer representation of strings is a number in base 256
-- rsaEncryptionVsTime, is a function that calculates {e,n}, the public key, then calls encrypt

How can I obtain a list of encryption time vs key size in a form that can be plotted, and how can I plot it?

Kareem Taha
  • 107
  • 1
  • 6
  • It sounds like you're looking for [Criterion](https://hackage.haskell.org/package/criterion). – Louis Wasserman May 22 '22 at 16:27
  • Well, I tried to benchmark it using criterion, I couldn't get it work with required scheme of having a list of values and the corresponding evaluation time, I ended up using criterion's getCPUTime and a deepseq call. – Kareem Taha May 22 '22 at 22:55
  • Have you tried to use the search before asking? This question has been answered before, although the answers are not exciting: you either get the measurements from criterion and plot manually (e.g. with gnuplot, see https://stackoverflow.com/q/20334597/465100) or try to resurrect the `complexity` package (see https://stackoverflow.com/q/17421709/465100). – Artem Pelenitsyn May 23 '22 at 16:06
  • @KareemTaha you are right, I should have just provided the links. I’m sorry, please accept my apology. As for marking it as a dup, I don’t believe I have enough of karma/badges/whatever for this. Also, if you will have any trouble with either of the proposed approach, I hope you post a new question with which I could be more helpful. – Artem Pelenitsyn May 23 '22 at 23:17
  • 1
    The answer with the gnu plot did the trick, thanks for caring. – Kareem Taha May 25 '22 at 00:10

0 Answers0