diff --git a/dagger/storageproofs/benchmark.nim b/dagger/storageproofs/benchmark.nim new file mode 100644 index 00000000..227542bd --- /dev/null +++ b/dagger/storageproofs/benchmark.nim @@ -0,0 +1,8 @@ +import times, strutils + +template benchmark*(benchmarkName: string, code: untyped) = + let t0 = epochTime() + code + let elapsed = epochTime() - t0 + let elapsedStr = elapsed.formatFloat(format = ffDecimal, precision = 3) + echo "CPU Time [", benchmarkName, "] ", elapsedStr, "s" diff --git a/dagger/storageproofs/testbls.nim b/dagger/storageproofs/testbls.nim new file mode 100644 index 00000000..390d3201 --- /dev/null +++ b/dagger/storageproofs/testbls.nim @@ -0,0 +1,36 @@ +## Nim-POS +## Copyright (c) 2021 Status Research & Development GmbH +## Licensed under either of +## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) +## * MIT license ([LICENSE-MIT](LICENSE-MIT)) +## at your option. +## This file may not be copied, modified, or distributed except according to +## those terms. + +import bls +import random +import benchmark +import strutils + +proc testbls() : bool = + benchmark "Key generation": + let (spk, ssk) = bls.keygen() + + benchmark "Auth generation": + let (tau, authenticators) = bls.st(ssk, "example.txt") + #echo "Auth: ", authenticators + + benchmark "Generating challenge...": + let q = bls.generateQuery(tau, spk) + #echo "Generated!" #, " q:", q + + benchmark "Issuing proof...": + let (mu, sigma) = bls.generateProof(q, authenticators, spk, "example.txt") + #echo "Issued!" #, " mu:", mu, " sigma:", sigma + + benchmark "Verifying proof...": + result = bls.verifyProof(tau, q, mu, sigma, spk) + echo "Result: ", result + +randomize() +let r = testbls()