Benchmarking script

This commit is contained in:
jude 2023-04-06 21:33:15 +01:00
parent eccf482192
commit cc2e1a618e
3 changed files with 69 additions and 1 deletions

View File

@ -181,5 +181,44 @@
<button id="ready-button">Not ready</button>
<button id="end-turn" class="hidden">End Turn</button>
</div>
<!-- Benchmarking script -->
<script>
function RSABench() {
console.log("Warming up")
for (let i = 0n; i < 100n; i++) {
window.rsa.pubKey.encrypt(i);
}
console.log("Benching")
performance.mark("rsa-start")
for (let i = 0n; i < 250n; i++) {
window.rsa.pubKey.encrypt(i);
}
performance.mark("rsa-end")
console.log(`Bench done. Duration: ${performance.measure("rsa-duration", "rsa-start", "rsa-end").duration}`)
}
function PaillierBench() {
console.log("Warming up")
for (let i = 0n; i < 100n; i++) {
window.paillier.pubKey.encrypt(i);
}
console.log("Benching")
performance.mark("paillier-start")
for (let i = 0n; i < 250n; i++) {
window.paillier.pubKey.encrypt(i);
}
performance.mark("paillier-end")
console.log(`Bench done. Duration: ${performance.measure("paillier-duration", "paillier-start", "paillier-end").duration}`)
}
</script>
</body>
</html>

Binary file not shown.

View File

@ -1,3 +1,5 @@
% !TeX document-id = {551c9545-e493-4534-9812-732e4f9d41b0}
% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]
\documentclass[12pt,a4paper]{report}
\usepackage{Bath-CS-Dissertation}
@ -5,6 +7,7 @@
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{minted}
\DeclareMathOperator{\lcm}{lcm}
\DeclareMathOperator{\id}{id}
@ -546,7 +549,33 @@ The size of the proof of zero communication is, in total, $3290 + 1744 + 2243$ c
\subsubsection{Time complexity}
It is generally remarked that Paillier performs considerably slower than RSA on all key sizes. %todo cite
It is remarked that Paillier encryption performs considerably slower than RSA on all key sizes. \cite{paillier1999public} provides a table of theoretic results, suggesting that Paillier encryption can be over 1,000 times slower than RSA for the same key size.
\cite{paillier1999public} also remarks that the choice of the public parameter $g$ can improve the time complexity. The selection of $g = n + 1$ is optimal in this regard, as binomial theorem allows the modular exponentiation $g^m \mod n^2$ to be reduced to the computation $1 + gm \mod n^2$.
These results are backed experimentally by my implementation. The following benchmarking code was executed.
\begin{minted}{javascript}
console.log("Warming up")
for (let i = 0n; i < 100n; i++) {
keyPair.pubKey.encrypt(i);
}
console.log("Benching")
performance.mark("start")
for (let i = 0n; i < 250n; i++) {
keyPair.pubKey.encrypt(i);
}
performance.mark("end")
console.log(performance.measure("duration", "start", "end").duration)
\end{minted}
Performing 250 Paillier encrypts required 49,100ms. On the other hand, performing 250 RSA encrypts required 60ms. This is a difference of over 1,000 times.
Decryption is remarked as being optimisable to constant time through application of Chinese Remainder Theorem.
\subsection{Quantum resistance}