nim-codex/dagger/por/testpor.nim
Csaba Kiraly 9456aad233
por: reduce s and challenge size for test vector generation
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2022-06-09 02:31:48 +02:00

39 lines
1.1 KiB
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 por
import benchmark
import strutils
const sectorsperblock = 1.int64
const querylen = 1
proc testbls() : bool =
benchmark "Key generation":
let (spk, ssk) = por.keygen()
benchmark "Auth generation (s=" & $sectorsperblock & ")":
let (tau, authenticators) = por.setup(ssk, sectorsperblock, "example.txt")
echo "tau: ", tau
echo "Auth: ", authenticators
benchmark "Generating challenge (q=" & $querylen & ")":
let q = por.generateQuery(tau, spk, querylen)
echo "Generated!", "\nq:", q
benchmark "Issuing proof":
let (mu, sigma) = por.generateProof(q, authenticators, spk, sectorsperblock, "example.txt")
echo "Issued!", "\nmu:", mu, "\nsigma:", sigma
benchmark "Verifying proof":
result = por.verifyProof(tau, q, mu, sigma, spk)
echo "Result: ", result
let r = testbls()