mirror of https://github.com/waku-org/nwaku.git
feat(rln-relay): adds rln identifier to the RateLimitProof (#1219)
* adds rln identifier to the RateLimitProof * enables rln-relay compilation for wakunode2 * unifies the two RateLimitProof types * a minor update Co-authored-by: G <28568419+s1fr0@users.noreply.github.com>
This commit is contained in:
parent
dd1fe16568
commit
fe3a3136a3
|
@ -36,7 +36,7 @@ import
|
|||
export
|
||||
wakunode2_types
|
||||
|
||||
when defined(rln):
|
||||
when defined(rln) or defined(rlnzerokit):
|
||||
import ../protocol/waku_rln_relay/waku_rln_relay_utils
|
||||
|
||||
declarePublicCounter waku_node_messages, "number of messages received", ["type"]
|
||||
|
@ -1066,7 +1066,7 @@ when isMainModule:
|
|||
# Keepalive mounted on all nodes
|
||||
waitFor mountLibp2pPing(node)
|
||||
|
||||
when defined(rln):
|
||||
when defined(rln) or defined(rlnzerokit):
|
||||
if conf.rlnRelay:
|
||||
let res = node.mountRlnRelay(conf)
|
||||
if res.isErr():
|
||||
|
|
|
@ -32,6 +32,7 @@ type
|
|||
MerkleNode* = array[32, byte] # Each node of the Merkle tee is a Poseidon hash which is a 32 byte value
|
||||
Nullifier* = array[32, byte]
|
||||
Epoch* = array[32, byte]
|
||||
RlnIdentifier* = array[32, byte]
|
||||
|
||||
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)):
|
||||
type
|
||||
|
@ -39,7 +40,7 @@ when defined(rln) or (not defined(rln) and not defined(rlnzerokit)):
|
|||
when defined(rlnzerokit):
|
||||
type
|
||||
ZKSNARK* = array[128, byte]
|
||||
RlnIdentifier* = array[32, byte]
|
||||
|
||||
|
||||
# Custom data types defined for waku rln relay -------------------------
|
||||
type MembershipKeyPair* = object
|
||||
|
@ -51,45 +52,25 @@ type MembershipKeyPair* = object
|
|||
# more details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||
idCommitment*: IDCommitment
|
||||
|
||||
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)):
|
||||
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
|
||||
## the epoch used for the generation of the `proof`
|
||||
epoch*: Epoch
|
||||
## 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
|
||||
|
||||
when defined(rlnzerokit):
|
||||
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
|
||||
## the epoch used for the generation of the `proof`
|
||||
epoch*: Epoch
|
||||
## 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
|
||||
## Application specific RLN Identifier
|
||||
rlnIdentifier*: RlnIdentifier
|
||||
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
|
||||
## the epoch used for the generation of the `proof`
|
||||
epoch*: Epoch
|
||||
## 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
|
||||
## Application specific RLN Identifier
|
||||
rlnIdentifier*: RlnIdentifier
|
||||
|
||||
type MembershipIndex* = uint
|
||||
|
||||
|
@ -182,11 +163,10 @@ proc init*(T: type RateLimitProof, buffer: seq[byte]): ProtoResult[T] =
|
|||
var nullifier: seq[byte]
|
||||
discard ? pb.getField(6, nullifier)
|
||||
discard nsp.nullifier.copyFrom(nullifier)
|
||||
|
||||
when defined(rlnzerokit):
|
||||
var rlnIdentifier: seq[byte]
|
||||
discard ? pb.getField(7, rlnIdentifier)
|
||||
discard nsp.rlnIdentifier.copyFrom(rlnIdentifier)
|
||||
|
||||
var rlnIdentifier: seq[byte]
|
||||
discard ? pb.getField(7, rlnIdentifier)
|
||||
discard nsp.rlnIdentifier.copyFrom(rlnIdentifier)
|
||||
|
||||
return ok(nsp)
|
||||
|
||||
|
@ -199,10 +179,8 @@ proc encode*(nsp: RateLimitProof): ProtoBuffer =
|
|||
output.write3(4, nsp.shareX)
|
||||
output.write3(5, nsp.shareY)
|
||||
output.write3(6, nsp.nullifier)
|
||||
|
||||
when defined(rlnzerokit):
|
||||
output.write3(7, nsp.rlnIdentifier)
|
||||
output.write3(7, nsp.rlnIdentifier)
|
||||
|
||||
output.finish3()
|
||||
|
||||
return output
|
||||
return output
|
||||
|
|
Loading…
Reference in New Issue