-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmark RLN proof generation/verification (#2410)
- Loading branch information
1 parent
2d46c35
commit e600203
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import | ||
math, | ||
std/sequtils, | ||
stew/results, | ||
options, | ||
../../waku/waku_rln_relay/protocol_types, | ||
../../waku/waku_rln_relay/rln, | ||
../../waku/waku_rln_relay, | ||
../../waku/waku_rln_relay/conversion_utils, | ||
../../waku/waku_rln_relay/group_manager/static/group_manager | ||
|
||
import std/[times, os] | ||
|
||
proc main(): Future[string] {.async, gcsafe.} = | ||
let rlnIns = createRLNInstance(20).get() | ||
let credentials = toSeq(0 .. 1000).mapIt(membershipKeyGen(rlnIns).get()) | ||
|
||
let manager = StaticGroupManager( | ||
rlnInstance: rlnIns, | ||
groupSize: 1000, | ||
membershipIndex: some(MembershipIndex(900)), | ||
groupKeys: credentials, | ||
) | ||
|
||
await manager.init() | ||
|
||
let data: seq[byte] = newSeq[byte](1024) | ||
|
||
var proofGenTimes: seq[times.Duration] = @[] | ||
var proofVerTimes: seq[times.Duration] = @[] | ||
for i in 0 .. 50: | ||
var time = getTime() | ||
let proof = manager.generateProof(data, getCurrentEpoch()).get() | ||
proofGenTimes.add(getTime() - time) | ||
|
||
time = getTime() | ||
let res = manager.verifyProof(data, proof).get() | ||
proofVerTimes.add(getTime() - time) | ||
|
||
echo "Proof generation times: ", sum(proofGenTimes) div len(proofGenTimes) | ||
echo "Proof verification times: ", sum(proofVerTimes) div len(proofVerTimes) | ||
|
||
when isMainModule: | ||
try: | ||
waitFor(main()) | ||
except CatchableError as e: | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters