fix: waku2 store queries
This commit is contained in:
parent
938e7987ca
commit
bf04ff3502
4
go.mod
4
go.mod
|
@ -54,7 +54,7 @@ require (
|
||||||
github.com/prometheus/client_golang v1.12.1
|
github.com/prometheus/client_golang v1.12.1
|
||||||
github.com/russolsen/transit v0.0.0-20180705123435-0794b4c4505a
|
github.com/russolsen/transit v0.0.0-20180705123435-0794b4c4505a
|
||||||
github.com/status-im/doubleratchet v3.0.0+incompatible
|
github.com/status-im/doubleratchet v3.0.0+incompatible
|
||||||
github.com/status-im/go-waku v0.2.3-0.20221003200721-1b3e23cf4e0b
|
github.com/status-im/go-waku v0.2.3-0.20221005220914-22c049dfd68b
|
||||||
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880
|
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880
|
||||||
github.com/status-im/markdown v0.0.0-20220622180305-7ee4aa8bbc3f
|
github.com/status-im/markdown v0.0.0-20220622180305-7ee4aa8bbc3f
|
||||||
github.com/status-im/migrate/v4 v4.6.2-status.2
|
github.com/status-im/migrate/v4 v4.6.2-status.2
|
||||||
|
@ -241,7 +241,7 @@ require (
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e // indirect
|
github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e // indirect
|
||||||
github.com/status-im/go-multiaddr-ethv4 v1.2.3 // indirect
|
github.com/status-im/go-multiaddr-ethv4 v1.2.3 // indirect
|
||||||
github.com/status-im/go-rln v0.1.1 // indirect
|
github.com/status-im/go-zerokit-rln v0.1.3 // indirect
|
||||||
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 // indirect
|
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.6 // indirect
|
github.com/tklauser/go-sysconf v0.3.6 // indirect
|
||||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -2107,14 +2107,14 @@ github.com/status-im/go-ethereum v1.10.4-status.4 h1:Cs0MoHEhF0LEwii2R8U8jMSEW/g
|
||||||
github.com/status-im/go-ethereum v1.10.4-status.4/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE=
|
github.com/status-im/go-ethereum v1.10.4-status.4/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE=
|
||||||
github.com/status-im/go-multiaddr-ethv4 v1.2.3 h1:EdMt0rCVcue9zQ3TZoUVrKel0HG+RfbuqY94PXd3AWk=
|
github.com/status-im/go-multiaddr-ethv4 v1.2.3 h1:EdMt0rCVcue9zQ3TZoUVrKel0HG+RfbuqY94PXd3AWk=
|
||||||
github.com/status-im/go-multiaddr-ethv4 v1.2.3/go.mod h1:xgjMcsI3pNezwNVlUnUmaDLVmtT871/OOqnEUublHKQ=
|
github.com/status-im/go-multiaddr-ethv4 v1.2.3/go.mod h1:xgjMcsI3pNezwNVlUnUmaDLVmtT871/OOqnEUublHKQ=
|
||||||
github.com/status-im/go-rln v0.1.1 h1:Evbma0GZ0dgzbKcm92SWzHMZ4pOlVBxH1+z9eQAd1i4=
|
github.com/status-im/go-waku v0.2.3-0.20221005220914-22c049dfd68b h1:KPuv6Hq4gShubVcN9fIoVqWqTxhTXlLDuGmqRi6ZZFo=
|
||||||
github.com/status-im/go-rln v0.1.1/go.mod h1:t8Bf4nNAuQh9VlEiz/rgFVtEz7sjEfcd62MIuEnZn8U=
|
github.com/status-im/go-waku v0.2.3-0.20221005220914-22c049dfd68b/go.mod h1:k7Oq24HcXqc6hcMGSCdlLMOZK/eWthdH8PXoKgcX0EU=
|
||||||
github.com/status-im/go-waku v0.2.3-0.20221003200721-1b3e23cf4e0b h1:fdqbDyjjdTw2WVPuNtywTtrhg0KjBmuyEuXsCcjkjyc=
|
|
||||||
github.com/status-im/go-waku v0.2.3-0.20221003200721-1b3e23cf4e0b/go.mod h1:yHFOjS30GLuCiS+UqblYd46McaorFlwMQ3tM32aofSU=
|
|
||||||
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 h1:Ggyf88sYbHV3q/qVNMNsq+JMiar1WRkiDTr+VdTPyVk=
|
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 h1:Ggyf88sYbHV3q/qVNMNsq+JMiar1WRkiDTr+VdTPyVk=
|
||||||
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880/go.mod h1:lYUCd41Gzh6bw8RYlbADWe+LQCvhxnq2e19QWxdDM0k=
|
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880/go.mod h1:lYUCd41Gzh6bw8RYlbADWe+LQCvhxnq2e19QWxdDM0k=
|
||||||
github.com/status-im/go-watchdog v1.2.0-ios-nolibproc h1:BJwZEF7OVKaXc2zErBUAolFSGzwrTBbWnN8e/6MER5E=
|
github.com/status-im/go-watchdog v1.2.0-ios-nolibproc h1:BJwZEF7OVKaXc2zErBUAolFSGzwrTBbWnN8e/6MER5E=
|
||||||
github.com/status-im/go-watchdog v1.2.0-ios-nolibproc/go.mod h1:lzSbAl5sh4rtI8tYHU01BWIDzgzqaQLj6RcA1i4mlqI=
|
github.com/status-im/go-watchdog v1.2.0-ios-nolibproc/go.mod h1:lzSbAl5sh4rtI8tYHU01BWIDzgzqaQLj6RcA1i4mlqI=
|
||||||
|
github.com/status-im/go-zerokit-rln v0.1.3 h1:3UxA29BoMPlBrXw1Cddubmq4XR96ihH9KpnwfzzPtq4=
|
||||||
|
github.com/status-im/go-zerokit-rln v0.1.3/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
|
||||||
github.com/status-im/gomoji v1.1.3-0.20220213022530-e5ac4a8732d4 h1:CtobZoiNdHpx+xurFxnuJ1xsGm3oKMfcZkB3vmomJmA=
|
github.com/status-im/gomoji v1.1.3-0.20220213022530-e5ac4a8732d4 h1:CtobZoiNdHpx+xurFxnuJ1xsGm3oKMfcZkB3vmomJmA=
|
||||||
github.com/status-im/gomoji v1.1.3-0.20220213022530-e5ac4a8732d4/go.mod h1:hmpnZzkzSZJbFYWAUkrPV8I36x7mdYiPhPqnALP4fKA=
|
github.com/status-im/gomoji v1.1.3-0.20220213022530-e5ac4a8732d4/go.mod h1:hmpnZzkzSZJbFYWAUkrPV8I36x7mdYiPhPqnALP4fKA=
|
||||||
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
|
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2021 Dean Eigenmann
|
|
||||||
Copyright (c) 2022 Status Research & Development GmbH
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -1,37 +0,0 @@
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
typedef struct RLN_Bn256 RLN_Bn256;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Buffer struct is taken from
|
|
||||||
* https://github.com/celo-org/celo-threshold-bls-rs/blob/master/crates/threshold-bls-ffi/src/ffi.rs
|
|
||||||
*/
|
|
||||||
typedef struct Buffer {
|
|
||||||
const uint8_t *ptr;
|
|
||||||
uintptr_t len;
|
|
||||||
} Buffer;
|
|
||||||
|
|
||||||
bool new_circuit_from_params(uintptr_t merkle_depth,
|
|
||||||
const struct Buffer *parameters_buffer,
|
|
||||||
struct RLN_Bn256 **ctx);
|
|
||||||
|
|
||||||
bool get_root(const struct RLN_Bn256 *ctx, struct Buffer *output_buffer);
|
|
||||||
|
|
||||||
bool update_next_member(struct RLN_Bn256 *ctx, const struct Buffer *input_buffer);
|
|
||||||
|
|
||||||
bool delete_member(struct RLN_Bn256 *ctx, uintptr_t index);
|
|
||||||
|
|
||||||
bool generate_proof(const struct RLN_Bn256 *ctx,
|
|
||||||
const struct Buffer *input_buffer,
|
|
||||||
struct Buffer *output_buffer);
|
|
||||||
|
|
||||||
bool verify(const struct RLN_Bn256 *ctx, const struct Buffer *proof_buffer, uint32_t *result_ptr);
|
|
||||||
|
|
||||||
bool signal_to_field(const struct RLN_Bn256 *ctx,
|
|
||||||
const struct Buffer *inputs_buffer,
|
|
||||||
struct Buffer *output_buffer);
|
|
||||||
|
|
||||||
bool key_gen(const struct RLN_Bn256 *ctx, struct Buffer *input_buffer);
|
|
|
@ -1,233 +0,0 @@
|
||||||
package rln
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/binary"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IDKey is an identity key as defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
|
||||||
type IDKey = [32]byte
|
|
||||||
|
|
||||||
// IDCommintment is hash of identity key as defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
|
||||||
type IDCommitment = [32]byte
|
|
||||||
|
|
||||||
// Each node of the Merkle tee is a Poseidon hash which is a 32 byte value
|
|
||||||
type MerkleNode = [32]byte
|
|
||||||
|
|
||||||
type Nullifier = [32]byte
|
|
||||||
|
|
||||||
type ZKSNARK = [256]byte
|
|
||||||
|
|
||||||
// Custom data types defined for waku rln relay -------------------------
|
|
||||||
|
|
||||||
type MembershipKeyPair = struct {
|
|
||||||
// user's identity key (a secret key) which is selected randomly
|
|
||||||
// see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
|
||||||
IDKey IDKey
|
|
||||||
// hash of user's identity key generated by
|
|
||||||
// Poseidon hash function implemented in rln lib
|
|
||||||
// more details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
|
||||||
IDCommitment IDCommitment
|
|
||||||
}
|
|
||||||
|
|
||||||
type RateLimitProof struct {
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
|
||||||
type MembershipIndex = uint
|
|
||||||
|
|
||||||
type ProofMetadata struct {
|
|
||||||
Nullifier Nullifier
|
|
||||||
ShareX MerkleNode
|
|
||||||
ShareY MerkleNode
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p ProofMetadata) Equals(p2 ProofMetadata) bool {
|
|
||||||
return bytes.Equal(p.Nullifier[:], p2.Nullifier[:]) && bytes.Equal(p.ShareX[:], p2.ShareX[:]) && bytes.Equal(p.ShareY[:], p2.ShareY[:])
|
|
||||||
}
|
|
||||||
|
|
||||||
// the current implementation of the rln lib only supports a circuit for Merkle tree with depth 32
|
|
||||||
const MERKLE_TREE_DEPTH int = 20
|
|
||||||
|
|
||||||
// HASH_BIT_SIZE is the size of poseidon hash output in bits
|
|
||||||
const HASH_BIT_SIZE = 256
|
|
||||||
|
|
||||||
// HASH_HEX_SIZE is the size of poseidon hash output as the number of bytes
|
|
||||||
const HASH_HEX_SIZE = int(HASH_BIT_SIZE / 8)
|
|
||||||
|
|
||||||
// temporary variables to test waku-rln-relay performance in the static group mode
|
|
||||||
|
|
||||||
const STATIC_GROUP_SIZE = 100
|
|
||||||
|
|
||||||
// STATIC_GROUP_KEYS is a static list of 100 membership keys in the form of (identity key, identity commitment)
|
|
||||||
// keys are created locally, using createMembershipList proc from waku_rln_relay_utils module, and the results are hardcoded in here
|
|
||||||
// this list is temporary and is created to test the performance of waku-rln-relay for the static groups
|
|
||||||
// in the later versions, this static hardcoded group will be replaced with a dynamic one
|
|
||||||
var STATIC_GROUP_KEYS [][]string
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
STATIC_GROUP_KEYS = [][]string{
|
|
||||||
{"e9a4d05b1f539d65c59015a079ee89aabeafbcfc9734342d9559f81601e85417", "b74d3a5b3200ab1126fbee393496f33da497d4d9a7c56693f44d6155c0c34e13"},
|
|
||||||
{"27b2bfc25257e53819beaf36ce1070007e04e7aad2e440a1f1fc066f59a61123", "522ce51aff96041e79a8476f508fb9661f146f189e288f83cb4837517cfc0127"},
|
|
||||||
{"66392eaae6674267c55fe393d39443ba90317a709d6e8f92a9f3e4abc18eff1d", "e3dc235e48c1811943fc249fecd0f1415a50ebe839ccefb0bd820a76fb77ba2a"},
|
|
||||||
{"e7462eebb81405230db8014b052d65fe7b269c3870e40b12cf64668ed6c2d40e", "727df0965e34144ea637be18208cc81e57e423010b3159c20f0ccff45c42212a"},
|
|
||||||
{"1ad8528b4c7075013a2d6561a02517b0482c0733dc018ac68774db857deb5004", "5df3a77577135784da2a9ee78f5026092b7d6bb9e6e95882d6cb172c0cb62208"},
|
|
||||||
{"aa0ff53bfc50861f871d94df18c3ac0b97f44ceb13436b33490cec5f6ce8e700", "30421d05b905aeaec0473ba29ace034bf73c406866d7dc23007eb9c34a596827"},
|
|
||||||
{"0448c0a6ed57b177c4c45de478b58d29f24e7ea842814305443e87188ae24324", "5ea1a704d8972af5a028367c8e3fb48ee61a603c6ea3a4c9247b0f611a6ab002"},
|
|
||||||
{"4b6a6edbdd11e69befe3f4a3c976baca320c4bcb188f129b603ebb198f663000", "451d6185e8ad2c8873f034683b9caca43ea7ceb1b839abd3e01c3f19f3e6bd1e"},
|
|
||||||
{"c3fba34855b33f025696326d2980ddc3fb47d90459ed6a4488fbb2e4e12ccf2b", "74674a86144ea866ad8fe633e256783bda4a07b997cb412c53a5eaf4cc7b6a0e"},
|
|
||||||
{"0c35b8b94a720f1c26d7c6241c9f3ea5332a87cf3730b25ef31b68854c10e405", "6915df8d8ad19ec17be37c299eed762f9b63e841cd7963e13e8db6890dba082d"},
|
|
||||||
{"a60b021677da95ba46c8c3411ac77f3e3b06937a8d189517111c045880029909", "bbfcd22ecb44cec6fd0717cd0f21b26e6e8b2c91e1a6cb5d8610e2f2ad41c90f"},
|
|
||||||
{"2f4d662e66fbe754b708b87ea3d75a01d2ea4d7bf33c615c2376211dcc3b560f", "c67f7e622c3293028b9f86571e82c49551eb5fd308a35eb663498cffac208810"},
|
|
||||||
{"d90a1afa96c14c8d3b989a9cf23d6e8b9907da42724e44a3ac74ae015b6ce22e", "f0795b1bdd0a907252b6ab047642d97be076a16ea69d463f1a4bec00c817202e"},
|
|
||||||
{"dfa0764d89c8da10777504e5274f1baccf8b4145deba72b26503474318fb6410", "9f8aa8e833ea2f13cccfb6d9f2f04fd7be9c9f3019540c05c1986b3bce254e25"},
|
|
||||||
{"e17490013b6b53a40964ff1067b922d4d73521e32fe394527b39c1bfd4a5e712", "7a8fa23a0e4b14a36f2818a7d98639f6e4934c028da780a6cc658fbf76e80a26"},
|
|
||||||
{"7a9328d1075373dddb1b1100e8217ffaa1f9b632911b95a8fdc08870b15a8410", "94b2ae70c046b94873098c19fe18e7b17db2d31fe6a7eb73fea8168395e3c122"},
|
|
||||||
{"ce319bb1447da5bf51a88ab3379dbea539b5a431d3c4f131048cf7b05c52161d", "cdfa264ab8a51bbc9fff5732cf544bb06abba7e807a8c252a5f9ce785c6ff22c"},
|
|
||||||
{"d3818503bfcbef9ca03fc4472be77cb4936a1720001fc5e54852f769448fd313", "e72792abd906976c75a5670de514894a720c5293cf74338a9c2987640a949c0b"},
|
|
||||||
{"4f9b8d118460736eb62602d12d3aed62938d4d4374b8c88704cf40c415c0901e", "2ecbe4588ade31924a1053fe0204950a0b4924878b312e56b2d0522f92a5f01c"},
|
|
||||||
{"39b59fd96adaf9633edcc8cef10049cddf5f7df8ac80af8aafa436d62ee7f905", "b94f7a979df8a95fc2766a9a96308ff39a14daf7b7d6bc48591d2ea4c764bf00"},
|
|
||||||
{"73cb0d25995d182b361c8237852bafeab8bb951de99f730da2913a239400c322", "da04e6e4446b6bcd54667b741444d826abbc5b76572d28474dfa94db91144606"},
|
|
||||||
{"2753423b83bba5bb8b2799bc58125c46fb03ec05e8579d772cdc6e75b0875009", "ee040010ec20e7293431a3692d06416f71162d176a316b0329a76edf6f3fb30d"},
|
|
||||||
{"cb73ec9b67355ce6275b51144a0759de28bb9390aab20514ee49a3bd8ce5361b", "c7c6e2ad3efe1f03b398241bddb67b008dd5e8caf1a17db9c33d2e2388d58e0d"},
|
|
||||||
{"bdb386d9f3fe5613ede926d80246682a5d32392f7f6c9d818a80d8e7a12e371b", "21d48c74f422ef72cb9db18799916b3c11d0cb99cec808563e2db22047840902"},
|
|
||||||
{"60f2fcfe341034449046c1fa330f6aceff737a9837a7d6d3a4885f8afce4a809", "e4c8f26f9e4127511b5ab21f1705913d7beaa2767cb7d033564e36bd2693370c"},
|
|
||||||
{"1223d64fb5c44921c1ae66d91543780634c2f7bae7e184e09c4e5447e6d1180b", "290ab84714fc3534c5ba22b2aa7696ac03ed12c9cf1c409a777bac05475ea406"},
|
|
||||||
{"b79c593316c42280d316bb7f3b43c7a5f5e29786d1ca6c0424463470eefe2b2f", "f4e44ac9574c4d32ab403e71dd00554eee0d8e34d04611b66ab2e59c49bff025"},
|
|
||||||
{"e6548f669ebe655cb6600432e1af14c43da7286e3620289b51cc947517db9c14", "ace261e3964a1dcb389a693f52104018cd475e6856ae37fe4892df9482954902"},
|
|
||||||
{"81be54409c9364f4842209e0f79b190afd9df017cc9790e11196d4bf5108f100", "d986b22e422703e065f12b6fd608813028ff913d4ffeb54b19e6537456391b23"},
|
|
||||||
{"940ff0d3b4549d1baf7ad900cf6aedde02833b777e39c411e6efe7bcdd2ef305", "d672bb8a6e75b47fdbb365de0516f3fa827b287c9666e64d1b6768e2c8949412"},
|
|
||||||
{"b4fe300aa1c8c836b3cc4c167df86d08fb7213200b8d9f7ba7963170e6dc8c0a", "5f7db6a9867f3f5c9fd1955c02cf96056d1225be950cd432818f8f1c16152020"},
|
|
||||||
{"2c34a2bdb3738cb78270207dcae40ae47178bf4216bd2044ba124ec49240522a", "8c490c78d7d735ab32493510cc2ec9c3742d3f47e46cfd754859e91271673e15"},
|
|
||||||
{"fc03857a3ff92d17d40bf9bb9b99e01e85fe4c698450147dc74cde60b2e9fa2d", "c0a22acdababbc42bba5bc0245a2ef9f2c74b215663440aed37c8e0bd7e00809"},
|
|
||||||
{"a267a96a35c63b03788e90bb9a440da9ac832b0be02537b6f0ecc928ea989223", "636ceacda5bce999ca303b7df32e9352af10083c6db6ed93c8a221efc385172d"},
|
|
||||||
{"ce4e15a2c1667a9dac4c4732de6c91f8c523c449f8c9be6b895644460717a209", "d55c6523f40b36d2519b30292873bd469aeda6dbdbafe7c5fd405438dcc6bd12"},
|
|
||||||
{"4c617cdea4e3cb008c396c59b701375409304d84cfa17fe9d6d91a15fa412306", "a6dc21a9c35418a39c69f2d8e9df738db0b36fecc44eddf364846b84c5362819"},
|
|
||||||
{"8c33aa2b3d94f9b11cc62ed1a304b92be370384ebbbf67c886dcd6ce544cc806", "7caca2b1ab8c70b58ba36794a988fd6ec50c2a04dd09d7cd28e67ca1f1401d2c"},
|
|
||||||
{"1b6fc8f4007e6cdcf89a496cf0e711b0a3bbdbbae66830450a9744f5c802a228", "c3b79478bd32feb99a0c92001efb97953efdad8c2338ed2ac14a313592c12418"},
|
|
||||||
{"0c6837e83ee0f1b1e5fe31bdf0960aefa2162ef7de7c0c886df930839bd4db06", "8b2667b5151ab13f0f87fb014cd3ebb7ab1e92a528f00ebd91b514ea61b8f52b"},
|
|
||||||
{"8da38060963597c34544d8b10432a2e34d8eada7d1479f4fa5e96dca32250c27", "7bf525115a8e6f772feb6d4db0f2a6b0d4233e0ff85e180c3249e18f0d08f42e"},
|
|
||||||
{"50b0c6d85f6a9d11fc52f1fc9e43b778380bdf936ddfd293940c77e79bc8340d", "bbb9e297de81ef341e032484d7b33b29e7d9e3be1414feaf2bbc0957ba408811"},
|
|
||||||
{"6e8fd3ad20cf32ff8ba6e4bd8d4f05f3cc20d88631cbd3aa5f7f98446d725108", "a9fe7404613b040412049a205301f2175b53d7012087047a8dc7501a381f5210"},
|
|
||||||
{"c291bb32d69cfef7e80b6dadd2a1198d05ac23eb30be6503d1c4c04350de2028", "f44f8ca09d849551f72a6692c793319eefaa0c02d3301ae79c2f869f4251d422"},
|
|
||||||
{"116d4c2e21101f819a87f0de31dec56a4649c9ad9e539b71680dd439b288681d", "9f4df65e05390be63bd6e3e38d8afb6117d5d357d56f35ecf63406096fdd810c"},
|
|
||||||
{"1813ed3760299a16e623084a852de9b12caaf8138744f8903a357fa9a2dbb00c", "f37baacccd07bc489f50b851f807c88a425e41dd9dda8068e75cffb8bf653a0f"},
|
|
||||||
{"545e62d72cbb89db1c17e7ad8bb0660a74f8bc411b16eb0452d9a2d7c3e5b01e", "96ddc93a86b091c7b1951d7371f80a352d85c38606e450aa2af272e8929fae19"},
|
|
||||||
{"0f5d5941474697c21ea6aecc29ff7cadbd28dbf29531431a40aaea3b7acd1514", "e83d0ff3ab4db81fb19c1b6125d7d2e4a34a83a8d463049d06df4870dbb2a525"},
|
|
||||||
{"52605bc1f48092f9d5ad4c2a840a60f129e6aef2eef9c92474951ed1e10e381c", "222df3afb8b20685c872f29ebfc7e4056fcdafe1d8a77a9f9ba08ac8f426190c"},
|
|
||||||
{"eee8cdee57e9f11ad0174c1514bba4c3a2c2a10d099876195726217445462f0b", "a000e5799ac933154bae228c09b522c714fb9a57f530d1954947277be9db0a24"},
|
|
||||||
{"8c7d04dc3916370f8186dcffc92ad482294ab49c9ce36a5bd13473dc7c4d491a", "788e35bcd82efbce15b3444f36330337ce3adb67bfc6329149cd25069ac9eb19"},
|
|
||||||
{"004a720f9edabb7f82eb30a78da45aceccbca5eb69583e1e8018ec1359a61f27", "e3d319d64bea8069a649acd33859b22361da799e0296f3d4f5117e16feb18e16"},
|
|
||||||
{"38716f1d7cde7e37795a5b2d6d6317eecbf0adc6dcf7dcc6ee02cc25d1efb22f", "95c229d0cfc1485f2be0a23de6e49601a2ea55652beead84a67cd727c21a1301"},
|
|
||||||
{"22cac7a49e99f3d071812abb0addafa4bf9a65308769728e4cd53cc7486f6c13", "a2e5b90606809964bc20d776b9cbcaab93a2f25124998ae3bd698d061f7afd00"},
|
|
||||||
{"5109c7a41f73baa4787358b72ff1095439602add7a86a034b87b74360ee2e20f", "a31b3e2033ed828b5a51b9428f8f6ea40267259df08fdcd2c0e34dd335bdf90c"},
|
|
||||||
{"957a87470f29a135567085c3d6d6ed14885bab4eb659725534a45a9f100a471c", "8f3005df282d5a87fa33405e35a313233d05731e87cfcbe060fa067596fa3013"},
|
|
||||||
{"e0dad57606c2b293dc7c841c965cb29736d2411003e9284a0ae94d13e3d03d2e", "0543643ef0b617030dcc292451ebcace8bad20706528cb6aedb98dcea66aba27"},
|
|
||||||
{"f1f10938c8a55b6b15b3f12beebb702133401135937c5c3f2d7fba702f24da09", "dc862a8a5ad5107421d550731a7f561e4064878c3654bf88b230cc249e91091d"},
|
|
||||||
{"4bbc08d78c9970235778d6bd9939c7b2b1bd88b9d1cde6473663ae96ae776911", "3584be9ce31a7fb3aae8515011f4d3eeb86a573b225a88577e4911050bc35013"},
|
|
||||||
{"c8325b31c9295757ca23d8f5256eebc5ccc517d28e00bfda5f4d709441d66713", "b81f360903160485c470625519cb18219b44d8b740273ef742fefc5653daf009"},
|
|
||||||
{"69a6b3e22fbe5879efa56cdb5d50605732bf7f311e28ba037916b4db61ae8a14", "10ddf800eb3e67da20575456150cb1f0d49506d97ed4ef2d91b951af48966924"},
|
|
||||||
{"c2a0e3586d4bb49f2ef979686c3a9a1619d0d54ac89641d592b4628b19dee401", "bc3ba677f6d13ef9f023d4a3b9f073c3eea910ef90cfd24b7f54414d2d02d315"},
|
|
||||||
{"5b89051b79ff37457760d7af2ebc68be955e47eb6cdf306fbd369dc19fc52c05", "7bfe2a9d5bb2ade0f9058ea27a07c867af21670d2b9e84bdcc8967d4cdc4ba11"},
|
|
||||||
{"46ac45f35cbc23bf68906933ad29240054a0a1d89c1832ebb54aa1bc32644105", "e891e783d5615a1b8ab838f68f6f2ce4e359510ddd40882d4650327d08a5bd11"},
|
|
||||||
{"581e067b37c40caf861c190922f816e6cb850540df7ceb159f96c48c1c70cd23", "0d49fa8c74202369c36f4121eab0aa3ac9206ad3419fc9517a88493b07d6fb25"},
|
|
||||||
{"bb7eb4ba2b45a22e14fad963c04eadbe8e7aab6ff912b008c9e7dd2a2c7d3615", "758ed0c8cef51f82508072fa758265f0f0eef6c7b2401b94ebe27a638ce33125"},
|
|
||||||
{"a08f3cc9904f672b94d1f5a14dedbdef4ed229da5b66eca0135090d6f0ba0728", "542c952395d241cfa15bd48922e9c7fc292dbdd120daa3d66dad67fb3abb700a"},
|
|
||||||
{"105bac5c449441bd5f5cf39b431f703e2e8f6a30a90d86cfdf425ec728fdbd08", "b59206f1d556fb98329a7111e3c89bf1e6a4861ec38c82eafa81cff70b713e0d"},
|
|
||||||
{"45df2edfaea234dab99efa9a402c0d2feaa841ff3c990c926473173283d95913", "db008cf922c3a50549373a14f5f18b2dc827bd6e168402dfe3e6ece4cb137527"},
|
|
||||||
{"488dd6437c15ef5b85e84407b7e599cc078c195ed2fc27b366ddac7739f1eb14", "0448887f55c677464e7e540adf107ba10fc6713e8a2718fe92cbd4794ef4be17"},
|
|
||||||
{"3fe697698f3504e15eb5d509efa91624d9aa4eae24beeb42ffcb3c6ea8372a30", "441ccb28e7c6c1893a58f7513c9b7c1c5d0adf3de452644a837d7e08e1ab8117"},
|
|
||||||
{"9bb5801272264c74db75f1c6812747bf338ea6880fa4dd2d51ef651ef73c2e04", "e2eefd80e838c30b3f1fb0313fcfcb1e1556439d0346d17334df83c33247b20e"},
|
|
||||||
{"bad37a1467c4fe875b78508656f2816414ef602ae2ccd4e9430d94ca5c1cd911", "21c72ccdbaed2e3ea9dac3881531467b64c9322199127f2ae2fa4bb31bad591d"},
|
|
||||||
{"95c72237ccbaedc185b1abfc59059c454175df81bb3ff65e5a61e2cb5263ed0d", "1040728a4775ac5cf7a9c75dda2f0aee1fabd6b202b5e916636e3aec73a09d0d"},
|
|
||||||
{"738e8b9af4d199bc95f70b2a9b25e999b39af15c6a02f2eca058326078745f2a", "004835960aa03e101d818907df453cefdfb910b44ad9bd056a83b2ef40a5ca0d"},
|
|
||||||
{"0d88caf486f2fe60bfc08697d1b617b586ec880e38e4ff56f145a5db0ab6d12e", "a7b19323815295bc84c50535b62c3d4d53dbfc434441eb3c009568fb8f7b2b1a"},
|
|
||||||
{"b37af7fd314d90590fba8ebf730397cfdaa97f86d3f31d1a7ddc817ff303791f", "8296a80eceae97f92784642da34f121e29db2c5f3baf9a2722896db22e98b703"},
|
|
||||||
{"6b67dd3051a8cb113431f5a14e279d910b7b4798ccb03ff588cf312ffe366a0b", "9c38cc543a0b793be4a0d66de3b2cd30b1f33d36c4402a165da924d7e6f89a12"},
|
|
||||||
{"72fc4c40e406b9d1b34daba614460922fc53951abd6db5834e1f1b07fa319f27", "daa4d50481ba47c4a78ae3848a9b268b1d8e0579b4967ebcdece47d386410d02"},
|
|
||||||
{"a4ce5cb2b2a23dcf019f275058a4092901c4793e6ee7d29282e755dd0d0df000", "00749453d23051f3587911c34d52e2c2d093273d2283cd6dfba94d7a89cdb226"},
|
|
||||||
{"9e00df0216e8ac8e72abfeab1106373a13699714c691f04a549f6b58ea974521", "0e69dbfd9023b8bb58ce7e17972d7c94d49e8464f9c22161d7564ed32c53ef27"},
|
|
||||||
{"fe1a558c6315f425fea7c04dcf6db869acd7b62b1b848200d5709e73d53de71b", "66cd33cc8d61cb807092d76ac0e506014fc55624a39ee2afa67f9ba58eb21022"},
|
|
||||||
{"3ca542e17e4cbc74f47afb399b12295d15dfbae5e966509b7e6cae2df61a430a", "57a0df429ed3720dee61ca720a4617243b41472f0c7766cc7ce625afddb3b41b"},
|
|
||||||
{"c1a77855e9b0b1f7381c9acd69ff68fdfa65f1f753dcea22de5a28ed088c2b2e", "4fce521d725abb8a30d8c39a2a22f496b374d8512b7a76afd3803f7200c86d19"},
|
|
||||||
{"17cda8d590adf3042bbf1452fe3d79b959f284f3df1e15ee3c696286f0ba832e", "8919e92a175b55003379ca6e546a04228aa9da861a9669e0e9b106e4a204d404"},
|
|
||||||
{"959fa9337b4b479ce5fcff7ff9096a344acf7fcde2f8852e28904236472f2f02", "79e688ecfece239223b745e4b95460bfcb02aee12b154e15db616fda857dcd06"},
|
|
||||||
{"d062d34cbdfbc50004a631e3dd8f21b446673b53830aa71fdcbc741e7d4fb31c", "2203af0127657f4e8a1c5ec44bb25028e64ad388efd0b9bfe2105f4f3ff66d0f"},
|
|
||||||
{"d2d3e3034864944914709549ce27068b5f27bd18b0edc940593df2dc5c5dae23", "5ae75206bfdc8f54a8673d5d4c4b464ba1e84ae2410418b5c5e98fa993608113"},
|
|
||||||
{"4ab457d6478fb27214345f0bc2e00cbb29cd55bed1f8e05c23b8f7810e134a1f", "3db37711e355ed46ea81bb6e31ae87b37b706a8d17e2aa976c7c7706c8e18d19"},
|
|
||||||
{"5aa17884c96ecdaf81e2b343dbf051e4ace41935e53378ac10a4387e2cb0c404", "7118986268a748881f6144fc1008e90b40afc702be53784ed4cbceb8606e0714"},
|
|
||||||
{"82f4ca6b751ac067e451ae1d5115806e7a1d14ab444084a8ac48046b88b43b30", "8a09186c2a5cb0f16e273be6a8710620006a77afe7c54149bea3dce906345a02"},
|
|
||||||
{"55d5d97de81e0cc4d2ac97e507d4d6d9874cb55e1522b89ed2050ff3c20a4912", "27facefe4e2041e11a21889205af6c11eba73e3e8779b801bf3f7253730f1d04"},
|
|
||||||
{"845177f4584f61071ddea21e9a6c0a17e1a9408e0c073047c339498ff383c109", "25bc572d1c861fe80156c2fd440e7d9110be8252723d276e806dcc012f8da103"},
|
|
||||||
{"ecec46dfdaf45f49f82ee78fd9c8c747c049de9becaf440f90391c04dd119002", "b922e1a7caf72db69dcc062424c7ce75728d010c4c201c2ed8e635a617c81a1f"},
|
|
||||||
{"8e265fd9f2a4b158a5eb4bda000a6124af909e118b7510f0ec418559aad85825", "aed92a21e9933bd2ce6c9f09bb7753b46ea31248b324c12726cff08e464bdd0c"},
|
|
||||||
{"99d7181572d3ae637a277dcc0c35b9b98bbb6ecf3cdcc69af3e946a5bfeb520f", "89217b554371a2495ee473f867b2e26ea70d4245aceb462a98dd31a37d2d5330"},
|
|
||||||
{"a5e1fd149ae27f34e7902ebf380277c0b7f09f37e8809d25a0b8df2965d24e29", "2d6a16a254cfc3894d5500f8c40feb1e84876bc51c68c381109e83f001b41c2f"},
|
|
||||||
{"7fd221da235bb6e5fd0ae047f1aa49615ddbeecfb71ccb976bf3e0534425661c", "9ea41ccc3e09572927b0d9f618e1135d384f33618b6a0f80002f0a70be5eb324"},
|
|
||||||
{"b125c1b45daa68f96be6a5b3e4dd24e4a0e49e46226d841eb73754a498c43b21", "360b9c39d25451ae58cf651c530155f91e324292b55475a92506de726f153c18"},
|
|
||||||
{"d64536234849ababefa90b84f7b7cacf4b073809aa9b0c35581426521f18d81a", "d2dae030312cd4325bb036aa3436b26b9bed69b4d78d68bd49dbdde3173f1510"},
|
|
||||||
{"d1ce3aea6cfb7be132d17e8d76fcbe4b7e34cef3979b4b905acfeff2f6d19724", "be47b76297791f535f4b56f973a19f07ec22d4eede2a41ff23c696089938bb21"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
const STATIC_GROUP_MERKLE_ROOT = "a1877a553eff12e1b21632a0545a916a5c5b8060ad7cc6c69956741134397b2d"
|
|
||||||
|
|
||||||
const EPOCH_UNIT_SECONDS = uint64(10) // the rln-relay epoch length in seconds
|
|
||||||
|
|
||||||
type Epoch [32]byte
|
|
||||||
|
|
||||||
func BytesToEpoch(b []byte) Epoch {
|
|
||||||
var result Epoch
|
|
||||||
copy(result[:], b)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func ToEpoch(t uint64) Epoch {
|
|
||||||
var result Epoch
|
|
||||||
binary.LittleEndian.PutUint64(result[:], t)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e Epoch) Uint64() uint64 {
|
|
||||||
return binary.LittleEndian.Uint64(e[:])
|
|
||||||
}
|
|
||||||
|
|
||||||
// CalcEpoch returns the corresponding rln `Epoch` value for a time.Time
|
|
||||||
func CalcEpoch(t time.Time) Epoch {
|
|
||||||
return ToEpoch(uint64(t.Unix()) / EPOCH_UNIT_SECONDS)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCurrentEpoch gets the current rln Epoch time
|
|
||||||
func GetCurrentEpoch() Epoch {
|
|
||||||
return CalcEpoch(time.Now())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Diff returns the difference between the two rln `Epoch`s `e1` and `e2`
|
|
||||||
func Diff(e1, e2 Epoch) int64 {
|
|
||||||
epoch1 := e1.Uint64()
|
|
||||||
epoch2 := e2.Uint64()
|
|
||||||
return int64(epoch1) - int64(epoch2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e Epoch) Time() time.Time {
|
|
||||||
return time.Unix(int64(e.Uint64()*EPOCH_UNIT_SECONDS), 0)
|
|
||||||
}
|
|
|
@ -128,7 +128,7 @@ func _2_messages_indexDownSql() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "2_messages_index.down.sql", size: 60, mode: os.FileMode(0664), modTime: time.Unix(1663763599, 0)}
|
info := bindataFileInfo{name: "2_messages_index.down.sql", size: 60, mode: os.FileMode(0664), modTime: time.Unix(1664827710, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6e, 0xcb, 0x70, 0x82, 0x33, 0x13, 0x70, 0xd5, 0xbd, 0x3e, 0x68, 0x9, 0x4f, 0x78, 0xa9, 0xc, 0xd6, 0xf4, 0x64, 0xa0, 0x8c, 0xe4, 0x0, 0x15, 0x71, 0xf0, 0x5, 0xdb, 0xa6, 0xf2, 0x12, 0x60}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6e, 0xcb, 0x70, 0x82, 0x33, 0x13, 0x70, 0xd5, 0xbd, 0x3e, 0x68, 0x9, 0x4f, 0x78, 0xa9, 0xc, 0xd6, 0xf4, 0x64, 0xa0, 0x8c, 0xe4, 0x0, 0x15, 0x71, 0xf0, 0x5, 0xdb, 0xa6, 0xf2, 0x12, 0x60}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ func _2_messages_indexUpSql() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "2_messages_index.up.sql", size: 226, mode: os.FileMode(0664), modTime: time.Unix(1663763514, 0)}
|
info := bindataFileInfo{name: "2_messages_index.up.sql", size: 226, mode: os.FileMode(0664), modTime: time.Unix(1664827710, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xce, 0xb1, 0xc8, 0x2d, 0xa8, 0x6f, 0x83, 0xfb, 0xf2, 0x40, 0x30, 0xe9, 0xd, 0x18, 0x54, 0xe8, 0xf5, 0xf5, 0xc4, 0x5b, 0xf5, 0xa4, 0x94, 0x50, 0x56, 0x4a, 0xc8, 0x73, 0x3f, 0xf1, 0x56, 0xce}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xce, 0xb1, 0xc8, 0x2d, 0xa8, 0x6f, 0x83, 0xfb, 0xf2, 0x40, 0x30, 0xe9, 0xd, 0x18, 0x54, 0xe8, 0xf5, 0xf5, 0xc4, 0x5b, 0xf5, 0xa4, 0x94, 0x50, 0x56, 0x4a, 0xc8, 0x73, 0x3f, 0xf1, 0x56, 0xce}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
r "github.com/status-im/go-rln/rln"
|
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/rln"
|
"github.com/status-im/go-waku/waku/v2/protocol/rln"
|
||||||
|
r "github.com/status-im/go-zerokit-rln/rln"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
r "github.com/status-im/go-rln/rln"
|
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/rln"
|
"github.com/status-im/go-waku/waku/v2/protocol/rln"
|
||||||
|
r "github.com/status-im/go-zerokit-rln/rln"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WithStaticRLNRelay enables the Waku V2 RLN protocol in offchain mode
|
// WithStaticRLNRelay enables the Waku V2 RLN protocol in offchain mode
|
||||||
|
|
|
@ -29,6 +29,7 @@ type RateLimitProof struct {
|
||||||
ShareX []byte `protobuf:"bytes,4,opt,name=share_x,json=shareX,proto3" json:"share_x,omitempty"`
|
ShareX []byte `protobuf:"bytes,4,opt,name=share_x,json=shareX,proto3" json:"share_x,omitempty"`
|
||||||
ShareY []byte `protobuf:"bytes,5,opt,name=share_y,json=shareY,proto3" json:"share_y,omitempty"`
|
ShareY []byte `protobuf:"bytes,5,opt,name=share_y,json=shareY,proto3" json:"share_y,omitempty"`
|
||||||
Nullifier []byte `protobuf:"bytes,6,opt,name=nullifier,proto3" json:"nullifier,omitempty"`
|
Nullifier []byte `protobuf:"bytes,6,opt,name=nullifier,proto3" json:"nullifier,omitempty"`
|
||||||
|
RlnIdentifier []byte `protobuf:"bytes,7,opt,name=rln_identifier,json=rlnIdentifier,proto3" json:"rln_identifier,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
@ -109,6 +110,13 @@ func (m *RateLimitProof) GetNullifier() []byte {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *RateLimitProof) GetRlnIdentifier() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.RlnIdentifier
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type WakuMessage struct {
|
type WakuMessage struct {
|
||||||
Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
|
Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
|
||||||
ContentTopic string `protobuf:"bytes,2,opt,name=contentTopic,proto3" json:"contentTopic,omitempty"`
|
ContentTopic string `protobuf:"bytes,2,opt,name=contentTopic,proto3" json:"contentTopic,omitempty"`
|
||||||
|
@ -204,27 +212,28 @@ func init() {
|
||||||
func init() { proto.RegisterFile("waku_message.proto", fileDescriptor_6f0a20862b3bf714) }
|
func init() { proto.RegisterFile("waku_message.proto", fileDescriptor_6f0a20862b3bf714) }
|
||||||
|
|
||||||
var fileDescriptor_6f0a20862b3bf714 = []byte{
|
var fileDescriptor_6f0a20862b3bf714 = []byte{
|
||||||
// 313 bytes of a gzipped FileDescriptorProto
|
// 334 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0x41, 0x4e, 0x02, 0x31,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0xcf, 0x4a, 0x33, 0x31,
|
||||||
0x18, 0x85, 0x2d, 0x0a, 0xc8, 0x0f, 0x12, 0xd2, 0x68, 0xec, 0x82, 0x0c, 0x13, 0x56, 0xb3, 0x62,
|
0x14, 0xc5, 0xbf, 0xf4, 0xb3, 0xad, 0xbd, 0xfd, 0x43, 0x09, 0x8a, 0x59, 0x94, 0xe9, 0x50, 0x10,
|
||||||
0xa1, 0x5b, 0x57, 0xae, 0x35, 0x31, 0x8d, 0x89, 0xba, 0x9a, 0x14, 0xfc, 0x91, 0x86, 0xe9, 0xfc,
|
0x66, 0xd5, 0x85, 0x6e, 0x5d, 0xb9, 0x13, 0x14, 0x24, 0x08, 0xea, 0x6a, 0x48, 0xdb, 0x5b, 0x1b,
|
||||||
0x4d, 0xa7, 0xa8, 0xdc, 0xc4, 0x4b, 0x78, 0x0f, 0x97, 0xde, 0x40, 0x83, 0x17, 0x31, 0xd3, 0x91,
|
0x9a, 0x49, 0x42, 0x26, 0x55, 0xfb, 0x26, 0x3e, 0x92, 0x4b, 0x17, 0xee, 0x95, 0xfa, 0x22, 0x32,
|
||||||
0x8c, 0xec, 0xfa, 0xbe, 0x97, 0x97, 0xbc, 0xbe, 0x1f, 0xf8, 0x8b, 0x5a, 0xae, 0x52, 0x83, 0x45,
|
0x19, 0xeb, 0xd8, 0x5d, 0xce, 0xef, 0xdc, 0x0b, 0x39, 0xe7, 0x02, 0x7d, 0x12, 0xcb, 0x55, 0x9a,
|
||||||
0xa1, 0x9e, 0x70, 0x62, 0x1d, 0x79, 0xe2, 0x0d, 0x3b, 0x1d, 0xbf, 0x33, 0xe8, 0x4b, 0xe5, 0xf1,
|
0x61, 0x9e, 0x8b, 0x07, 0x1c, 0x5b, 0x67, 0xbc, 0xa1, 0x35, 0x3b, 0x19, 0xbd, 0x13, 0xe8, 0x71,
|
||||||
0x4a, 0x1b, 0xed, 0x6f, 0x1c, 0xd1, 0x9c, 0x1f, 0x43, 0xd3, 0x96, 0x0f, 0xc1, 0x62, 0x96, 0xf4,
|
0xe1, 0xf1, 0x52, 0x66, 0xd2, 0x5f, 0x3b, 0x63, 0xe6, 0xf4, 0x00, 0xea, 0xb6, 0x78, 0x30, 0x12,
|
||||||
0x64, 0x25, 0xf8, 0x08, 0xba, 0x06, 0xdd, 0x32, 0xc3, 0xd4, 0x11, 0x79, 0xd1, 0x08, 0x1e, 0x54,
|
0x93, 0xa4, 0xc3, 0x4b, 0x41, 0x87, 0xd0, 0xce, 0xd0, 0x2d, 0x15, 0xa6, 0xce, 0x18, 0xcf, 0x6a,
|
||||||
0x48, 0x12, 0xf9, 0x32, 0x86, 0x96, 0x66, 0x0b, 0xb1, 0x5f, 0xc5, 0x82, 0xe0, 0xa7, 0xd0, 0x2e,
|
0xc1, 0x83, 0x12, 0x71, 0x63, 0x7c, 0xb1, 0x86, 0xd6, 0x4c, 0x17, 0xec, 0x7f, 0xb9, 0x16, 0x04,
|
||||||
0x16, 0xca, 0x61, 0xfa, 0x2a, 0x0e, 0x02, 0x6f, 0x05, 0x79, 0x5f, 0x1b, 0x6b, 0xd1, 0xfc, 0x67,
|
0x3d, 0x82, 0x66, 0xbe, 0x10, 0x0e, 0xd3, 0x67, 0xb6, 0x17, 0x78, 0x23, 0xc8, 0xbb, 0xca, 0x58,
|
||||||
0x3c, 0xf0, 0x21, 0x74, 0xf2, 0x55, 0x96, 0xe9, 0xb9, 0x46, 0x27, 0x5a, 0xc1, 0xaa, 0xc1, 0xf8,
|
0xb3, 0xfa, 0x1f, 0xe3, 0x9e, 0x0e, 0xa0, 0xa5, 0x57, 0x4a, 0xc9, 0xb9, 0x44, 0xc7, 0x1a, 0xc1,
|
||||||
0x8b, 0x41, 0xf7, 0x4e, 0x2d, 0x57, 0xd7, 0xd5, 0x4f, 0xb8, 0x80, 0xb6, 0x55, 0xeb, 0x8c, 0xd4,
|
0xaa, 0x00, 0x3d, 0x86, 0x9e, 0x53, 0x3a, 0x95, 0x33, 0xd4, 0xbe, 0x1c, 0x69, 0x86, 0x91, 0xae,
|
||||||
0xe3, 0x5f, 0xdd, 0xad, 0xe4, 0x63, 0xe8, 0xcd, 0x28, 0xf7, 0x98, 0xfb, 0x5b, 0xb2, 0x7a, 0x16,
|
0x53, 0xfa, 0xe2, 0x17, 0x8e, 0x3e, 0x08, 0xb4, 0x6f, 0xc5, 0x72, 0x75, 0x55, 0x06, 0xa6, 0x0c,
|
||||||
0x1a, 0x77, 0xe4, 0x0e, 0x2b, 0xd3, 0xcf, 0xe8, 0x0a, 0x4d, 0x79, 0x68, 0x7d, 0x24, 0xb7, 0xb2,
|
0x9a, 0x56, 0xac, 0x95, 0x11, 0xb3, 0x9f, 0x54, 0x5b, 0x49, 0x47, 0xd0, 0x99, 0x1a, 0xed, 0x51,
|
||||||
0x6c, 0xe1, 0xb5, 0xc1, 0xc2, 0x2b, 0x63, 0x05, 0xc4, 0x2c, 0xe1, 0xb2, 0x06, 0xfc, 0x02, 0x06,
|
0xfb, 0x1b, 0x63, 0xe5, 0x34, 0x04, 0x6b, 0xf1, 0x1d, 0x56, 0x6c, 0x3f, 0xa2, 0xcb, 0xa5, 0xd1,
|
||||||
0x4e, 0x79, 0x4c, 0xb3, 0x72, 0xb5, 0xb4, 0x5a, 0xeb, 0x24, 0x66, 0x49, 0xf7, 0x8c, 0x4f, 0xec,
|
0x21, 0x5c, 0x97, 0x6f, 0x65, 0xf1, 0x59, 0x2f, 0x33, 0xcc, 0xbd, 0xc8, 0x2c, 0x83, 0x98, 0x24,
|
||||||
0x74, 0xb2, 0x3b, 0xa8, 0xec, 0xbb, 0xdd, 0x81, 0x87, 0xd0, 0x41, 0xbb, 0x40, 0x83, 0x4e, 0x65,
|
0x94, 0x57, 0x80, 0x9e, 0x41, 0xdf, 0x09, 0x8f, 0xa9, 0x2a, 0xca, 0x4d, 0xcb, 0x52, 0x0f, 0x63,
|
||||||
0x62, 0x14, 0xb3, 0xe4, 0x50, 0xd6, 0xe0, 0x72, 0xf0, 0xb1, 0x89, 0xd8, 0xe7, 0x26, 0x62, 0xdf,
|
0x92, 0xb4, 0x4f, 0xe8, 0xd8, 0x4e, 0xc6, 0xbb, 0xbd, 0xf3, 0x9e, 0xdb, 0xbd, 0xc3, 0x00, 0x5a,
|
||||||
0x9b, 0x88, 0xbd, 0xfd, 0x44, 0x7b, 0xd3, 0x56, 0x38, 0xd7, 0xf9, 0x6f, 0x00, 0x00, 0x00, 0xff,
|
0x68, 0x17, 0x98, 0xa1, 0x13, 0x8a, 0x0d, 0x63, 0x92, 0xec, 0xf3, 0x0a, 0x9c, 0xf7, 0x5f, 0x37,
|
||||||
0xff, 0xe6, 0x01, 0x38, 0xc8, 0xc4, 0x01, 0x00, 0x00,
|
0x11, 0x79, 0xdb, 0x44, 0xe4, 0x73, 0x13, 0x91, 0x97, 0xaf, 0xe8, 0xdf, 0xa4, 0x11, 0xae, 0x7a,
|
||||||
|
0xfa, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x5a, 0xc1, 0xf3, 0x87, 0xeb, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *RateLimitProof) Marshal() (dAtA []byte, err error) {
|
func (m *RateLimitProof) Marshal() (dAtA []byte, err error) {
|
||||||
|
@ -251,6 +260,13 @@ func (m *RateLimitProof) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
i -= len(m.XXX_unrecognized)
|
i -= len(m.XXX_unrecognized)
|
||||||
copy(dAtA[i:], m.XXX_unrecognized)
|
copy(dAtA[i:], m.XXX_unrecognized)
|
||||||
}
|
}
|
||||||
|
if len(m.RlnIdentifier) > 0 {
|
||||||
|
i -= len(m.RlnIdentifier)
|
||||||
|
copy(dAtA[i:], m.RlnIdentifier)
|
||||||
|
i = encodeVarintWakuMessage(dAtA, i, uint64(len(m.RlnIdentifier)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x3a
|
||||||
|
}
|
||||||
if len(m.Nullifier) > 0 {
|
if len(m.Nullifier) > 0 {
|
||||||
i -= len(m.Nullifier)
|
i -= len(m.Nullifier)
|
||||||
copy(dAtA[i:], m.Nullifier)
|
copy(dAtA[i:], m.Nullifier)
|
||||||
|
@ -414,6 +430,10 @@ func (m *RateLimitProof) Size() (n int) {
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovWakuMessage(uint64(l))
|
n += 1 + l + sovWakuMessage(uint64(l))
|
||||||
}
|
}
|
||||||
|
l = len(m.RlnIdentifier)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovWakuMessage(uint64(l))
|
||||||
|
}
|
||||||
if m.XXX_unrecognized != nil {
|
if m.XXX_unrecognized != nil {
|
||||||
n += len(m.XXX_unrecognized)
|
n += len(m.XXX_unrecognized)
|
||||||
}
|
}
|
||||||
|
@ -692,6 +712,40 @@ func (m *RateLimitProof) Unmarshal(dAtA []byte) error {
|
||||||
m.Nullifier = []byte{}
|
m.Nullifier = []byte{}
|
||||||
}
|
}
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
|
case 7:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field RlnIdentifier", wireType)
|
||||||
|
}
|
||||||
|
var byteLen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowWakuMessage
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
byteLen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if byteLen < 0 {
|
||||||
|
return ErrInvalidLengthWakuMessage
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + byteLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthWakuMessage
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.RlnIdentifier = append(m.RlnIdentifier[:0], dAtA[iNdEx:postIndex]...)
|
||||||
|
if m.RlnIdentifier == nil {
|
||||||
|
m.RlnIdentifier = []byte{}
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipWakuMessage(dAtA[iNdEx:])
|
skippy, err := skipWakuMessage(dAtA[iNdEx:])
|
||||||
|
|
|
@ -9,6 +9,7 @@ message RateLimitProof {
|
||||||
bytes share_x = 4;
|
bytes share_x = 4;
|
||||||
bytes share_y = 5;
|
bytes share_y = 5;
|
||||||
bytes nullifier = 6;
|
bytes nullifier = 6;
|
||||||
|
bytes rln_identifier = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message WakuMessage {
|
message WakuMessage {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
package rln
|
|
||||||
|
|
||||||
//go:generate go-bindata -pkg rln -o ./bindata.go parameters.key
|
|
Binary file not shown.
|
@ -6,8 +6,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
r "github.com/status-im/go-rln/rln"
|
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
||||||
|
r "github.com/status-im/go-zerokit-rln/rln"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,21 +31,15 @@ func RlnRelayStatic(
|
||||||
return nil, errors.New("peer's IDCommitment does not match commitment in group")
|
return nil, errors.New("peer's IDCommitment does not match commitment in group")
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an RLN instance
|
rlnInstance, err := r.NewRLN()
|
||||||
parameters, err := parametersKeyBytes()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
rlnInstance, err := r.NewRLN(parameters)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add members to the Merkle tree
|
// add members to the Merkle tree
|
||||||
for _, member := range group {
|
for _, member := range group {
|
||||||
if !rlnInstance.InsertMember(member) {
|
if err := rlnInstance.InsertMember(member); err != nil {
|
||||||
return nil, errors.New("could not add member")
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +86,7 @@ func RlnRelayDynamic(
|
||||||
|
|
||||||
log.Info("mounting rln-relay in onchain/dynamic mode")
|
log.Info("mounting rln-relay in onchain/dynamic mode")
|
||||||
|
|
||||||
// create an RLN instance
|
rlnInstance, err := r.NewRLN()
|
||||||
parameters, err := parametersKeyBytes()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
rlnInstance, err := r.NewRLN(parameters)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -144,10 +132,7 @@ func RlnRelayDynamic(
|
||||||
handler := func(pubkey r.IDCommitment, index r.MembershipIndex) error {
|
handler := func(pubkey r.IDCommitment, index r.MembershipIndex) error {
|
||||||
log.Debug("a new key is added", zap.Binary("pubkey", pubkey[:]))
|
log.Debug("a new key is added", zap.Binary("pubkey", pubkey[:]))
|
||||||
// assuming all the members arrive in order
|
// assuming all the members arrive in order
|
||||||
if !rlnInstance.InsertMember(pubkey) {
|
return rlnInstance.InsertMember(pubkey)
|
||||||
return errors.New("couldn't insert member")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
|
|
|
@ -14,10 +14,10 @@ import (
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||||
r "github.com/status-im/go-rln/rln"
|
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
||||||
"github.com/status-im/go-waku/waku/v2/utils"
|
"github.com/status-im/go-waku/waku/v2/utils"
|
||||||
|
r "github.com/status-im/go-zerokit-rln/rln"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -264,12 +264,13 @@ func (rln *WakuRLNRelay) AppendRLNProof(msg *pb.WakuMessage, senderEpochTime tim
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.RateLimitProof = &pb.RateLimitProof{
|
msg.RateLimitProof = &pb.RateLimitProof{
|
||||||
Proof: proof.Proof[:],
|
Proof: proof.Proof[:],
|
||||||
MerkleRoot: proof.MerkleRoot[:],
|
MerkleRoot: proof.MerkleRoot[:],
|
||||||
Epoch: proof.Epoch[:],
|
Epoch: proof.Epoch[:],
|
||||||
ShareX: proof.ShareX[:],
|
ShareX: proof.ShareX[:],
|
||||||
ShareY: proof.ShareY[:],
|
ShareY: proof.ShareY[:],
|
||||||
Nullifier: proof.Nullifier[:],
|
Nullifier: proof.Nullifier[:],
|
||||||
|
RlnIdentifier: proof.RLNIdentifier[:],
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -333,7 +334,7 @@ func (r *WakuRLNRelay) addValidator(
|
||||||
zap.Binary("payload", wakuMessage.Payload),
|
zap.Binary("payload", wakuMessage.Payload),
|
||||||
zap.Any("proof", wakuMessage.RateLimitProof),
|
zap.Any("proof", wakuMessage.RateLimitProof),
|
||||||
)
|
)
|
||||||
return true
|
return false
|
||||||
case MessageValidationResult_Spam:
|
case MessageValidationResult_Spam:
|
||||||
r.log.Debug("spam message found",
|
r.log.Debug("spam message found",
|
||||||
zap.String("contentTopic", wakuMessage.ContentTopic),
|
zap.String("contentTopic", wakuMessage.ContentTopic),
|
||||||
|
@ -395,25 +396,14 @@ func ToRateLimitProof(msg *pb.WakuMessage) *r.RateLimitProof {
|
||||||
}
|
}
|
||||||
|
|
||||||
result := &r.RateLimitProof{
|
result := &r.RateLimitProof{
|
||||||
Proof: r.ZKSNARK(Bytes256(msg.RateLimitProof.Proof)),
|
Proof: r.ZKSNARK(r.Bytes128(msg.RateLimitProof.Proof)),
|
||||||
MerkleRoot: r.MerkleNode(Bytes32(msg.RateLimitProof.MerkleRoot)),
|
MerkleRoot: r.MerkleNode(r.Bytes32(msg.RateLimitProof.MerkleRoot)),
|
||||||
Epoch: r.Epoch(Bytes32(msg.RateLimitProof.Epoch)),
|
Epoch: r.Epoch(r.Bytes32(msg.RateLimitProof.Epoch)),
|
||||||
ShareX: r.MerkleNode(Bytes32(msg.RateLimitProof.ShareX)),
|
ShareX: r.MerkleNode(r.Bytes32(msg.RateLimitProof.ShareX)),
|
||||||
ShareY: r.MerkleNode(Bytes32(msg.RateLimitProof.ShareY)),
|
ShareY: r.MerkleNode(r.Bytes32(msg.RateLimitProof.ShareY)),
|
||||||
Nullifier: r.Nullifier(Bytes32(msg.RateLimitProof.Nullifier)),
|
Nullifier: r.Nullifier(r.Bytes32(msg.RateLimitProof.Nullifier)),
|
||||||
|
RLNIdentifier: r.RLNIdentifier(r.Bytes32(msg.RateLimitProof.RlnIdentifier)),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func Bytes32(b []byte) [32]byte {
|
|
||||||
var result [32]byte
|
|
||||||
copy(result[:], b)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func Bytes256(b []byte) [256]byte {
|
|
||||||
var result [256]byte
|
|
||||||
copy(result[:], b)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
r "github.com/status-im/go-rln/rln"
|
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/rln/contracts"
|
"github.com/status-im/go-waku/waku/v2/protocol/rln/contracts"
|
||||||
|
r "github.com/status-im/go-zerokit-rln/rln"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -77,8 +77,7 @@ func register(ctx context.Context, idComm r.IDCommitment, ethAccountPrivateKey *
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventIdComm r.IDCommitment
|
var eventIdComm r.IDCommitment = r.Bytes32(evt.Pubkey.Bytes())
|
||||||
copy(eventIdComm[:], evt.Pubkey.Bytes())
|
|
||||||
|
|
||||||
log.Debug("the identity commitment key extracted from tx log", zap.Binary("eventIdComm", eventIdComm[:]))
|
log.Debug("the identity commitment key extracted from tx log", zap.Binary("eventIdComm", eventIdComm[:]))
|
||||||
|
|
||||||
|
@ -111,8 +110,7 @@ func processLogs(evt *contracts.RLNMemberRegistered, handler RegistrationEventHa
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var pubkey r.IDCommitment
|
var pubkey r.IDCommitment = r.Bytes32(evt.Pubkey.Bytes())
|
||||||
copy(pubkey[:], evt.Pubkey.Bytes())
|
|
||||||
|
|
||||||
index := r.MembershipIndex(uint(evt.Index.Int64()))
|
index := r.MembershipIndex(uint(evt.Index.Int64()))
|
||||||
|
|
||||||
|
|
|
@ -411,6 +411,9 @@ func (store *WakuStore) queryFrom(ctx context.Context, q *pb.HistoryQuery, selec
|
||||||
|
|
||||||
if historyResponseRPC.Response == nil {
|
if historyResponseRPC.Response == nil {
|
||||||
historyResponseRPC.Response = new(pb.HistoryResponse)
|
historyResponseRPC.Response = new(pb.HistoryResponse)
|
||||||
|
}
|
||||||
|
|
||||||
|
if historyResponseRPC.Response.PagingInfo == nil {
|
||||||
historyResponseRPC.Response.PagingInfo = new(pb.PagingInfo)
|
historyResponseRPC.Response.PagingInfo = new(pb.PagingInfo)
|
||||||
historyResponseRPC.Response.PagingInfo.Cursor = new(pb.Index)
|
historyResponseRPC.Response.PagingInfo.Cursor = new(pb.Index)
|
||||||
}
|
}
|
||||||
|
@ -471,12 +474,14 @@ func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryR
|
||||||
return nil, errors.New("invalid cursor")
|
return nil, errors.New("invalid cursor")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Result{
|
result := &Result{
|
||||||
Messages: response.Messages,
|
Messages: response.Messages,
|
||||||
cursor: response.PagingInfo.Cursor,
|
|
||||||
query: q,
|
query: q,
|
||||||
|
cursor: response.PagingInfo.Cursor,
|
||||||
peerId: params.selectedPeer,
|
peerId: params.selectedPeer,
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next is used with to retrieve the next page of rows from a query response.
|
// Next is used with to retrieve the next page of rows from a query response.
|
||||||
|
|
|
@ -0,0 +1,201 @@
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright (c) 2022 Status Research & Development GmbH
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
|
@ -0,0 +1,61 @@
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define TEST_PARAMETERS_INDEX 2
|
||||||
|
|
||||||
|
typedef struct RLN RLN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Buffer struct is taken from
|
||||||
|
* https://github.com/celo-org/celo-threshold-bls-rs/blob/master/crates/threshold-bls-ffi/src/ffi.rs
|
||||||
|
*
|
||||||
|
* Also heavily inspired by https://github.com/kilic/rln/blob/master/src/ffi.rs
|
||||||
|
*/
|
||||||
|
typedef struct Buffer {
|
||||||
|
const uint8_t *ptr;
|
||||||
|
uintptr_t len;
|
||||||
|
} Buffer;
|
||||||
|
|
||||||
|
bool new(uintptr_t tree_height, const struct Buffer *input_buffer, struct RLN **ctx);
|
||||||
|
|
||||||
|
bool new_with_params(uintptr_t tree_height,
|
||||||
|
const struct Buffer *circom_buffer,
|
||||||
|
const struct Buffer *zkey_buffer,
|
||||||
|
const struct Buffer *vk_buffer,
|
||||||
|
struct RLN **ctx);
|
||||||
|
|
||||||
|
bool set_tree(struct RLN *ctx, uintptr_t tree_height);
|
||||||
|
|
||||||
|
bool delete_leaf(struct RLN *ctx, uintptr_t index);
|
||||||
|
|
||||||
|
bool set_leaf(struct RLN *ctx, uintptr_t index, const struct Buffer *input_buffer);
|
||||||
|
|
||||||
|
bool set_next_leaf(struct RLN *ctx, const struct Buffer *input_buffer);
|
||||||
|
|
||||||
|
bool set_leaves(struct RLN *ctx, const struct Buffer *input_buffer);
|
||||||
|
|
||||||
|
bool get_root(const struct RLN *ctx, struct Buffer *output_buffer);
|
||||||
|
|
||||||
|
bool get_proof(const struct RLN *ctx, uintptr_t index, struct Buffer *output_buffer);
|
||||||
|
|
||||||
|
bool prove(struct RLN *ctx, const struct Buffer *input_buffer, struct Buffer *output_buffer);
|
||||||
|
|
||||||
|
bool verify(const struct RLN *ctx, const struct Buffer *proof_buffer, bool *proof_is_valid_ptr);
|
||||||
|
|
||||||
|
bool generate_rln_proof(struct RLN *ctx,
|
||||||
|
const struct Buffer *input_buffer,
|
||||||
|
struct Buffer *output_buffer);
|
||||||
|
|
||||||
|
bool verify_rln_proof(const struct RLN *ctx,
|
||||||
|
const struct Buffer *proof_buffer,
|
||||||
|
bool *proof_is_valid_ptr);
|
||||||
|
|
||||||
|
bool key_gen(const struct RLN *ctx, struct Buffer *output_buffer);
|
||||||
|
|
||||||
|
bool seeded_key_gen(const struct RLN *ctx,
|
||||||
|
const struct Buffer *input_buffer,
|
||||||
|
struct Buffer *output_buffer);
|
||||||
|
|
||||||
|
bool hash(struct RLN *ctx, const struct Buffer *input_buffer, struct Buffer *output_buffer);
|
|
@ -2,10 +2,6 @@ package rln
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo LDFLAGS:-lrln -ldl -lm
|
#cgo LDFLAGS:-lrln -ldl -lm
|
||||||
#cgo android,arm64 LDFLAGS:-L${SRCDIR}/../libs/aarch64-linux-android
|
|
||||||
#cgo android,arm7 LDFLAGS:-L${SRCDIR}/../libs/armv7-linux-androideabi
|
|
||||||
#cgo android,amd64 LDFLAGS:-L${SRCDIR}/../libs/x86_64-linux-android
|
|
||||||
#cgo android,386 LDFLAGS:-L${SRCDIR}/../libs/i686-linux-android
|
|
||||||
#cgo linux,arm LDFLAGS:-L${SRCDIR}/../libs/armv7-linux-androideabi
|
#cgo linux,arm LDFLAGS:-L${SRCDIR}/../libs/armv7-linux-androideabi
|
||||||
#cgo linux,arm64 LDFLAGS:-L${SRCDIR}/../libs/aarch64-unknown-linux-gnu
|
#cgo linux,arm64 LDFLAGS:-L${SRCDIR}/../libs/aarch64-unknown-linux-gnu
|
||||||
#cgo linux,amd64,musl,!android LDFLAGS:-L${SRCDIR}/../libs/x86_64-unknown-linux-musl
|
#cgo linux,amd64,musl,!android LDFLAGS:-L${SRCDIR}/../libs/x86_64-unknown-linux-musl
|
||||||
|
@ -16,6 +12,5 @@ package rln
|
||||||
#cgo darwin,386,!ios LDFLAGS:-L${SRCDIR}/../libs/i686-apple-darwin
|
#cgo darwin,386,!ios LDFLAGS:-L${SRCDIR}/../libs/i686-apple-darwin
|
||||||
#cgo darwin,arm64,!ios LDFLAGS:-L${SRCDIR}/../libs/aarch64-apple-darwin
|
#cgo darwin,arm64,!ios LDFLAGS:-L${SRCDIR}/../libs/aarch64-apple-darwin
|
||||||
#cgo darwin,amd64,!ios LDFLAGS:-L${SRCDIR}/../libs/x86_64-apple-darwin
|
#cgo darwin,amd64,!ios LDFLAGS:-L${SRCDIR}/../libs/x86_64-apple-darwin
|
||||||
#cgo ios LDFLAGS:-L${SRCDIR}/../libs/universal -framework Security -framework Foundation
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,3 @@
|
||||||
|
package resources
|
||||||
|
|
||||||
|
//go:generate go-bindata -pkg resources -o ./bindata.go ./...
|
|
@ -1,4 +1,3 @@
|
||||||
// Package rln contains bindings for https://github.com/kilic/rln
|
|
||||||
package rln
|
package rln
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -9,38 +8,88 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/status-im/go-zerokit-rln/rln/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RLN represents the context used for rln.
|
// RLN represents the context used for rln.
|
||||||
type RLN struct {
|
type RLN struct {
|
||||||
ptr *C.RLN_Bn256
|
ptr *C.RLN
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new RLN generated using the default merkle tree depth
|
// NewRLN generates an instance of RLN. An instance supports both zkSNARKs logics
|
||||||
func NewRLN(params []byte) (*RLN, error) {
|
// and Merkle tree data structure and operations. It uses a depth of 20 by default
|
||||||
return NewRLNWithDepth(MERKLE_TREE_DEPTH, params)
|
func NewRLN() (*RLN, error) {
|
||||||
}
|
|
||||||
|
|
||||||
// NewRLNWithDepth generates an instance of RLN. An instance supports both zkSNARKs logics
|
wasm, err := resources.Asset("tree_height_20/rln.wasm")
|
||||||
// and Merkle tree data structure and operations. The parameter `depth`` indicates the depth of Merkle tree
|
if err != nil {
|
||||||
func NewRLNWithDepth(depth int, params []byte) (*RLN, error) {
|
return nil, err
|
||||||
r := &RLN{}
|
|
||||||
|
|
||||||
if len(params) == 0 {
|
|
||||||
return nil, errors.New("error in parameters.key")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := toBuffer(params)
|
zkey, err := resources.Asset("tree_height_20/rln_final.zkey")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
verifKey, err := resources.Asset("tree_height_20/verification_key.json")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r := &RLN{}
|
||||||
|
|
||||||
|
depth := 20
|
||||||
|
|
||||||
|
wasmBuffer := toCBufferPtr(wasm)
|
||||||
|
zkeyBuffer := toCBufferPtr(zkey)
|
||||||
|
verifKeyBuffer := toCBufferPtr(verifKey)
|
||||||
|
|
||||||
|
if !bool(C.new_with_params(C.uintptr_t(depth), wasmBuffer, zkeyBuffer, verifKeyBuffer, &r.ptr)) {
|
||||||
|
return nil, errors.New("failed to initialize")
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRLNWithParams generates an instance of RLN. An instance supports both zkSNARKs logics
|
||||||
|
// and Merkle tree data structure and operations. The parameter `depth“ indicates the depth of Merkle tree
|
||||||
|
func NewRLNWithParams(depth int, wasm []byte, zkey []byte, verifKey []byte) (*RLN, error) {
|
||||||
|
r := &RLN{}
|
||||||
|
|
||||||
|
wasmBuffer := toCBufferPtr(wasm)
|
||||||
|
zkeyBuffer := toCBufferPtr(zkey)
|
||||||
|
verifKeyBuffer := toCBufferPtr(verifKey)
|
||||||
|
|
||||||
|
if !bool(C.new_with_params(C.uintptr_t(depth), wasmBuffer, zkeyBuffer, verifKeyBuffer, &r.ptr)) {
|
||||||
|
return nil, errors.New("failed to initialize")
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRLNWithFolder generates an instance of RLN. An instance supports both zkSNARKs logics
|
||||||
|
// and Merkle tree data structure and operations. The parameter `deptk` indicates the depth of Merkle tree
|
||||||
|
// The parameter “
|
||||||
|
func NewRLNWithFolder(depth int, resourcesFolderPath string) (*RLN, error) {
|
||||||
|
r := &RLN{}
|
||||||
|
|
||||||
|
pathBuffer := toCBufferPtr([]byte(resourcesFolderPath))
|
||||||
|
|
||||||
|
if !bool(C.new(C.uintptr_t(depth), pathBuffer, &r.ptr)) {
|
||||||
|
return nil, errors.New("failed to initialize")
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func toCBufferPtr(input []byte) *C.Buffer {
|
||||||
|
buf := toBuffer(input)
|
||||||
|
|
||||||
size := int(unsafe.Sizeof(buf))
|
size := int(unsafe.Sizeof(buf))
|
||||||
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
||||||
*in = buf
|
*in = buf
|
||||||
|
|
||||||
if !bool(C.new_circuit_from_params(C.uintptr_t(depth), in, &r.ptr)) {
|
return in
|
||||||
return nil, errors.New("failed to initialize")
|
|
||||||
}
|
|
||||||
|
|
||||||
return r, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MembershipKeyGen generates a MembershipKeyPair that can be used for the registration into the rln membership contract
|
// MembershipKeyGen generates a MembershipKeyPair that can be used for the registration into the rln membership contract
|
||||||
|
@ -99,15 +148,12 @@ func (r *RLN) Hash(data []byte) (MerkleNode, error) {
|
||||||
// a thin layer on top of the Nim wrapper of the Poseidon hasher
|
// a thin layer on top of the Nim wrapper of the Poseidon hasher
|
||||||
lenPrefData := appendLength(data)
|
lenPrefData := appendLength(data)
|
||||||
|
|
||||||
hashInputBuffer := toBuffer(lenPrefData)
|
hashInputBuffer := toCBufferPtr(lenPrefData)
|
||||||
size := int(unsafe.Sizeof(hashInputBuffer))
|
|
||||||
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
|
||||||
*in = hashInputBuffer
|
|
||||||
|
|
||||||
var output []byte
|
var output []byte
|
||||||
out := toBuffer(output)
|
out := toBuffer(output)
|
||||||
|
|
||||||
if !bool(C.signal_to_field(r.ptr, in, &out)) {
|
if !bool(C.hash(r.ptr, hashInputBuffer, &out)) {
|
||||||
return MerkleNode{}, errors.New("failed to hash")
|
return MerkleNode{}, errors.New("failed to hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,41 +166,39 @@ func (r *RLN) Hash(data []byte) (MerkleNode, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateProof generates a proof for the RLN given a KeyPair and the index in a merkle tree.
|
// GenerateProof generates a proof for the RLN given a KeyPair and the index in a merkle tree.
|
||||||
// The output will containt the proof data and should be parsed as |proof<256>|root<32>|epoch<32>|share_x<32>|share_y<32>|nullifier<32>|
|
// The output will containt the proof data and should be parsed as |proof<128>|root<32>|epoch<32>|share_x<32>|share_y<32>|nullifier<32>|
|
||||||
// integers wrapped in <> indicate value sizes in bytes
|
// integers wrapped in <> indicate value sizes in bytes
|
||||||
func (r *RLN) GenerateProof(data []byte, key MembershipKeyPair, index MembershipIndex, epoch Epoch) (*RateLimitProof, error) {
|
func (r *RLN) GenerateProof(data []byte, key MembershipKeyPair, index MembershipIndex, epoch Epoch) (*RateLimitProof, error) {
|
||||||
input := serialize(key.IDKey, index, epoch, data)
|
input := serialize(key.IDKey, index, epoch, data)
|
||||||
inputBuf := toBuffer(input)
|
inputBuffer := toCBufferPtr(input)
|
||||||
size := int(unsafe.Sizeof(inputBuf))
|
|
||||||
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
|
||||||
*in = inputBuf
|
|
||||||
|
|
||||||
var output []byte
|
var output []byte
|
||||||
out := toBuffer(output)
|
out := toBuffer(output)
|
||||||
|
|
||||||
if !bool(C.generate_proof(r.ptr, in, &out)) {
|
if !bool(C.generate_rln_proof(r.ptr, inputBuffer, &out)) {
|
||||||
return nil, errors.New("could not generate the proof")
|
return nil, errors.New("could not generate the proof")
|
||||||
}
|
}
|
||||||
|
|
||||||
proofBytes := C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len))
|
proofBytes := C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len))
|
||||||
|
|
||||||
if len(proofBytes) != 416 {
|
if len(proofBytes) != 320 {
|
||||||
return nil, errors.New("invalid proof generated")
|
return nil, errors.New("invalid proof generated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the proof as |zkSNARKs<256>|root<32>|epoch<32>|share_x<32>|share_y<32>|nullifier<32>|
|
// parse the proof as [ proof<128> | root<32> | epoch<32> | share_x<32> | share_y<32> | nullifier<32> | rln_identifier<32> ]
|
||||||
|
proofOffset := 128
|
||||||
proofOffset := 256
|
|
||||||
rootOffset := proofOffset + 32
|
rootOffset := proofOffset + 32
|
||||||
epochOffset := rootOffset + 32
|
epochOffset := rootOffset + 32
|
||||||
shareXOffset := epochOffset + 32
|
shareXOffset := epochOffset + 32
|
||||||
shareYOffset := shareXOffset + 32
|
shareYOffset := shareXOffset + 32
|
||||||
nullifierOffset := shareYOffset + 32
|
nullifierOffset := shareYOffset + 32
|
||||||
|
rlnIdentifierOffset := nullifierOffset + 32
|
||||||
|
|
||||||
var zkproof ZKSNARK
|
var zkproof ZKSNARK
|
||||||
var proofRoot, shareX, shareY MerkleNode
|
var proofRoot, shareX, shareY MerkleNode
|
||||||
var epochR Epoch
|
var epochR Epoch
|
||||||
var nullifier Nullifier
|
var nullifier Nullifier
|
||||||
|
var rlnIdentifier RLNIdentifier
|
||||||
|
|
||||||
copy(zkproof[:], proofBytes[0:proofOffset])
|
copy(zkproof[:], proofBytes[0:proofOffset])
|
||||||
copy(proofRoot[:], proofBytes[proofOffset:rootOffset])
|
copy(proofRoot[:], proofBytes[proofOffset:rootOffset])
|
||||||
|
@ -162,53 +206,51 @@ func (r *RLN) GenerateProof(data []byte, key MembershipKeyPair, index Membership
|
||||||
copy(shareX[:], proofBytes[epochOffset:shareXOffset])
|
copy(shareX[:], proofBytes[epochOffset:shareXOffset])
|
||||||
copy(shareY[:], proofBytes[shareXOffset:shareYOffset])
|
copy(shareY[:], proofBytes[shareXOffset:shareYOffset])
|
||||||
copy(nullifier[:], proofBytes[shareYOffset:nullifierOffset])
|
copy(nullifier[:], proofBytes[shareYOffset:nullifierOffset])
|
||||||
|
copy(rlnIdentifier[:], proofBytes[nullifierOffset:rlnIdentifierOffset])
|
||||||
|
|
||||||
return &RateLimitProof{
|
return &RateLimitProof{
|
||||||
Proof: zkproof,
|
Proof: zkproof,
|
||||||
MerkleRoot: proofRoot,
|
MerkleRoot: proofRoot,
|
||||||
Epoch: epochR,
|
Epoch: epochR,
|
||||||
ShareX: shareX,
|
ShareX: shareX,
|
||||||
ShareY: shareY,
|
ShareY: shareY,
|
||||||
Nullifier: nullifier,
|
Nullifier: nullifier,
|
||||||
|
RLNIdentifier: rlnIdentifier,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify verifies a proof generated for the RLN.
|
// Verify verifies a proof generated for the RLN.
|
||||||
// proof [ proof<256>| root<32>| epoch<32>| share_x<32>| share_y<32>| nullifier<32> | signal_len<8> | signal<var> ]
|
// proof [ proof<128>| root<32>| epoch<32>| share_x<32>| share_y<32>| nullifier<32> | signal_len<8> | signal<var> ]
|
||||||
func (r *RLN) Verify(data []byte, proof RateLimitProof) bool {
|
func (r *RLN) Verify(data []byte, proof RateLimitProof) bool {
|
||||||
proofBytes := proof.serialize(data)
|
proofBytes := proof.serialize(data)
|
||||||
proofBuf := toBuffer(proofBytes)
|
proofBuf := toCBufferPtr(proofBytes)
|
||||||
size := int(unsafe.Sizeof(proofBuf))
|
res := C.bool(false)
|
||||||
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
if !bool(C.verify_rln_proof(r.ptr, proofBuf, &res)) {
|
||||||
*in = proofBuf
|
|
||||||
|
|
||||||
result := uint32(0)
|
|
||||||
res := C.uint(result)
|
|
||||||
if !bool(C.verify(r.ptr, in, &res)) {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return uint32(res) == 0
|
return bool(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertMember adds the member to the tree
|
// InsertMember adds the member to the tree
|
||||||
func (r *RLN) InsertMember(idComm IDCommitment) bool {
|
func (r *RLN) InsertMember(idComm IDCommitment) error {
|
||||||
buf := toBuffer(idComm[:])
|
idCommBuffer := toCBufferPtr(idComm[:])
|
||||||
|
insertionSuccess := bool(C.set_next_leaf(r.ptr, idCommBuffer))
|
||||||
size := int(unsafe.Sizeof(buf))
|
if !insertionSuccess {
|
||||||
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
return errors.New("could not insert member")
|
||||||
*in = buf
|
}
|
||||||
|
return nil
|
||||||
res := C.update_next_member(r.ptr, in)
|
|
||||||
return bool(res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMember removes an IDCommitment key from the tree. The index
|
// DeleteMember removes an IDCommitment key from the tree. The index
|
||||||
// parameter is the position of the id commitment key to be deleted from the tree.
|
// parameter is the position of the id commitment key to be deleted from the tree.
|
||||||
// The deleted id commitment key is replaced with a zero leaf
|
// The deleted id commitment key is replaced with a zero leaf
|
||||||
func (r *RLN) DeleteMember(index MembershipIndex) bool {
|
func (r *RLN) DeleteMember(index MembershipIndex) error {
|
||||||
deletionSuccess := bool(C.delete_member(r.ptr, C.uintptr_t(index)))
|
deletionSuccess := bool(C.delete_leaf(r.ptr, C.uintptr_t(index)))
|
||||||
return deletionSuccess
|
if !deletionSuccess {
|
||||||
|
return errors.New("could not delete member")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMerkleRoot reads the Merkle Tree root after insertion
|
// GetMerkleRoot reads the Merkle Tree root after insertion
|
||||||
|
@ -233,26 +275,26 @@ func (r *RLN) GetMerkleRoot() (MerkleNode, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddAll adds members to the Merkle tree
|
// AddAll adds members to the Merkle tree
|
||||||
func (r *RLN) AddAll(list []IDCommitment) bool {
|
func (r *RLN) AddAll(list []IDCommitment) error {
|
||||||
for _, member := range list {
|
for _, member := range list {
|
||||||
if !r.InsertMember(member) {
|
if err := r.InsertMember(member); err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcMerkleRoot returns the root of the Merkle tree that is computed from the supplied list
|
// CalcMerkleRoot returns the root of the Merkle tree that is computed from the supplied list
|
||||||
func CalcMerkleRoot(list []IDCommitment, params []byte) (MerkleNode, error) {
|
func CalcMerkleRoot(list []IDCommitment) (MerkleNode, error) {
|
||||||
rln, err := NewRLN(params)
|
rln, err := NewRLN()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return MerkleNode{}, err
|
return MerkleNode{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a Merkle tree
|
// create a Merkle tree
|
||||||
for _, c := range list {
|
for _, c := range list {
|
||||||
if !rln.InsertMember(c) {
|
if err := rln.InsertMember(c); err != nil {
|
||||||
return MerkleNode{}, errors.New("could not add member")
|
return MerkleNode{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,9 +304,9 @@ func CalcMerkleRoot(list []IDCommitment, params []byte) (MerkleNode, error) {
|
||||||
// CreateMembershipList produces a list of membership key pairs and also returns the root of a Merkle tree constructed
|
// CreateMembershipList produces a list of membership key pairs and also returns the root of a Merkle tree constructed
|
||||||
// out of the identity commitment keys of the generated list. The output of this function is used to initialize a static
|
// out of the identity commitment keys of the generated list. The output of this function is used to initialize a static
|
||||||
// group keys (to test waku-rln-relay in the off-chain mode)
|
// group keys (to test waku-rln-relay in the off-chain mode)
|
||||||
func CreateMembershipList(n int, params []byte) ([]MembershipKeyPair, MerkleNode, error) {
|
func CreateMembershipList(n int) ([]MembershipKeyPair, MerkleNode, error) {
|
||||||
// initialize a Merkle tree
|
// initialize a Merkle tree
|
||||||
rln, err := NewRLN(params)
|
rln, err := NewRLN()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, MerkleNode{}, err
|
return nil, MerkleNode{}, err
|
||||||
}
|
}
|
||||||
|
@ -280,8 +322,8 @@ func CreateMembershipList(n int, params []byte) ([]MembershipKeyPair, MerkleNode
|
||||||
output = append(output, *keypair)
|
output = append(output, *keypair)
|
||||||
|
|
||||||
// insert the key to the Merkle tree
|
// insert the key to the Merkle tree
|
||||||
if !rln.InsertMember(keypair.IDCommitment) {
|
if err := rln.InsertMember(keypair.IDCommitment); err != nil {
|
||||||
return nil, MerkleNode{}, errors.New("could not insert member")
|
return nil, MerkleNode{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,15 +23,15 @@ func serialize(idKey IDKey, memIndex MembershipIndex, epoch Epoch, msg []byte) [
|
||||||
// serialize converts a RateLimitProof and data to a byte seq
|
// serialize converts a RateLimitProof and data to a byte seq
|
||||||
// this conversion is used in the proof verification proc
|
// this conversion is used in the proof verification proc
|
||||||
// the order of serialization is based on https://github.com/kilic/rln/blob/7ac74183f8b69b399e3bc96c1ae8ab61c026dc43/src/public.rs#L205
|
// the order of serialization is based on https://github.com/kilic/rln/blob/7ac74183f8b69b399e3bc96c1ae8ab61c026dc43/src/public.rs#L205
|
||||||
// [ proof<256>| root<32>| epoch<32>| share_x<32>| share_y<32>| nullifier<32> | signal_len<8> | signal<var> ]
|
// [ proof<128> | root<32> | epoch<32> | share_x<32> | share_y<32> | nullifier<32> | rln_identifier<32> | signal_len<8> | signal<var> ]
|
||||||
func (r RateLimitProof) serialize(data []byte) []byte {
|
func (r RateLimitProof) serialize(data []byte) []byte {
|
||||||
|
|
||||||
lenPrefMsg := appendLength(data)
|
lenPrefMsg := appendLength(data)
|
||||||
proofBytes := append(r.Proof[:], r.MerkleRoot[:]...)
|
proofBytes := append(r.Proof[:], r.MerkleRoot[:]...)
|
||||||
proofBytes = append(proofBytes, r.Epoch[:]...)
|
proofBytes = append(proofBytes, r.Epoch[:]...)
|
||||||
proofBytes = append(proofBytes, r.ShareX[:]...)
|
proofBytes = append(proofBytes, r.ShareX[:]...)
|
||||||
proofBytes = append(proofBytes, r.ShareY[:]...)
|
proofBytes = append(proofBytes, r.ShareY[:]...)
|
||||||
proofBytes = append(proofBytes, r.Nullifier[:]...)
|
proofBytes = append(proofBytes, r.Nullifier[:]...)
|
||||||
|
proofBytes = append(proofBytes, r.RLNIdentifier[:]...)
|
||||||
proofBytes = append(proofBytes, lenPrefMsg...)
|
proofBytes = append(proofBytes, lenPrefMsg...)
|
||||||
|
|
||||||
return proofBytes
|
return proofBytes
|
|
@ -0,0 +1,237 @@
|
||||||
|
package rln
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IDKey is an identity key as defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||||
|
type IDKey = [32]byte
|
||||||
|
|
||||||
|
// IDCommintment is hash of identity key as defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||||
|
type IDCommitment = [32]byte
|
||||||
|
|
||||||
|
// Each node of the Merkle tee is a Poseidon hash which is a 32 byte value
|
||||||
|
type MerkleNode = [32]byte
|
||||||
|
|
||||||
|
type Nullifier = [32]byte
|
||||||
|
|
||||||
|
type RLNIdentifier = [32]byte
|
||||||
|
|
||||||
|
type ZKSNARK = [128]byte
|
||||||
|
|
||||||
|
// Custom data types defined for waku rln relay -------------------------
|
||||||
|
|
||||||
|
type MembershipKeyPair = struct {
|
||||||
|
// user's identity key (a secret key) which is selected randomly
|
||||||
|
// see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||||
|
IDKey IDKey
|
||||||
|
// hash of user's identity key generated by
|
||||||
|
// Poseidon hash function implemented in rln lib
|
||||||
|
// more details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||||
|
IDCommitment IDCommitment
|
||||||
|
}
|
||||||
|
|
||||||
|
type RateLimitProof struct {
|
||||||
|
// 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 ProofMetadata struct {
|
||||||
|
Nullifier Nullifier
|
||||||
|
ShareX MerkleNode
|
||||||
|
ShareY MerkleNode
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ProofMetadata) Equals(p2 ProofMetadata) bool {
|
||||||
|
return bytes.Equal(p.Nullifier[:], p2.Nullifier[:]) && bytes.Equal(p.ShareX[:], p2.ShareX[:]) && bytes.Equal(p.ShareY[:], p2.ShareY[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// the current implementation of the rln lib only supports a circuit for Merkle tree with depth 32
|
||||||
|
const MERKLE_TREE_DEPTH int = 20
|
||||||
|
|
||||||
|
// HASH_BIT_SIZE is the size of poseidon hash output in bits
|
||||||
|
const HASH_BIT_SIZE = 256
|
||||||
|
|
||||||
|
// HASH_HEX_SIZE is the size of poseidon hash output as the number of bytes
|
||||||
|
const HASH_HEX_SIZE = int(HASH_BIT_SIZE / 8)
|
||||||
|
|
||||||
|
// temporary variables to test waku-rln-relay performance in the static group mode
|
||||||
|
|
||||||
|
const STATIC_GROUP_SIZE = 100
|
||||||
|
|
||||||
|
// STATIC_GROUP_KEYS is a static list of 100 membership keys in the form of (identity key, identity commitment)
|
||||||
|
// keys are created locally, using createMembershipList proc from waku_rln_relay_utils module, and the results are hardcoded in here
|
||||||
|
// this list is temporary and is created to test the performance of waku-rln-relay for the static groups
|
||||||
|
// in the later versions, this static hardcoded group will be replaced with a dynamic one
|
||||||
|
var STATIC_GROUP_KEYS [][]string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
STATIC_GROUP_KEYS = [][]string{
|
||||||
|
{"c12d11c3b8ee882559ef48f7a42633d81b1e13fc589e6caca028281a1098012c", "b3ec8a9138817be401b9ed2c683f6969d87f70ad87cbc514dee24146a542a71c"},
|
||||||
|
{"1a19a8d1709ffa10882673962fa4b6fcecdd2ae3c95f9cc2db294633fd775109", "eb599e4681f8fd50730d22d2b0d0e9e4efcc659d2d310bd6cb3ff5600a81300e"},
|
||||||
|
{"6317e72b74ad1395ce77777bcde06b7b5dd02ca69ad6fdc7affeb3bf4d6d1c13", "151a533bc8927e97be9ba2173644282e3aeada4f9a65c4cc72eda27f3ba10c11"},
|
||||||
|
{"d5d375f61fc9f9b4702aee9473ce304abca838d224dbc0dcfabffa0e3d04452f", "f538609579c413bca2d395a772b026498eba0c00a1cdd5f7127d526bd96da723"},
|
||||||
|
{"f47b36d2df712cb16eb21797c2d0672e12a60e0a7807edcfb15e7213f072a20c", "d4d12cce11c6d8311c15353d35926f298b886ac66cf6420c47ad178231632608"},
|
||||||
|
{"3a8360de57f4ab8cad701459a73019c71b0d84927dcec0384bafb2586356080d", "08a8b713036264b878bdb8051cd6a6ccc9acf9e094daff690d167e699a90c628"},
|
||||||
|
{"661b5eb69735c9e8a181bcbf34563b96aff763d4996d60ef88c439e82549b622", "c1fffac2bc6d8b78eb24ba052d72bb88fe5cdb40e86eb3ebadbd57aff47b1e2c"},
|
||||||
|
{"79fe1ac6ee536412d737091c7e53f003cfd4e4d1a96b1ebc1d27faff4527101c", "ae1b33ed18cb164c4b3227d8acaf75eb480a58c07d04792361d3e7688437572e"},
|
||||||
|
{"88f35905877c4417d418a75994eb2ccf7da052b1032bae782c935b107bcaf12e", "0e3cf8fee2c863470dfefabea0162e98a3cb0b5aed1387d9aa2990710ae6b705"},
|
||||||
|
{"771b20194afc2d043d133213a39c99f88a50f6459eb7bb7a8b19cd468fdace1a", "408f8624260e2a85ea354959cff0e7550d89ba666e4a5d646fe1ab8a9b253d2f"},
|
||||||
|
{"1e40c14bbe937cc3baac06f4b9c1e9d15374064a12462a505ee3c85b59e12d20", "c5ea8270d54c3919ffc5659bef2b4f00f55a9b7e8a655875ca864837cf66561f"},
|
||||||
|
{"23dae2b032cf45c17378778786b91fe53c7aad7928391c5c4613b5683ef22c16", "9f6e20cc9f6df9e64cabcbb765c92faabe25257d92a00f746d13cf1e5f113f1f"},
|
||||||
|
{"f3213ee18ebd73ee5813ef6267d54e0af7bff2a62ebd329adfe41a42e1d7451c", "839c3c58a2ecc4c181b8f298ce6aaeeace4e0777e8774cc1fbc4279c3e001724"},
|
||||||
|
{"f96996f6df01ebe12b75f96ec634458e5e96d8bc9b2983b211d943d8093d0b0b", "8ce6a29f023aa78d5a4de75b3e12c3cc673bba9dcafd5a2968f4a1b9707c5b11"},
|
||||||
|
{"c9d5403ed3ee20b29cb49c16312464a52109c553cb7c3e2e760488bc1f4f1b1b", "96a4069fa8485b11c9fcd9502c384caa6a1db2a90d45559a2aba51d5ea21782b"},
|
||||||
|
{"3de4f01667d317d52e2718926646dcf559f2fb7266b6977a47401b976b457b06", "6eff6bbee3d3bd885c7f900b362dbf245e97a523afdbb62d25eefb9afeba4c0f"},
|
||||||
|
{"89453ee367a782654502062cba7da961d638b4160121ba0ac88abe7a2f82ee18", "551f19081516e49a4e94dd97af53da2b35b603c321ad02d29f85b9d5ff12f802"},
|
||||||
|
{"32c5a512efe5d41504bea17a4e3bb865c8d54e9c6732a3bce77962e52e1fc414", "3b8dab877f10640659e99bc6dba2367664aca2f4e3f87b38ffd532f326332f12"},
|
||||||
|
{"a74c13d3813e7452fd8680074c31dcc8d6e79e95086175205129f77f37feb129", "c55985f3a99a3fd1a2619a54b87e433e4114f59d1a59c3a911e957790bec471e"},
|
||||||
|
{"9b1c420aa3dc252e9f290bba21136c97d4bea618ee298a4167eeb445d3b6d517", "66f0efae6899a6f851a2dab31df7e936238b8aba4e961c9b65c6b1d113f13e23"},
|
||||||
|
{"d4821c14ed5e7b8f4febc8cecc26e1d0ae6fd97a7324566c06920300110de414", "9653e0cbb946b534f0468e42bf124e5806adb4bdb93e91665610d69037b28b1d"},
|
||||||
|
{"26c453348bae0b3398691e39d5032021c15f7fcf8efb5666f2ffb3bf0c609804", "a366c39b7cfd462063aa394c31642d36cd3ea5fe89ed0d7db423f2791cf74429"},
|
||||||
|
{"4a50a8c66d78ea1850ef9e6ff3d082fb6aea7a380d267b89e449826c8e7c1319", "e353c38ea40b59565dbbdcbc03c0c9f99a017551ae912afca8d5b6cb028bbd2d"},
|
||||||
|
{"d04788fe9a750986d14596580b48edb0415b18466872d4b431ebbe80c0276f17", "234ecb8bd50f758f80a48484b6997b4d0a64a1f67941aca1bb31661797d63010"},
|
||||||
|
{"c5a3e4885e1b16a26ba3d938659e6a4d37e3f66d3f4a8d82ff6e22145ea58303", "2921633b6bc30dacadba9ee3956ec7e3024971d9db600ef99c4ffeb1ccb8e425"},
|
||||||
|
{"485887237db885ac07ce8eaf4e881fdc3fbcd4454cf0c56f0bee6b7213de570c", "061186e353aa3a59c4bc1d98e926c17b3450081dbcae63d2d0841a3fb3cef422"},
|
||||||
|
{"ca0f9ff876c78957564b303c9e99598036293efe635ec29e0e4bbc59ec59d106", "48e04ce11bf78ef28261067eec8e5a47ab8632b2d35dcf2e28d229e1e2894714"},
|
||||||
|
{"9d7965f433303388ced9097e0563c2871c7ce0b286f108bb53e7a68f77102b24", "b6afb6e2de8fd30417e4b8d1fe4559ec73aa9e96726d0448eef104a0f099eb2f"},
|
||||||
|
{"db1ef92e473d8bdad5654525d9a9fd9fc0febfe7101eed67c8031d697fff5913", "34d5b8bb8893c4f4fcf0aa4cb6bc13187bd4867bf0b4b32b57387bd371406f01"},
|
||||||
|
{"d43e059b5a5a2cb6b4200ac3832fd4ae6a33c69bcd784eaa3e662007a43c2614", "560683915ff850883b2344e9c64543cd40b2a544c099edb1e37932a7c21a1d12"},
|
||||||
|
{"a1cf07a46e8696f4a6f6838d246c4e9fbfe6db33149c99fa563f233b16317e01", "3904003e9ec020a567d23301a8f381a7395d129020ad320fb2b11f57680de027"},
|
||||||
|
{"178c9c8612a61f62506da40443cbf6d6fccbc9406303b6f88d9536b42c506826", "2c81906219408328fa05a005247c9baf796c459ecc3ab0e1a70195c180e47705"},
|
||||||
|
{"f84b9362f81ec147c40f43cde64f3ce883bd80b40230c435978794b54431be1c", "ca524f39724400999116252fdd67316cc0caf586c3ee0bd98c132ab2fdb7f30f"},
|
||||||
|
{"a2fbcc2ebb6f728e42c2967bde68461af69c2b10c5305fd40053eb01d1db1e22", "4ef48e82ffc90c273c6a1627eed225a1ecf5d34bfa33026758306601a08ee71e"},
|
||||||
|
{"91a7de9363388d15501cf72449b053a036ec5fa16faddb0bfdb6aca0a0c1f409", "fa5bc2eb977165e92a45d92d5da48e0b1e95e2d13e2d8d42dcf9e99f8761f20a"},
|
||||||
|
{"6e2598bf6a6975a578abc5615e0791c678ff1776176a771f025c17a67777791c", "22afc07a5715a0d1a47ba27403e83660837d2c7b9a5902c22c0fed861ff5ac14"},
|
||||||
|
{"e788d7b78798f2edc1d5575e35dfa3c17b6c15b6642df72ea6ee28297422b011", "ba9a4176a20d61efabf8b3a6e2197b8dcd26b0337c26b567c2fc4b3ccf67aa15"},
|
||||||
|
{"bd13c15935c3a49b2f19058e784d3bf700f4c06c0641fa771822194e543a3200", "1535c97c68abc851042f117cf98be4130a25a49acf5f9c910babef342db1fa1a"},
|
||||||
|
{"7718d0013fe1be1715041b7df3372f21185821111966fc40c5c29b948fecf60f", "e476d8441b12a235c48c24cf1a4edd1b9384c2531d70dbaeaab891aea4c39a09"},
|
||||||
|
{"857adf44efeec3ee71001be5172f0796a56021cbc94273ae4c8a58356a0d2003", "358eae8e81fd089c3807354d20cf1f878d39b1ce757126e787d4487af65d7821"},
|
||||||
|
{"8dd2491ce49ef575e8e0ebfd675b6b831e8d19c90d6110ebe57a60d3a9fff622", "88ef9b9cadb4395c03d57ca9c0a84fc76988b1285d716d4ed3a6340aa7f85a28"},
|
||||||
|
{"95a421fd9f866bf28eae38fff084ed0d300ac08c3c020d73e6c0a432e5731313", "d86722ca41b4dacfcf1bbcce9a232979722e228e15fb3e2048b8cc271b021726"},
|
||||||
|
{"8509921c8c87eeddba208836e3a70d570b39d14d8fc89a0cd988ace585a3ea2d", "1970a24152128fd6c74ed49315ff705d5af4a58b4dac87d8c82f9be6a6d77507"},
|
||||||
|
{"f0591ba2f822317b6d5d8b771474ae9518e4d36518469965d83d84d5795ea513", "1d78b5d07a822537a1bd8e8a2fe2fa9acd4d858aae251f5e33e57d1f7c462300"},
|
||||||
|
{"a302906a3fbf5dd8753edad674bc00b9397d1a5bc3dd1d229359044ffa346b0b", "de7690a0fceb4c071f52a09a1fe3e872a74a33c698792a0c30e26fbc8d8b4d20"},
|
||||||
|
{"6b425f3cfd5f66616556d9e16698fa1d2cb2e6ea6149b75089c0c403d52bbf07", "3254d4f64d9fd0ab8269bff02865dc115841f1717ca4408c8fd21830deba4900"},
|
||||||
|
{"570a3f9bb4a293fde27fd13f1407a0aef5c1e1025e2417af400d5c40a043222a", "f3d481d495572a89216be3bf4d3ba719d2c81f59f67ff825f2ac0bed67ab2a11"},
|
||||||
|
{"d2a4336cfe79faa8695f88d74b7786ef418bac6021a9c4ba1c3db8e433fda122", "618888220de5b3f2eb1470ea0ab8188d5385b21e1eef64a691b2f31d066be12d"},
|
||||||
|
{"5e9db678cd1dfd7e0c598236d25f27b34139e26e5b15b032a68de05b0e394e28", "4f2379dc6a1212d0b7029dc3248d0546d003edc23329c848ea62442e3b2a280a"},
|
||||||
|
{"042dbc17ec31dbd098c87c98fa9cd5d8ce7716045ef9d93aab3c9d6bf6f86e21", "d30841c4768e3b902d9def72131244717d2a0341540e71b51321aabe81cbcb08"},
|
||||||
|
{"c5cda9e62ddff24a2f14c8ec8ffd7746e230b3023bc2f87353a6eba7d1e55f1f", "d6252a48c7baa1b9194d0d12a8a07b97f2b624234b48f5eace2d1adc958a8118"},
|
||||||
|
{"b751b8e0c753c8dd5a07293c0dcc51448a49be3cfad6c8d3fcb8e15703a1f402", "297af6aed5d949eb9ca3ce7f0f16ab270fd509ca350376cecb844fc55606f523"},
|
||||||
|
{"2c72a6ac20aa6c8ad2500bab50c90fa8c5b2150a17d3f1d249faf29dc48ee81a", "c05528b87b7d9b7f1c96937116cb5b6c1d66fdd7678332e257d95601e98bf108"},
|
||||||
|
{"843a2f33499e417fb3370d2b35170dfd89ae3d7296bc2552611a1f04542f2b15", "85f5166a1b5c384f6bc9f59e779c9f866c4a4d00443372cd433b5096a7a77e08"},
|
||||||
|
{"329f698e99433a9acfe5bde3662d8e2c05b5b68024d29af1a59eb63d3722e40c", "910b67959ff965ae27ae8679e07bc2dfd3b6f567bdf74f07b7dc3b055d883430"},
|
||||||
|
{"2e00f33354bcace1c798690fdae14a40b8b0d5d922c5e7d9b8a7bb17ec72a40e", "4b50726e2c50f4e404bbc39eea2a8fd711a6cbd194489c4bedce99f32cebb81e"},
|
||||||
|
{"73c09da2c4cd22b3890ada1d6045a6877d558ea5c3a7088fcdd3b77b229b7620", "f500793aaae728efa2029825185175fffc286159319347d10586b8a1de01b613"},
|
||||||
|
{"25c8efe9ff791b4a0f4478a6dda0867d8df396aa51044c6d6b1ed9427d117c20", "eb57c5d562ee43c72d8972ae0e8c170b3a7f0e4c89ba67e82186229adb904706"},
|
||||||
|
{"863f44e00121079c54d36d7cccc1da51ff5900610386fdb8bc36b3a47483d72e", "c30fd9b1b05ac1a347f432d65b68c82476b4ec0994fa00cfd90f1f7db1571d2c"},
|
||||||
|
{"6a7311e3f18945a8709eb5e90021a8139375b5b68af6c9cad121615a80ee3f07", "1a3d8faa7c7d38d5acb627def5b070d8f5719189f7a25e3861c0a9a879cc611c"},
|
||||||
|
{"97d27ce44b476664863f34a2073278dd5ef1c8623771a9813fedc3a1455ce92f", "9fc429eafee88fad27dd8a0b05087a9282c926353152c8174e774f34128a7d13"},
|
||||||
|
{"a88ab45b5ea8cd975399fa39d3ea5b04b12adc705732b54ba6e5af494863c310", "2429cf8b01347e32d2774cc4070928d7ff96ff585e6f39e0a2e06fabce53c81c"},
|
||||||
|
{"51eba466f4662972616dfc4fe846425b245ca1405730b6809882f51f413b8526", "f9112ddb4c80bb385a3938959a750e091c3bb9b6e16d717db46c28efbe273a1d"},
|
||||||
|
{"45e9ff284aa8b4c825ebe16165953b186bbc0b62f209f84dac2eee3382a94e2b", "d932afbbe10120b68c573e1844a4f8f87bc93ff9d359d7c15621952e4ef9821c"},
|
||||||
|
{"d1807c403b8ed2e8022db73486ff6dd2471872404accb8208cda3d757079041c", "7aed51eb6e3f042a32e44f7add13f9d8cc675839232323094692fa9ec0385e19"},
|
||||||
|
{"b9c93861237f423f8cb2e96e3a92ba986f290f3852475d9b62cb21a445cdc201", "e25ae2bb31b01d5d80186f906af11d4c7a6ed172a5aefbabe3b3eeece6750816"},
|
||||||
|
{"558ad70ccba7882b6f20cd8098f52b8288afdee8b346bf4db33b5deb8153c71a", "c651377b6f9deb188dfc868df0157ee50dd5f9f7d92ca0e69e82f03355af9821"},
|
||||||
|
{"b6e4ff38fc18fcb2ca63486314db80183b35f1dc8082e8dffae0726a1c284c25", "2eedb645aa09985bf178bbc4c5417f8c1a9907440066096111292f2e72e9a01b"},
|
||||||
|
{"c264ab7d9008339abbc1be91bb96eed30cc5d051d8833a3f5cc94674fccd8627", "8fd732c230f79e11d56d8f7cacd5f7095e4ad1a80a3c79b1cf42d9733001fe2b"},
|
||||||
|
{"8b29b2811047827f356a57f7166f8b3dd4a3aac23b02522daf007c677295801a", "e4b4d00d5d3eeb087c2edfdede5eb92ad39974c359172913abc78e5a5c78ff13"},
|
||||||
|
{"30be5db463aef5665c8699f2e5fc69ea2ca209290771e2aaac3b60caee6cf22e", "3c5e974d664c03b13adbe5ebcf9b03491ed0e4c50095297d7b3115804274d70e"},
|
||||||
|
{"db16b337102ce1b0932fe6e841fc1e7c01473ed4f3765934f2275b821d5b5d2d", "dbcb04a56099034b4eddf402c08810f5842a74d5312cd5fd86d9378a2da54323"},
|
||||||
|
{"6f75a23af554d0b3f5ee5a48b5ec1ad8fe9a6f7c2c64b9e44bd9deb644212e17", "68cebf8d52280b6484bd14f9b6bdbf89a485fc6f6129f49494bd7c1b40c90624"},
|
||||||
|
{"e3d00baa245cb4f99dcc282cb33121dfa42c3ae1524139c5be17a043cdf65a28", "5710f34c928c76f21871bcb63731f3417f1056437397b083d095e7fd3f49790f"},
|
||||||
|
{"f382f322140415ed6692583c594e8d8fc5bea0f027a159ad01df4a3942771100", "4bfb6da22da207b0935868b7ac4574bea7f3358f4a281837e56b1fa3147cb40f"},
|
||||||
|
{"33e74fde6f16209c57b24d496fc87ce2270dd2f3b04a9a5a701ec743ed9e1d04", "e1e847e1ba408253c0539af6a7ff0a8700802ac26f8f7aa68906471613f8371f"},
|
||||||
|
{"3e4b5dc67f25293d3c432cfe6e37ac7905ae19e62c7836c8e1a05b5822ad432c", "c978a79b21c177d102af936de352d5fb2862396157628c8c53b259eaadd60303"},
|
||||||
|
{"1468956b2009da0abc540721681516d2d836fbb19692276d07345b6706a53129", "eef70d99244f8e5de8c938b56d3079990652e399edf4996c7ba3090bd20e652a"},
|
||||||
|
{"c641b2667bc124b26572f9fbbec9ecf839db74c9edec9a75168579b71cbb9901", "83b957a57b5ecacc1a4b0231795be7013e488ab0ba2e7cb4122152aa2a14ba18"},
|
||||||
|
{"5bc5c3903a9a19dd230310422c11dc42c590c949580f37dedc6bfb528be5c62f", "5e2dcafd8d018dd8d3ad1e5a7adf58605cd8628dadd96ee48f32bc0f8c4be41b"},
|
||||||
|
{"9766e135d8b9aa253c90202454fa824b03b9d2d25e0b6c18cd99d87cb328590e", "d3f8885f3dfa8a0416937ef89f89d2ee7df9e71852f09f812ac6d7934fccb60d"},
|
||||||
|
{"feb64610db2ac2f01869a198f5a3fc524d6cf0bd171f118bd291c50db1d54a1c", "3e27cd9b28b288fb3d1953a7355c986c88428a0a95b56ee39f7e5aeb0bbfdb0f"},
|
||||||
|
{"571bf13dc817ae45281208cf712cee1917900e203be6d617984bb493e0c24c25", "132f0e795cb6f5127e9fbaff53b28e4baf05df08b92dcbdc05d8ea2638d9e70c"},
|
||||||
|
{"fb649a934864788acacdfa654bc262cb71af2842f0e0b65054f37e8bc5332d08", "67a5a6e195a43d1492461d65ac8dd2b254b1467bfe85342cec8fe6ae9892ca1e"},
|
||||||
|
{"bd6d4da3fcb81b710dbba70051fe8d565c47419517fea3d20639667edb415413", "07fc16e5a1523005ca08be860c4dc58413b773c1c15f9079c6d373f9e2f93228"},
|
||||||
|
{"e49799e28327a6e8f4a1d1ad7290345a37a263284517b094d325e7e17593971d", "641a4439c23e414ef21dd7a563cd75f533a3e26b1e11f5d207d29629d5c4d416"},
|
||||||
|
{"c0ba522a52198ab0a79d935b17eb57611d141f0ac3864e2a37439e4996591e24", "78fe086005cd3baaa5315cd138530ef4d7f6febc6e427cd71625329c56419312"},
|
||||||
|
{"871ee440ba18913aeec0d7fac20c9671e4ceba8e1cde2dc74e2636ca57de6922", "9d2e7c22c6b8b723b06e5960c92b1a7e6cc4cd11619ec7f21b7c1543103aae2a"},
|
||||||
|
{"ab5a1272cd4e16be953511a5c5ef9ea24f0072f8bd976314d260757ed0b30c12", "ebfc21341bfde18f6f7fe1b883d83b43278a635b5d699525aeaa2eec2aba211e"},
|
||||||
|
{"2c9e91994096c903e90144689053f6f3d9645bc6e11ce48e82facfb03551c41b", "f9cb618cc78c0e630f3035da914c8606ac1b6629657210308509cf6724748300"},
|
||||||
|
{"ba41a3b75d7fdd1962feddb3ebabfb1ed01480334dd3bcae3e45f80db0353123", "39eecd2d4a751206f4aeed3dba6d9acc0aefddba1897eb91731f767ed94cfd07"},
|
||||||
|
{"ccf1feef0bca203265ffda1e22d88c7d23db4244658f8b3629cc1c7bec17fe02", "093c3209e63e409899050e2b2e17b6397a9e6c9f267056b1300814d9bfadf80c"},
|
||||||
|
{"7c2f59be680d820f1fdd4b95982b31931cf3d218088e36f1400d07089f1c2211", "67eb216710fae6f8cdc776e8edbe6adedb670d2ae92a399e80d35ed1dd82de16"},
|
||||||
|
{"94063e3fa709f74b22761cbc400d3b7971b0e32d75de9618c11caa06c6d0c012", "c2eefc502f09e9098c554d7db21cc4ebe3432baed062fb7f1a70d3ea76044d18"},
|
||||||
|
{"bd8a78715e32d4d7b263b2f358509157a8f1488a48860cb4dae04501e5040926", "f9dac2ab11885c3478469582ec619714623485572a65839aa6a6254c7fbfc914"},
|
||||||
|
{"c742d8f410f594be95b9c70f30ab2b3c752388f5d5c139653e3e1f46a3ea1c2a", "39a28b57b0341b76c9a6d8d4502702aa79f03b6b4c71b4a8b16ee73289f9a405"},
|
||||||
|
{"b74ce76b34b4e0bea87c576b4185f6e0e2fe60a1ee29a7be6685ab06f84b340d", "fabe6f436f34a98de98776d7170a537afdc4e697933ef83f3ee083619eb6550b"},
|
||||||
|
{"89f3b3d0a0563fdb52d340d60bd4a94acb8e9fcb1a078b3784f5d5dd0a76bc2f", "54e5e2dc8bee937a903dbb41fda7d26855d1a852c10f86e60fadae5284a2d82c"},
|
||||||
|
{"6a2b21264c42a6fe6968eb4d9539f7d3bd02b0598c58c2a4e709249016720b0d", "a02038d629f056214390c7c3d07b29d9fd2187e671bf68edfc4c4e6d215e2a1d"},
|
||||||
|
{"a7f518c047cb8af54cbab674f684d2114517a5ece15b38511333fe60fa75b10a", "e092a4f17f93aabe3b062cd0a41321a3cef624c1b6cfd943d3a5f1834cb2ae03"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
const STATIC_GROUP_MERKLE_ROOT = "805be2ac92bc8b21bf093440f5a8055a8a4ec7bf5c5af5e22680d9123a4a5c2b"
|
||||||
|
|
||||||
|
const EPOCH_UNIT_SECONDS = uint64(10) // the rln-relay epoch length in seconds
|
||||||
|
|
||||||
|
type Epoch [32]byte
|
||||||
|
|
||||||
|
func BytesToEpoch(b []byte) Epoch {
|
||||||
|
var result Epoch
|
||||||
|
copy(result[:], b)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func ToEpoch(t uint64) Epoch {
|
||||||
|
var result Epoch
|
||||||
|
binary.LittleEndian.PutUint64(result[:], t)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Epoch) Uint64() uint64 {
|
||||||
|
return binary.LittleEndian.Uint64(e[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// CalcEpoch returns the corresponding rln `Epoch` value for a time.Time
|
||||||
|
func CalcEpoch(t time.Time) Epoch {
|
||||||
|
return ToEpoch(uint64(t.Unix()) / EPOCH_UNIT_SECONDS)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentEpoch gets the current rln Epoch time
|
||||||
|
func GetCurrentEpoch() Epoch {
|
||||||
|
return CalcEpoch(time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Diff returns the difference between the two rln `Epoch`s `e1` and `e2`
|
||||||
|
func Diff(e1, e2 Epoch) int64 {
|
||||||
|
epoch1 := e1.Uint64()
|
||||||
|
epoch2 := e2.Uint64()
|
||||||
|
return int64(epoch1) - int64(epoch2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Epoch) Time() time.Time {
|
||||||
|
return time.Unix(int64(e.Uint64()*EPOCH_UNIT_SECONDS), 0)
|
||||||
|
}
|
|
@ -25,12 +25,12 @@ func toMembershipKeyPairs(groupKeys [][]string) ([]MembershipKeyPair, error) {
|
||||||
|
|
||||||
func Bytes32(b []byte) [32]byte {
|
func Bytes32(b []byte) [32]byte {
|
||||||
var result [32]byte
|
var result [32]byte
|
||||||
copy(result[:], b)
|
copy(result[32-len(b):], b)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func Bytes256(b []byte) [256]byte {
|
func Bytes128(b []byte) [128]byte {
|
||||||
var result [256]byte
|
var result [128]byte
|
||||||
copy(result[:], b)
|
copy(result[128-len(b):], b)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
|
@ -932,10 +932,7 @@ github.com/status-im/go-discover/discover/v5wire
|
||||||
# github.com/status-im/go-multiaddr-ethv4 v1.2.3
|
# github.com/status-im/go-multiaddr-ethv4 v1.2.3
|
||||||
## explicit; go 1.11
|
## explicit; go 1.11
|
||||||
github.com/status-im/go-multiaddr-ethv4
|
github.com/status-im/go-multiaddr-ethv4
|
||||||
# github.com/status-im/go-rln v0.1.1
|
# github.com/status-im/go-waku v0.2.3-0.20221005220914-22c049dfd68b
|
||||||
## explicit; go 1.17
|
|
||||||
github.com/status-im/go-rln/rln
|
|
||||||
# github.com/status-im/go-waku v0.2.3-0.20221003200721-1b3e23cf4e0b
|
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
github.com/status-im/go-waku/logging
|
github.com/status-im/go-waku/logging
|
||||||
github.com/status-im/go-waku/waku/persistence
|
github.com/status-im/go-waku/waku/persistence
|
||||||
|
@ -961,6 +958,10 @@ github.com/status-im/go-waku/waku/v2/utils
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
github.com/status-im/go-waku-rendezvous
|
github.com/status-im/go-waku-rendezvous
|
||||||
github.com/status-im/go-waku-rendezvous/pb
|
github.com/status-im/go-waku-rendezvous/pb
|
||||||
|
# github.com/status-im/go-zerokit-rln v0.1.3
|
||||||
|
## explicit; go 1.17
|
||||||
|
github.com/status-im/go-zerokit-rln/rln
|
||||||
|
github.com/status-im/go-zerokit-rln/rln/resources
|
||||||
# github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969
|
# github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969
|
||||||
## explicit
|
## explicit
|
||||||
github.com/status-im/keycard-go/derivationpath
|
github.com/status-im/keycard-go/derivationpath
|
||||||
|
|
Loading…
Reference in New Issue