Skip to content

Commit

Permalink
update to benchmark to include size analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Oct 11, 2024
1 parent 03826d7 commit b9ecaee
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 29 deletions.
11 changes: 9 additions & 2 deletions test/benchmark/bbs/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
ZENROOM ?= ../../../zenroom

all: keygen.png sign_verify.png zkp.png entropy.png
../../../src/zenroom -l common.lua sizes.lua

sizes:
@echo '{"total":200,"step":5,"fraction":4,"size":64}' > params.json
@$(ZENROOM) -l common.lua -a params.json sizes.lua > sizes.txt
@rm -f params.json
sed 's/TERM/pngcairo dashed rounded size 1024,768/' \
$(basename $@).gnuplot | gnuplot > $(basename $@).png

%.png: %.txt %.gnuplot
sed 's/TERM/pngcairo dashed rounded size 1024,768/' \
Expand All @@ -11,7 +18,7 @@ all: keygen.png sign_verify.png zkp.png entropy.png
$(basename $@).gnuplot | gnuplot > $(basename $@).eps

%.txt:
../../../src/zenroom -l common.lua ${basename $@}.lua | tee $@
$(ZENROOM) -l common.lua ${basename $@}.lua | tee $@

clean:
rm -f *.txt *.png *.eps
8 changes: 8 additions & 0 deletions test/benchmark/bbs/sizes.gnuplot
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set notitle
set terminal TERM
set key left nobox
set style data points
set autoscale
set xlabel "credentials"
set ylabel "bytes"
plot for [col=2:4] "sizes.txt" using 0:col:xticlabels(1) with lines linetype 8 dashtype col title columnheader
92 changes: 65 additions & 27 deletions test/benchmark/bbs/sizes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,69 @@ print 'BBS+ size benchmarks'
print ''

B3 = BBS.ciphersuite'shake256'
local T, start
start = os.clock()

local kp = keygen(B3)
print('TIME: '..os.clock()-start)
I.print(kp)
print''


local m = { OCTET.random(512) }
local i = { 1 }

start = os.clock()
local signed = sign(B3, kp, m)
print('TIME: '..os.clock()-start)
I.print({signature=signed})
print''

start = os.clock()
local proof = create_proof(B3, kp.pk, signed, m, i)
print('TIME: '..os.clock()-start)
I.print({proof=proof})
print''

print'verification'
disclosed = disclosed_messages(m, i)
start = os.clock()
assert( verify_proof(B3, kp.pk, proof, disclosed, i) )
print('TIME: '..os.clock()-start)

function create_index(count, max)
local numbers = {}
local uniqueNumbers = {}
while #uniqueNumbers < count do
local num = random16()%max
if num == 0 then num=num+1 end
if not numbers[num] then
numbers[num] = true
table.insert(uniqueNumbers, num)
end
end
return uniqueNumbers
end


function test_bbs_credential_size(total, step, fraction, msgsize)
local CREDS_T = { }
local PROOF_T = { }
local creds = { }
printerr('Testing '..total..' credentials at step '..step
..' fraction '..fraction..' message size '..msgsize)
for i=step,total+step,step do
-- print('generate credentials: '..i)
for c=1,i,1 do
-- table.insert(creds, OCTET.random(random16()))
table.insert(creds, OCTET.random(msgsize))
end
-- print'sign credentials'
local signed = sign(B3, kp, creds)
local subset = math.floor(i/fraction)
if subset == 0 then subset=1 end
-- print('generate indexes: '..i/2)
local q = tostring(i)
local indexes = create_index(subset,i)
table.insert(CREDS_T,q)
-- I.print(indexes)
-- print('creds: generate proofs'
local proof = create_proof(B3, kp.pk, signed, creds, indexes)
-- print({proof=proof})
table.insert(PROOF_T,#proof)
-- print'present disclosures'
-- local disclosed = disclosed_messages(creds, indexes)
-- -- print'verify disclosed proofs'
-- assert( verify_proof(B3, kp.pk, proof, disclosed, indexes) )
printerr(q.." ")
collectgarbage'collect'
end
print""
return({CREDS = CREDS_T, PROOF = PROOF_T})
end

P = JSON.decode(DATA)


TEST_100_10_2 = test_bbs_credential_size(P.total,P.step,P.fraction,P.size)

print("CREDS \t PROOF")
for k,v in pairs(TEST_100_10_2.CREDS) do
write(v)
write(' \t ')
write(TEST_100_10_2.PROOF[k])
write('\n')
end

0 comments on commit b9ecaee

Please sign in to comment.