-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
246 additions
and
149 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
import std/tempfiles | ||
|
||
import ../../../waku/waku_rln_relay/[rln, protocol_types] | ||
import | ||
../../../waku/waku_rln_relay, | ||
../../../waku/waku_rln_relay/[rln, protocol_types] | ||
|
||
proc createRLNInstanceWrapper*(): RLNResult = | ||
return createRlnInstance(tree_path = genTempPath("rln_tree", "waku_rln_relay")) | ||
|
||
|
||
proc unsafeAppendRLNProof*(rlnPeer: WakuRLNRelay, | ||
msg: var WakuMessage, | ||
senderEpochTime: float64): RlnRelayResult[void] = | ||
## this proc derived from unsafeAppendRLNProof, does not perform nonce check to | ||
## facilitate bad message id generation for testing | ||
|
||
let input = msg.toRLNSignal() | ||
let epoch = rlnPeer.calcEpoch(senderEpochTime) | ||
|
||
when defined(rln_v2): | ||
# we do not fetch a nonce from the nonce manager, | ||
# instead we use 0 as the nonce | ||
let proof = rlnPeer.groupManager.generateProof(input, epoch, 0).valueOr: | ||
return err("could not generate rln-v2 proof: " & $error) | ||
else: | ||
let proof = rlnPeer.groupManager.generateProof(input, epoch).valueOr: | ||
return err("could not generate rln proof: " & $error) | ||
|
||
msg.proof = proof.encode().buffer | ||
return ok() |
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
Oops, something went wrong.