Rln-Relay: Change tree depth to 20 (#726)

* adds instructions on how to generate parameters for a different tree size

* updates the depth of tree

* modifies the Merkle root

* updates parameters for the new tree size

* fixes failing tests

* updates the comment
This commit is contained in:
Sanaz Taheri Boshrooyeh 2021-09-28 12:03:53 -07:00 committed by GitHub
parent 645832e9fd
commit 696f41e12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View File

@ -246,7 +246,7 @@ procSuite "Waku rln relay":
debug "expected root ", expectedRoot
# start rln-relay
node.mountRelay()
node.mountRelay(@[RLNRELAY_PUBSUB_TOPIC])
await node.mountRlnRelay(ethClientAddrOpt = some(EthClient), ethAccAddrOpt = some(ethAccountAddress), memContractAddOpt = some(membershipContractAddress), groupOpt = some(group), memKeyPairOpt = some(keypair.get()), memIndexOpt = some(index), pubsubTopic = RLNRELAY_PUBSUB_TOPIC)
let calculatedRoot = node.wakuRlnRelay.rlnInstance.getMerkleRoot().value().toHex
debug "calculated root ", calculatedRoot
@ -280,7 +280,7 @@ procSuite "Waku rln relay":
let index = MembershipIndex(5)
# -------- mount rln-relay in the off-chain mode
node.mountRelay()
node.mountRelay(@[RLNRELAY_PUBSUB_TOPIC])
await node.mountRlnRelay(groupOpt = some(groupIDCommitments), memKeyPairOpt = some(groupKeyPairs[index]), memIndexOpt = some(index), onchainMode = false, pubsubTopic = RLNRELAY_PUBSUB_TOPIC)
# get the root of Merkle tree which is constructed inside the mountRlnRelay proc

View File

@ -44,7 +44,7 @@ type MembershipIndex* = uint
const
MEMBERSHIP_FEE* = 5.u256
# the current implementation of the rln lib only supports a circuit for Merkle tree with depth 32
MERKLE_TREE_DEPTH* = 32
MERKLE_TREE_DEPTH* = 20
# TODO the ETH_CLIENT should be an input to the rln-relay, though hardcoded for now
# the current address is the address of ganache-cli when run locally
ETH_CLIENT* = "ws://localhost:8540/"
@ -67,5 +67,5 @@ const
# STATIC_GROUP_MERKLE_ROOT is the root of the Merkle tree constructed from the STATIC_GROUP_KEYS above
# only identity commitments are used for the Merkle tree construction
# the root is created locally, using createMembershipList proc from waku_rln_relay_utils module, and the result is hardcoded in here
STATIC_GROUP_MERKLE_ROOT* = "25e03b7d551c3016cb21c057a113be5bf27eaa9b2529e806715bc0a1ef221e07"
STATIC_GROUP_MERKLE_ROOT* = "a1877a553eff12e1b21632a0545a916a5c5b8060ad7cc6c69956741134397b2d"

View File

@ -28,11 +28,15 @@ proc createRLNInstance*(d: int = MERKLE_TREE_DEPTH): RLNResult
var
rlnInstance: RLN[Bn256]
merkleDepth: csize_t = uint(d)
# parameters.key contains the parameters related to the Poseidon hasher
# to generate this file, clone this repo https://github.com/kilic/rln
# and run the following command in the root directory of the cloned project
# cargo run --example export_test_keys
# the file is generated separately and copied here
## parameters.key contains the prover and verifier keys
## to generate this file, clone this repo https://github.com/kilic/rln
## and run the following command in the root directory of the cloned project
## cargo run --example export_test_keys
## the file is generated separately and copied here
## parameters are function of tree depth and poseidon hasher
## to generate parameters for a different tree depth, change the tree size in the following line of rln library
## https://github.com/kilic/rln/blob/3bbec368a4adc68cd5f9bfae80b17e1bbb4ef373/examples/export_test_keys/main.rs#L4
## and then proceed as explained above
parameters = readFile("waku/v2/protocol/waku_rln_relay/parameters.key")
pbytes = parameters.toBytes()
len : csize_t = uint(pbytes.len)