mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-04 22:43:12 +00:00
draft test and benchmark code for BLS PoS
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
5ee331ac75
commit
c52b3ac30a
8
dagger/storageproofs/benchmark.nim
Normal file
8
dagger/storageproofs/benchmark.nim
Normal file
@ -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"
|
||||
36
dagger/storageproofs/testbls.nim
Normal file
36
dagger/storageproofs/testbls.nim
Normal file
@ -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()
|
||||
Loading…
x
Reference in New Issue
Block a user