Csaba Kiraly c52b3ac30a
draft test and benchmark code for BLS PoS
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2022-01-17 11:26:10 -06:00

37 lines
1017 B
Nim

## 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()