mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-15 17:35:45 +00:00
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
|
export
|
||||||
wakunode2_types
|
wakunode2_types
|
||||||
|
|
||||||
when defined(rln):
|
when defined(rln) or defined(rlnzerokit):
|
||||||
import ../protocol/waku_rln_relay/waku_rln_relay_utils
|
import ../protocol/waku_rln_relay/waku_rln_relay_utils
|
||||||
|
|
||||||
declarePublicCounter waku_node_messages, "number of messages received", ["type"]
|
declarePublicCounter waku_node_messages, "number of messages received", ["type"]
|
||||||
@ -1066,7 +1066,7 @@ when isMainModule:
|
|||||||
# Keepalive mounted on all nodes
|
# Keepalive mounted on all nodes
|
||||||
waitFor mountLibp2pPing(node)
|
waitFor mountLibp2pPing(node)
|
||||||
|
|
||||||
when defined(rln):
|
when defined(rln) or defined(rlnzerokit):
|
||||||
if conf.rlnRelay:
|
if conf.rlnRelay:
|
||||||
let res = node.mountRlnRelay(conf)
|
let res = node.mountRlnRelay(conf)
|
||||||
if res.isErr():
|
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
|
MerkleNode* = array[32, byte] # Each node of the Merkle tee is a Poseidon hash which is a 32 byte value
|
||||||
Nullifier* = array[32, byte]
|
Nullifier* = array[32, byte]
|
||||||
Epoch* = array[32, byte]
|
Epoch* = array[32, byte]
|
||||||
|
RlnIdentifier* = array[32, byte]
|
||||||
|
|
||||||
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)):
|
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)):
|
||||||
type
|
type
|
||||||
@ -39,7 +40,7 @@ when defined(rln) or (not defined(rln) and not defined(rlnzerokit)):
|
|||||||
when defined(rlnzerokit):
|
when defined(rlnzerokit):
|
||||||
type
|
type
|
||||||
ZKSNARK* = array[128, byte]
|
ZKSNARK* = array[128, byte]
|
||||||
RlnIdentifier* = array[32, byte]
|
|
||||||
|
|
||||||
# Custom data types defined for waku rln relay -------------------------
|
# Custom data types defined for waku rln relay -------------------------
|
||||||
type MembershipKeyPair* = object
|
type MembershipKeyPair* = object
|
||||||
@ -51,45 +52,25 @@ type MembershipKeyPair* = object
|
|||||||
# more details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
# more details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||||
idCommitment*: IDCommitment
|
idCommitment*: IDCommitment
|
||||||
|
|
||||||
when defined(rln) or (not defined(rln) and not defined(rlnzerokit)):
|
type RateLimitProof* = object
|
||||||
type RateLimitProof* = object
|
## RateLimitProof holds the public inputs to rln circuit as
|
||||||
## RateLimitProof holds the public inputs to rln circuit as
|
## defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Public-Inputs
|
||||||
## defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Public-Inputs
|
## the `proof` field carries the actual zkSNARK proof
|
||||||
## the `proof` field carries the actual zkSNARK proof
|
proof*: ZKSNARK
|
||||||
proof*: ZKSNARK
|
## the root of Merkle tree used for the generation of the `proof`
|
||||||
## the root of Merkle tree used for the generation of the `proof`
|
merkleRoot*: MerkleNode
|
||||||
merkleRoot*: MerkleNode
|
## the epoch used for the generation of the `proof`
|
||||||
## the epoch used for the generation of the `proof`
|
epoch*: Epoch
|
||||||
epoch*: Epoch
|
## shareX and shareY are shares of user's identity key
|
||||||
## shareX and shareY are shares of user's identity key
|
## these shares are created using Shamir secret sharing scheme
|
||||||
## these shares are created using Shamir secret sharing scheme
|
## see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Linear-Equation-amp-SSS
|
||||||
## see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Linear-Equation-amp-SSS
|
shareX*: MerkleNode
|
||||||
shareX*: MerkleNode
|
shareY*: MerkleNode
|
||||||
shareY*: MerkleNode
|
## nullifier enables linking two messages published during the same epoch
|
||||||
## nullifier enables linking two messages published during the same epoch
|
## see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Nullifiers
|
||||||
## see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Nullifiers
|
nullifier*: Nullifier
|
||||||
nullifier*: Nullifier
|
## Application specific RLN Identifier
|
||||||
|
rlnIdentifier*: RlnIdentifier
|
||||||
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 MembershipIndex* = uint
|
type MembershipIndex* = uint
|
||||||
|
|
||||||
@ -182,11 +163,10 @@ proc init*(T: type RateLimitProof, buffer: seq[byte]): ProtoResult[T] =
|
|||||||
var nullifier: seq[byte]
|
var nullifier: seq[byte]
|
||||||
discard ? pb.getField(6, nullifier)
|
discard ? pb.getField(6, nullifier)
|
||||||
discard nsp.nullifier.copyFrom(nullifier)
|
discard nsp.nullifier.copyFrom(nullifier)
|
||||||
|
|
||||||
when defined(rlnzerokit):
|
var rlnIdentifier: seq[byte]
|
||||||
var rlnIdentifier: seq[byte]
|
discard ? pb.getField(7, rlnIdentifier)
|
||||||
discard ? pb.getField(7, rlnIdentifier)
|
discard nsp.rlnIdentifier.copyFrom(rlnIdentifier)
|
||||||
discard nsp.rlnIdentifier.copyFrom(rlnIdentifier)
|
|
||||||
|
|
||||||
return ok(nsp)
|
return ok(nsp)
|
||||||
|
|
||||||
@ -199,10 +179,8 @@ proc encode*(nsp: RateLimitProof): ProtoBuffer =
|
|||||||
output.write3(4, nsp.shareX)
|
output.write3(4, nsp.shareX)
|
||||||
output.write3(5, nsp.shareY)
|
output.write3(5, nsp.shareY)
|
||||||
output.write3(6, nsp.nullifier)
|
output.write3(6, nsp.nullifier)
|
||||||
|
output.write3(7, nsp.rlnIdentifier)
|
||||||
when defined(rlnzerokit):
|
|
||||||
output.write3(7, nsp.rlnIdentifier)
|
|
||||||
|
|
||||||
output.finish3()
|
output.finish3()
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user