nwaku/waku/waku_rln_relay/protocol_types.nim

128 lines
3.7 KiB
Nim
Raw Normal View History

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
2021-07-22 08:43:41 +00:00
import std/[options, tables, deques], stew/arrayops, chronos, web3, eth/keys
import ../waku_core, ../waku_keystore, ../common/protobuf
export waku_keystore, waku_core
type RlnRelayResult*[T] = Result[T, string]
## RLN is a Nim wrapper for the data types used in zerokit RLN
type RLN* {.incompleteStruct.} = object
type RLNResult* = RlnRelayResult[ptr RLN]
chore|feat (waku-rln-relay): modules reorganization|Initial test for capturing events using nim-web3 (#941) * first edition * adds the full test scenario * fixes typos * fixes a bug in the supplied command * further edits the description * displays the chat prompt after spam detection * updates changelog * minor wording fix * adds a new test file for onchain rln relay * adds the Event proc * adds one working example of event subscription * defines a new unitt test for event subscription * adds the new test file * cleans up the code * adds a working event subscription for faucet contract * wip * makes faucet test conditional * updates contract byte codes * adds a working test for event subscription and cleans up the tests * fixes case * adss toUInt256 unit function * enables the tests * fixes a bug * undo commented tests * cleans up the test * logs the pk * removes excess entry in the changelog * fixes spacing * comments * removes unused test codes * adds the conditional compilation for onchain tests * uncomments offchain tests * removes onchain tests * reorganizes the code and moves the rln contract data into a separate module * deletes txt files * beautifies the code * beautifies the code * removes an excess line * more formatting fixes * minor fix * updates the case of membership fee const * renames compare to diff * renames time to e * edits the number of arguments of the send proc * fixes a comment alignment * fixes indentation * fixed id style * splits check from condition * fixes a naming mismatch
2022-05-10 21:09:18 +00:00
type
MerkleNode* = array[32, byte]
# Each node of the Merkle tee is a Poseidon hash which is a 32 byte value
chore|feat (waku-rln-relay): modules reorganization|Initial test for capturing events using nim-web3 (#941) * first edition * adds the full test scenario * fixes typos * fixes a bug in the supplied command * further edits the description * displays the chat prompt after spam detection * updates changelog * minor wording fix * adds a new test file for onchain rln relay * adds the Event proc * adds one working example of event subscription * defines a new unitt test for event subscription * adds the new test file * cleans up the code * adds a working event subscription for faucet contract * wip * makes faucet test conditional * updates contract byte codes * adds a working test for event subscription and cleans up the tests * fixes case * adss toUInt256 unit function * enables the tests * fixes a bug * undo commented tests * cleans up the test * logs the pk * removes excess entry in the changelog * fixes spacing * comments * removes unused test codes * adds the conditional compilation for onchain tests * uncomments offchain tests * removes onchain tests * reorganizes the code and moves the rln contract data into a separate module * deletes txt files * beautifies the code * beautifies the code * removes an excess line * more formatting fixes * minor fix * updates the case of membership fee const * renames compare to diff * renames time to e * edits the number of arguments of the send proc * fixes a comment alignment * fixes indentation * fixed id style * splits check from condition * fixes a naming mismatch
2022-05-10 21:09:18 +00:00
Nullifier* = array[32, byte]
Epoch* = array[32, byte]
RlnIdentifier* = array[32, byte]
ZKSNARK* = array[128, byte]
when defined(rln_v2):
type
MessageId* = uint64
ExternalNullifier* = array[32, byte]
type RateCommitment* = object
idCommitment*: IDCommitment
userMessageLimit*: UserMessageLimit
# Custom data types defined for waku rln relay -------------------------
type RateLimitProof* = object
## RateLimitProof holds the public inputs to rln circuit as
## defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Public-Inputs
## the `proof` field carries the actual zkSNARK proof
proof*: ZKSNARK
## the root of Merkle tree used for the generation of the `proof`
merkleRoot*: MerkleNode
## shareX and shareY are shares of user's identity key
## these shares are created using Shamir secret sharing scheme
## see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Linear-Equation-amp-SSS
shareX*: MerkleNode
shareY*: MerkleNode
## nullifier enables linking two messages published during the same epoch
## see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Nullifiers
nullifier*: Nullifier
## the epoch used for the generation of the `proof`
epoch*: Epoch
## Application specific RLN Identifier
rlnIdentifier*: RlnIdentifier
when defined(rln_v2):
## the external nullifier used for the generation of the `proof` (derived from poseidon([epoch, rln_identifier]))
externalNullifier*: ExternalNullifier
type ProofMetadata* = object
nullifier*: Nullifier
shareX*: MerkleNode
shareY*: MerkleNode
externalNullifier*: Nullifier
type
MessageValidationResult* {.pure.} = enum
Valid
Invalid
Spam
MerkleNodeResult* = RlnRelayResult[MerkleNode]
RateLimitProofResult* = RlnRelayResult[RateLimitProof]
# Protobufs enc and init
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
proc init*(T: type RateLimitProof, buffer: seq[byte]): ProtoResult[T] =
var nsp: RateLimitProof
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
let pb = initProtoBuffer(buffer)
var proof: seq[byte]
discard ?pb.getField(1, proof)
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
discard nsp.proof.copyFrom(proof)
var merkleRoot: seq[byte]
discard ?pb.getField(2, merkleRoot)
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
discard nsp.merkleRoot.copyFrom(merkleRoot)
var epoch: seq[byte]
discard ?pb.getField(3, epoch)
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
discard nsp.epoch.copyFrom(epoch)
var shareX: seq[byte]
discard ?pb.getField(4, shareX)
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
discard nsp.shareX.copyFrom(shareX)
var shareY: seq[byte]
discard ?pb.getField(5, shareY)
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
discard nsp.shareY.copyFrom(shareY)
var nullifier: seq[byte]
discard ?pb.getField(6, nullifier)
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
discard nsp.nullifier.copyFrom(nullifier)
var rlnIdentifier: seq[byte]
discard ?pb.getField(7, rlnIdentifier)
discard nsp.rlnIdentifier.copyFrom(rlnIdentifier)
chore|feat (waku-rln-relay): modules reorganization|Initial test for capturing events using nim-web3 (#941) * first edition * adds the full test scenario * fixes typos * fixes a bug in the supplied command * further edits the description * displays the chat prompt after spam detection * updates changelog * minor wording fix * adds a new test file for onchain rln relay * adds the Event proc * adds one working example of event subscription * defines a new unitt test for event subscription * adds the new test file * cleans up the code * adds a working event subscription for faucet contract * wip * makes faucet test conditional * updates contract byte codes * adds a working test for event subscription and cleans up the tests * fixes case * adss toUInt256 unit function * enables the tests * fixes a bug * undo commented tests * cleans up the test * logs the pk * removes excess entry in the changelog * fixes spacing * comments * removes unused test codes * adds the conditional compilation for onchain tests * uncomments offchain tests * removes onchain tests * reorganizes the code and moves the rln contract data into a separate module * deletes txt files * beautifies the code * beautifies the code * removes an excess line * more formatting fixes * minor fix * updates the case of membership fee const * renames compare to diff * renames time to e * edits the number of arguments of the send proc * fixes a comment alignment * fixes indentation * fixed id style * splits check from condition * fixes a naming mismatch
2022-05-10 21:09:18 +00:00
return ok(nsp)
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
chore|feat (waku-rln-relay): modules reorganization|Initial test for capturing events using nim-web3 (#941) * first edition * adds the full test scenario * fixes typos * fixes a bug in the supplied command * further edits the description * displays the chat prompt after spam detection * updates changelog * minor wording fix * adds a new test file for onchain rln relay * adds the Event proc * adds one working example of event subscription * defines a new unitt test for event subscription * adds the new test file * cleans up the code * adds a working event subscription for faucet contract * wip * makes faucet test conditional * updates contract byte codes * adds a working test for event subscription and cleans up the tests * fixes case * adss toUInt256 unit function * enables the tests * fixes a bug * undo commented tests * cleans up the test * logs the pk * removes excess entry in the changelog * fixes spacing * comments * removes unused test codes * adds the conditional compilation for onchain tests * uncomments offchain tests * removes onchain tests * reorganizes the code and moves the rln contract data into a separate module * deletes txt files * beautifies the code * beautifies the code * removes an excess line * more formatting fixes * minor fix * updates the case of membership fee const * renames compare to diff * renames time to e * edits the number of arguments of the send proc * fixes a comment alignment * fixes indentation * fixed id style * splits check from condition * fixes a naming mismatch
2022-05-10 21:09:18 +00:00
proc encode*(nsp: RateLimitProof): ProtoBuffer =
Integrates proof generation and verification into wakunode2 (#735) * WIP * WIP: fixes a bug * adds test for static group formation * adds static group creation when rln-relay is enabled * adds createStatic group * wip: adds group formation to mount rlnrelay * adds createMembershipList utility function * adds doc strings and todos * cleans up the code and add comments * defaults createRLNInstance depth argument to 32 * renames Depth * distinguishes between onchain and offchain modes * updates index boundaries * updates log levels * updates docstring * updates log level of displayed membership keys * relocates a todo * activates all the tests * fixes some comments and todos * extracts some utils procs for better debugging * adds todo * moves calculateMerkleRoot and toMembersipKeyPairs to the rln utils * makes calls to the utils functions * adds unit test for createMembershipList * adds unittest for toMembershipKeyPairs and calcMerkleRoot * cleans up the code and fixes tree root value * reverts an unwanted change * minor * adds comments and cleans up the code * updates config message * adds more comments * fixes a minor value mismatch * edits the size of group * minor rewording * defines a const var for the group keys * replaces the sequence literal with the StaticGroupKeys const * adds a rudimentary unittest * adds todos * adds more comment * replaces uint with MembeshipIndex type * fixes rln relay mem index config message * adds rln relay setup proc * decouples relay and rln-relay * uses MemIndexType instead of uint * brings back the rlnRelayEnabled flag to mountRlnRelay * deletes commented codes * adds rln relay topic validator inside updates rln relay mounting procedure * adds rln-relay-pubsub-topic cli option * adds a static rln-relay topic * deletes rlnrelayEnabled argument * adds pubsub topic for rln-relay * deletes static pubsub topic * mounts relay before rlnrelay in the tests * logs rln relay pubsub topic * cleans up the code * edits rlnrelay setup * uninitializes the input parameter of rlnrelay setup * adds comments * removes unused comments * compiles addRLNRelayValidtor when RLN compilation flag is set * adds comment about topic validator * minor * mode modifications on the description of add validator * adds pubsubtopic field to wakuRlnRelay type * WIP: shaping the test * Checks whether rln relay pubsub topic is within the supported topics of relay protocol * minor * WIP: unit test for actual proof * fixes a bug * removes a redundant proc * refines the test for actual proof * breaks lines to 80 chars * defines NonSpamProof type * adds a return * defines Epoch type * WIP: proof gen * implements actual proof gen * adds proto enc and init * adds notes about proof structure * adds NonSpamProof to wakumessage * adds proof gen * WIP: non working tests for protobuf * fixes the protobuf encoding issue * discards the output of copyFrom * WIP: hash unittest and proofVrfy and ProofGen * integrates proofVrfy * uses toBuffer inside the hash proc * adds comment * fixes a bug * removes proof field initialization * cleans up the test * generalizes input from byte seq to byte openArray * adds toBuffer * adds a bad test * cleans up unused tests * adds integration test * adds comments * cleans up * adds description to the integration test * adds test for unhappy path * tides up the tests * tides up hash unit test * renames a few var * uses a const for wku rln relay pubsub topic * minor refinement * deletes an obsolete comment * comment revision * adds comments * cleans up and adds docstrings * profGen returns proofRes instead of proof * removes extra sleepAsync * fixes two bugs * returns reject when proof is not verified\ * addresses comments * adds comments * links to rln doc * more comments * fixes space format * uncomments v2 tests * dnsclient branch update * undo branch update * minor spacing fix * makes proof field conditional
2021-10-20 00:37:29 +00:00
var output = initProtoBuffer()
output.write3(1, nsp.proof)
output.write3(2, nsp.merkleRoot)
output.write3(3, nsp.epoch)
output.write3(4, nsp.shareX)
output.write3(5, nsp.shareY)
output.write3(6, nsp.nullifier)
output.write3(7, nsp.rlnIdentifier)
output.finish3()
return output
type
SpamHandler* =
proc(wakuMessage: WakuMessage): void {.gcsafe, closure, raises: [Defect].}
RegistrationHandler* =
proc(txHash: string): void {.gcsafe, closure, raises: [Defect].}