This commit is contained in:
jude 2023-04-29 16:35:17 +01:00
parent cceb6dee90
commit 0fed48b79d
5 changed files with 65 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import { mod_exp } from "./math.js";
export const KEY_SIZE = 512;
export const KEY_SIZE = 1024;
export function cryptoRandom(bits) {
if (bits === undefined) {

View File

@ -1,7 +1,7 @@
import { cryptoRandom } from "../crypto/random_primes.js";
import { Region } from "./map.js";
const ROUNDS = 12;
const ROUNDS = 24;
function cryptoRange(upper) {
// This is ridiculous: why implement a BigInt primitive, have it behave like a number, and then _not_ offer
@ -603,16 +603,10 @@ export function proveFortify(fortify) {
}
}
let rangeProofs = {};
for (let r of regionNames) {
rangeProofs[r] = proveBitLength(Region.getRegion(r).strength.cipherText);
}
return {
fortify: fortify,
proofs: proofs,
verifications: verifications,
rangeProofs: rangeProofs,
};
}

View File

@ -368,6 +368,61 @@
console.log(`Bench done. Time per verification: ${performance.measure("rv-duration", "rv-start", "rv-end").duration / ROUNDS}`)
}
function FortifyProofBench() {
console.log("Warming up")
const ct = {
A: paillier.pubKey.encrypt(0n),
B: paillier.pubKey.encrypt(3n),
C: paillier.pubKey.encrypt(-3n),
D: paillier.pubKey.encrypt(0n),
E: paillier.pubKey.encrypt(0n)
}
const ROUNDS = 20;
for (let i = 0; i < 5; i++) {
proveFortify(ct)
}
console.log("Benching")
performance.mark("fp-start")
for (let i = 0; i < ROUNDS; i++) {
proveFortify(ct)
}
performance.mark("fp-end")
console.log(`Bench done. Time per proof: ${performance.measure("fp-duration", "fp-start", "fp-end").duration / ROUNDS}`)
}
function FortifyVerifierBench() {
console.log("Warming up")
const ROUNDS = 20;
const ct = {
A: paillier.pubKey.encrypt(0n),
B: paillier.pubKey.encrypt(3n),
C: paillier.pubKey.encrypt(-3n),
D: paillier.pubKey.encrypt(0n),
E: paillier.pubKey.encrypt(0n)
}
let proof = proveFortify(ct)
for (let i = 0; i < 5; i++) {
verifyFortify(proof, paillier.pubKey)
}
console.log("Benching")
performance.mark("rv-start")
for (let i = 0; i < ROUNDS; i++) {
verifyFortify(proof, paillier.pubKey)
}
performance.mark("rv-end")
console.log(`Bench done. Time per verification: ${performance.measure("rv-duration", "rv-start", "rv-end").duration / ROUNDS}`)
}
// https://gist.github.com/kawanet/352a2ed1d1656816b2bc
function string_to_buffer(src) {
return (new Uint16Array([].map.call(src, function(c) {

Binary file not shown.

View File

@ -1148,20 +1148,21 @@ All measurements were taken on Brave 1.50.114 (Chromium 112.0.5615.49) 64-bit, u
\begin{table}
\fontsize{10pt}{10pt}\selectfont
\caption{Time\parnote{$|n| = 4096$ uses a less-optimised encryption method, as the browser frequently timed out attempting to pre-compute for the more-optimised version.} to process non-interactive proofs}
\begin{tabularx}{\hsize}{c *8{>{\Centering}X}}
\begin{tabularx}{\hsize}{c *8{>{\Centering}X} *2{>{\Centering}X}}
\toprule
\multirow{2}{*}{Modulus} &
\multicolumn{2}{c}{\hyperref[protocol0]{Protocol~\ref*{protocol0}}} &
\multicolumn{2}{c}{\hyperref[protocol1]{Protocol~\ref*{protocol1}} with $t = 24$} &
\multicolumn{2}{c}{BCDG Range with $t = 24$} &
\multicolumn{2}{c}{\hyperref[protocol4]{Protocol~\ref*{protocol4}} with $t = 24$}
\multicolumn{2}{c}{\hyperref[protocol4]{Protocol~\ref*{protocol4}} with $t = 24$} &
\multicolumn{2}{c}{\hyperref[protocol3]{Protocol~\ref*{protocol3}} with $t = 24$}
\tabularnewline
\cmidrule(l){2-3}\cmidrule(l){4-5}\cmidrule(l){6-7}\cmidrule(l){8-9}
& Prover & Verifier & Prover & Verifier & Prover & Verifier & Prover & Verifier \\
\cmidrule(l){2-3}\cmidrule(l){4-5}\cmidrule(l){6-7}\cmidrule(l){8-9}\cmidrule(l){10-11}
& Prover & Verifier & Prover & Verifier & Prover & Verifier & Prover & Verifier & Prover & Verifier \\
\midrule
$|n| = 1024$ & 10ms & 18ms & 1,420ms & 2,140ms & 443ms & 655ms & 3,530ms & 5,310ms \\
$|n| = 2048$ & 44ms & 68ms & 6,390ms & 8,140ms & 1,980ms & 2,400ms & 15,800ms & 19,000ms \\
$|n| = 4096$ & 225ms & 292ms & 41,500ms & 34,400ms & 14,300ms & 11,400ms & 112,000ms & 79,300ms \\
$|n| = 1024$ & 10ms & 18ms & 1,420ms & 2,140ms & 443ms & 655ms & 3,530ms & 5,310ms & 1,350ms & 2,070ms \\
$|n| = 2048$ & 44ms & 68ms & 6,390ms & 8,140ms & 1,980ms & 2,400ms & 15,800ms & 19,000ms & 5,800ms & 7,790ms \\
$|n| = 4096$ & 225ms & 292ms & 41,500ms & 34,400ms & 14,300ms & 11,400ms & 112,000ms & 79,300ms & & \\
\bottomrule
\end{tabularx}
\parnotes