feat: zerokit RLN

This commit is contained in:
Richard Ramos 2022-10-04 19:15:39 -04:00 committed by RichΛrd
parent 5af5e89c08
commit 4d23f4256a
28 changed files with 192 additions and 426 deletions

View File

@ -134,7 +134,7 @@ You will see a different value than `165886530` on your screen.
If two messages sent by the same chat2 client happen to have the same RLN epoch value, then one of them will be detected as spam and won't be routed (by test fleets in this test setting). If two messages sent by the same chat2 client happen to have the same RLN epoch value, then one of them will be detected as spam and won't be routed (by test fleets in this test setting).
You'll also see a `ERROR: validation failed` message You'll also see a `ERROR: validation failed` message
At the time of this tutorial, the epoch duration is set to `10` seconds. At the time of this tutorial, the epoch duration is set to `10` seconds.
You can inspect the current epoch value by checking the following [constant variable](https://github.com/status-im/go-rln/blob/main/rln/types.go#L194) in the go-rln codebase. You can inspect the current epoch value by checking the following [constant variable](https://github.com/status-im/go-zerokit-rln/blob/main/rln/types.go#L194) in the go-rln codebase.
Thus, if you send two messages less than `10` seconds apart, they are likely to get the same `rln epoch` values. Thus, if you send two messages less than `10` seconds apart, they are likely to get the same `rln epoch` values.
After sending a chat message, you may experience some delay before the next chat prompt appears. After sending a chat message, you may experience some delay before the next chat prompt appears.

View File

@ -125,8 +125,8 @@ require (
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
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-rln v0.0.9 // indirect
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 // indirect github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 // indirect
github.com/status-im/go-zerokit-rln v0.1.2 // indirect
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect
github.com/status-im/status-go/extkeys v1.1.2 // indirect github.com/status-im/status-go/extkeys v1.1.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect

View File

@ -1653,10 +1653,12 @@ github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e h1:fDm8hqKGF
github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c= github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c=
github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA= github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA=
github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE= github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE=
github.com/status-im/go-rln v0.0.9 h1:qDmFJoFS/1PGNDB0pEjlRDRNZUpIFBAde2f3fIixCbA=
github.com/status-im/go-rln v0.0.9/go.mod h1:t8Bf4nNAuQh9VlEiz/rgFVtEz7sjEfcd62MIuEnZn8U=
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-zerokit-rln v0.1.1 h1:vSWYAlfgiZHhmDXwcOP41GtEJEhxR0P+pWGuNnbH8F4=
github.com/status-im/go-zerokit-rln v0.1.1/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/go-zerokit-rln v0.1.2 h1:o1r9+MChdr5U2+T0sSojmNzgDvAUgtwIWAvpDDvkYsg=
github.com/status-im/go-zerokit-rln v0.1.2/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg=
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=
github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk= github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk=

View File

@ -13,7 +13,6 @@ import (
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"github.com/multiformats/go-multiaddr" "github.com/multiformats/go-multiaddr"
"github.com/status-im/go-rln/rln"
"github.com/status-im/go-waku/waku/v2/dnsdisc" "github.com/status-im/go-waku/waku/v2/dnsdisc"
"github.com/status-im/go-waku/waku/v2/node" "github.com/status-im/go-waku/waku/v2/node"
"github.com/status-im/go-waku/waku/v2/protocol" "github.com/status-im/go-waku/waku/v2/protocol"
@ -23,6 +22,7 @@ import (
"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/protocol/store" "github.com/status-im/go-waku/waku/v2/protocol/store"
"github.com/status-im/go-waku/waku/v2/utils" "github.com/status-im/go-waku/waku/v2/utils"
"github.com/status-im/go-zerokit-rln/rln"
"golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/pbkdf2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )

View File

@ -8,6 +8,8 @@ replace github.com/ethereum/go-ethereum v1.10.21 => github.com/status-im/go-ethe
replace github.com/flynn/noise v1.0.0 => github.com/status-im/noise v1.0.1-handshakeMessages replace github.com/flynn/noise v1.0.0 => github.com/status-im/noise v1.0.1-handshakeMessages
replace github.com/status-im/go-zerokit-rln => ../../../go-zerokit-rln
require ( require (
github.com/charmbracelet/bubbles v0.13.0 github.com/charmbracelet/bubbles v0.13.0
github.com/charmbracelet/bubbletea v0.22.0 github.com/charmbracelet/bubbletea v0.22.0
@ -18,8 +20,8 @@ require (
github.com/libp2p/go-libp2p-core v0.19.1 github.com/libp2p/go-libp2p-core v0.19.1
github.com/muesli/reflow v0.3.0 github.com/muesli/reflow v0.3.0
github.com/multiformats/go-multiaddr v0.6.0 github.com/multiformats/go-multiaddr v0.6.0
github.com/status-im/go-rln v0.1.1
github.com/status-im/go-waku v0.0.0-00010101000000-000000000000 github.com/status-im/go-waku v0.0.0-00010101000000-000000000000
github.com/status-im/go-zerokit-rln v0.1.2
github.com/urfave/cli/v2 v2.11.2 github.com/urfave/cli/v2 v2.11.2
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211

View File

@ -1688,10 +1688,10 @@ github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e h1:fDm8hqKGF
github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c= github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c=
github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA= github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA=
github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE= github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE=
github.com/status-im/go-rln v0.1.1 h1:Evbma0GZ0dgzbKcm92SWzHMZ4pOlVBxH1+z9eQAd1i4=
github.com/status-im/go-rln v0.1.1/go.mod h1:t8Bf4nNAuQh9VlEiz/rgFVtEz7sjEfcd62MIuEnZn8U=
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-zerokit-rln v0.1.1 h1:vSWYAlfgiZHhmDXwcOP41GtEJEhxR0P+pWGuNnbH8F4=
github.com/status-im/go-zerokit-rln v0.1.1/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg=
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=
github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk= github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk=

View File

@ -9,7 +9,7 @@ import (
"path/filepath" "path/filepath"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/status-im/go-rln/rln" "github.com/status-im/go-zerokit-rln/rln"
) )
type membershipKeyPair struct { type membershipKeyPair struct {

View File

@ -127,6 +127,7 @@ require (
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-rln v0.0.9 // indirect github.com/status-im/go-rln v0.0.9 // indirect
github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 // indirect github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 // indirect
github.com/status-im/go-zerokit-rln v0.1.2 // indirect
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect
github.com/status-im/status-go/extkeys v1.1.2 // indirect github.com/status-im/status-go/extkeys v1.1.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect

View File

@ -1653,10 +1653,13 @@ github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e h1:fDm8hqKGF
github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c= github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c=
github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA= github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA=
github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE= github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE=
github.com/status-im/go-rln v0.0.9 h1:qDmFJoFS/1PGNDB0pEjlRDRNZUpIFBAde2f3fIixCbA=
github.com/status-im/go-rln v0.0.9/go.mod h1:t8Bf4nNAuQh9VlEiz/rgFVtEz7sjEfcd62MIuEnZn8U= github.com/status-im/go-rln v0.0.9/go.mod h1:t8Bf4nNAuQh9VlEiz/rgFVtEz7sjEfcd62MIuEnZn8U=
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-zerokit-rln v0.1.1 h1:vSWYAlfgiZHhmDXwcOP41GtEJEhxR0P+pWGuNnbH8F4=
github.com/status-im/go-zerokit-rln v0.1.1/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/go-zerokit-rln v0.1.2 h1:o1r9+MChdr5U2+T0sSojmNzgDvAUgtwIWAvpDDvkYsg=
github.com/status-im/go-zerokit-rln v0.1.2/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg=
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=
github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk= github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk=

2
go.mod
View File

@ -40,7 +40,7 @@ require (
require ( require (
github.com/flynn/noise v1.0.0 github.com/flynn/noise v1.0.0
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/status-im/go-rln v0.1.1 github.com/status-im/go-zerokit-rln v0.1.2
golang.org/x/text v0.3.7 golang.org/x/text v0.3.7
) )

6
go.sum
View File

@ -1671,12 +1671,14 @@ github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e h1:fDm8hqKGF
github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c= github.com/status-im/go-discover v0.0.0-20220406135310-85a2ce36f63e/go.mod h1:u1s0ACIlweIjmJrgXyljRPSOflZLaS6ezb044+92W3c=
github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA= github.com/status-im/go-ethereum v1.10.4-status.2 h1:uvcD2U7skYqPQviARFb4w3wZyFSYLs/pfVrJaRSDcCA=
github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE= github.com/status-im/go-ethereum v1.10.4-status.2/go.mod h1:GvIhpdCOgMHI6i5xVPEZOrv/qSMeOFHbZh77AoyZUoE=
github.com/status-im/go-rln v0.1.1 h1:Evbma0GZ0dgzbKcm92SWzHMZ4pOlVBxH1+z9eQAd1i4=
github.com/status-im/go-rln v0.1.1/go.mod h1:t8Bf4nNAuQh9VlEiz/rgFVtEz7sjEfcd62MIuEnZn8U=
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.1 h1:vSWYAlfgiZHhmDXwcOP41GtEJEhxR0P+pWGuNnbH8F4=
github.com/status-im/go-zerokit-rln v0.1.1/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/go-zerokit-rln v0.1.2 h1:o1r9+MChdr5U2+T0sSojmNzgDvAUgtwIWAvpDDvkYsg=
github.com/status-im/go-zerokit-rln v0.1.2/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg=
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=
github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk= github.com/status-im/noise v1.0.1-handshakeMessages h1:mj1btE58Qk2pS0qz+BHE22HYIOhZoEFNTnRpQeMfHYk=

View File

@ -7,8 +7,8 @@ import (
"crypto/ecdsa" "crypto/ecdsa"
"errors" "errors"
"github.com/status-im/go-rln/rln"
"github.com/status-im/go-waku/waku/v2/node" "github.com/status-im/go-waku/waku/v2/node"
"github.com/status-im/go-zerokit-rln/rln"
"go.uber.org/zap" "go.uber.org/zap"
) )

View File

@ -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
} }

View File

@ -12,7 +12,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/status-im/go-rln/rln" "github.com/status-im/go-zerokit-rln/rln"
"go.uber.org/zap" "go.uber.org/zap"
) )

View File

@ -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"
) )

View File

@ -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

View File

@ -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:])

View File

@ -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 {

File diff suppressed because one or more lines are too long

View File

@ -1,3 +0,0 @@
package rln
//go:generate go-bindata -pkg rln -o ./bindata.go parameters.key

View File

@ -7,13 +7,12 @@ import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"crypto/rand" "crypto/rand"
"errors"
"math/big" "math/big"
"sync" "sync"
"testing" "testing"
"time" "time"
r "github.com/status-im/go-rln/rln" r "github.com/status-im/go-zerokit-rln/rln"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -98,11 +97,8 @@ func (s *WakuRLNRelayDynamicSuite) register(privKey *ecdsa.PrivateKey, commitmen
} }
func (s *WakuRLNRelayDynamicSuite) TestDynamicGroupManagement() { func (s *WakuRLNRelayDynamicSuite) TestDynamicGroupManagement() {
params, err := parametersKeyBytes()
s.Require().NoError(err)
// Create a RLN instance // Create a RLN instance
rlnInstance, err := r.NewRLN(params) rlnInstance, err := r.NewRLN()
s.Require().NoError(err) s.Require().NoError(err)
keyPair, err := rlnInstance.MembershipKeyGen() keyPair, err := rlnInstance.MembershipKeyGen()
@ -133,11 +129,7 @@ func (s *WakuRLNRelayDynamicSuite) TestDynamicGroupManagement() {
wg.Done() wg.Done()
} }
if !rlnInstance.InsertMember(pubkey) { return rlnInstance.InsertMember(pubkey)
return errors.New("couldn't insert member")
}
return nil
} }
errChan := make(chan error, 1) errChan := make(chan error, 1)
@ -181,11 +173,8 @@ func (s *WakuRLNRelayDynamicSuite) TestInsertKeyMembershipContract() {
} }
func (s *WakuRLNRelayDynamicSuite) TestRegistrationProcedure() { func (s *WakuRLNRelayDynamicSuite) TestRegistrationProcedure() {
params, err := parametersKeyBytes()
s.Require().NoError(err)
// Create a RLN instance // Create a RLN instance
rlnInstance, err := r.NewRLN(params) rlnInstance, err := r.NewRLN()
s.Require().NoError(err) s.Require().NoError(err)
keyPair, err := rlnInstance.MembershipKeyGen() keyPair, err := rlnInstance.MembershipKeyGen()
@ -209,11 +198,8 @@ func (s *WakuRLNRelayDynamicSuite) TestRegistrationProcedure() {
} }
func (s *WakuRLNRelayDynamicSuite) TestMerkleTreeConstruction() { func (s *WakuRLNRelayDynamicSuite) TestMerkleTreeConstruction() {
params, err := parametersKeyBytes()
s.Require().NoError(err)
// Create a RLN instance // Create a RLN instance
rlnInstance, err := r.NewRLN(params) rlnInstance, err := r.NewRLN()
s.Require().NoError(err) s.Require().NoError(err)
keyPair1, err := rlnInstance.MembershipKeyGen() keyPair1, err := rlnInstance.MembershipKeyGen()
@ -222,10 +208,11 @@ func (s *WakuRLNRelayDynamicSuite) TestMerkleTreeConstruction() {
keyPair2, err := rlnInstance.MembershipKeyGen() keyPair2, err := rlnInstance.MembershipKeyGen()
s.Require().NoError(err) s.Require().NoError(err)
r1 := rlnInstance.InsertMember(keyPair1.IDCommitment) err = rlnInstance.InsertMember(keyPair1.IDCommitment)
r2 := rlnInstance.InsertMember(keyPair2.IDCommitment) s.Require().NoError(err)
s.Require().True(r1)
s.Require().True(r2) err = rlnInstance.InsertMember(keyPair2.IDCommitment)
s.Require().NoError(err)
// get the Merkle root // get the Merkle root
expectedRoot, err := rlnInstance.GetMerkleRoot() expectedRoot, err := rlnInstance.GetMerkleRoot()
@ -250,7 +237,7 @@ func (s *WakuRLNRelayDynamicSuite) TestMerkleTreeConstruction() {
defer sub.Unsubscribe() defer sub.Unsubscribe()
// mount the rln relay protocol in the on-chain/dynamic mode // mount the rln relay protocol in the on-chain/dynamic mode
rlnRelay, err := RlnRelayDynamic(context.TODO(), relay, ETH_CLIENT_ADDRESS, nil, s.rlnAddr, keyPair1, r.MembershipIndex(0), RLNRELAY_PUBSUB_TOPIC, RLNRELAY_CONTENT_TOPIC, nil, utils.Logger()) rlnRelay, err := RlnRelayDynamic(context.TODO(), relay, ETH_CLIENT_ADDRESS, nil, s.rlnAddr, keyPair1, r.MembershipIndex(0), RLNRELAY_PUBSUB_TOPIC, RLNRELAY_CONTENT_TOPIC, nil, nil, utils.Logger())
s.Require().NoError(err) s.Require().NoError(err)
// wait for the event to reach the group handler // wait for the event to reach the group handler
@ -282,7 +269,7 @@ func (s *WakuRLNRelayDynamicSuite) TestCorrectRegistrationOfPeers() {
defer sub1.Unsubscribe() defer sub1.Unsubscribe()
// mount the rln relay protocol in the on-chain/dynamic mode // mount the rln relay protocol in the on-chain/dynamic mode
rlnRelay1, err := RlnRelayDynamic(context.TODO(), relay1, ETH_CLIENT_ADDRESS, s.u1PrivKey, s.rlnAddr, nil, r.MembershipIndex(0), RLNRELAY_PUBSUB_TOPIC, RLNRELAY_CONTENT_TOPIC, nil, utils.Logger()) rlnRelay1, err := RlnRelayDynamic(context.TODO(), relay1, ETH_CLIENT_ADDRESS, s.u1PrivKey, s.rlnAddr, nil, r.MembershipIndex(0), RLNRELAY_PUBSUB_TOPIC, RLNRELAY_CONTENT_TOPIC, nil, nil, utils.Logger())
s.Require().NoError(err) s.Require().NoError(err)
// Node 2 ============================================================ // Node 2 ============================================================
@ -301,7 +288,7 @@ func (s *WakuRLNRelayDynamicSuite) TestCorrectRegistrationOfPeers() {
defer sub2.Unsubscribe() defer sub2.Unsubscribe()
// mount the rln relay protocol in the on-chain/dynamic mode // mount the rln relay protocol in the on-chain/dynamic mode
rlnRelay2, err := RlnRelayDynamic(context.TODO(), relay2, ETH_CLIENT_ADDRESS, s.u2PrivKey, s.rlnAddr, nil, r.MembershipIndex(0), RLNRELAY_PUBSUB_TOPIC, RLNRELAY_CONTENT_TOPIC, nil, utils.Logger()) rlnRelay2, err := RlnRelayDynamic(context.TODO(), relay2, ETH_CLIENT_ADDRESS, s.u2PrivKey, s.rlnAddr, nil, r.MembershipIndex(0), RLNRELAY_PUBSUB_TOPIC, RLNRELAY_CONTENT_TOPIC, nil, nil, utils.Logger())
s.Require().NoError(err) s.Require().NoError(err)
// ================================== // ==================================

Binary file not shown.

View File

@ -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)

View File

@ -6,11 +6,11 @@ import (
"testing" "testing"
"time" "time"
r "github.com/status-im/go-rln/rln"
"github.com/status-im/go-waku/tests" "github.com/status-im/go-waku/tests"
"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"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
@ -36,10 +36,7 @@ func (s *WakuRLNRelaySuite) TestOffchainMode() {
defer relay.Stop() defer relay.Stop()
s.Require().NoError(err) s.Require().NoError(err)
params, err := parametersKeyBytes() groupKeyPairs, root, err := r.CreateMembershipList(100)
s.Require().NoError(err)
groupKeyPairs, root, err := r.CreateMembershipList(100, params)
s.Require().NoError(err) s.Require().NoError(err)
var groupIDCommitments []r.IDCommitment var groupIDCommitments []r.IDCommitment
@ -122,10 +119,7 @@ func (s *WakuRLNRelaySuite) TestUpdateLogAndHasDuplicate() {
} }
func (s *WakuRLNRelaySuite) TestValidateMessage() { func (s *WakuRLNRelaySuite) TestValidateMessage() {
params, err := parametersKeyBytes() groupKeyPairs, _, err := r.CreateMembershipList(100)
s.Require().NoError(err)
groupKeyPairs, _, err := r.CreateMembershipList(100, params)
s.Require().NoError(err) s.Require().NoError(err)
var groupIDCommitments []r.IDCommitment var groupIDCommitments []r.IDCommitment
@ -139,11 +133,11 @@ func (s *WakuRLNRelaySuite) TestValidateMessage() {
index := r.MembershipIndex(5) index := r.MembershipIndex(5)
// Create a RLN instance // Create a RLN instance
rlnInstance, err := r.NewRLN(params) rlnInstance, err := r.NewRLN()
s.Require().NoError(err) s.Require().NoError(err)
added := rlnInstance.AddAll(groupIDCommitments) err = rlnInstance.AddAll(groupIDCommitments)
s.Require().True(added) s.Require().NoError(err)
rlnRelay := &WakuRLNRelay{ rlnRelay := &WakuRLNRelay{
membershipIndex: index, membershipIndex: index,

View File

@ -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"
) )
@ -270,6 +270,7 @@ func (rln *WakuRLNRelay) AppendRLNProof(msg *pb.WakuMessage, senderEpochTime tim
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,12 +396,13 @@ func ToRateLimitProof(msg *pb.WakuMessage) *r.RateLimitProof {
} }
result := &r.RateLimitProof{ result := &r.RateLimitProof{
Proof: r.ZKSNARK(Bytes256(msg.RateLimitProof.Proof)), Proof: r.ZKSNARK(Bytes128(msg.RateLimitProof.Proof)),
MerkleRoot: r.MerkleNode(Bytes32(msg.RateLimitProof.MerkleRoot)), MerkleRoot: r.MerkleNode(Bytes32(msg.RateLimitProof.MerkleRoot)),
Epoch: r.Epoch(Bytes32(msg.RateLimitProof.Epoch)), Epoch: r.Epoch(Bytes32(msg.RateLimitProof.Epoch)),
ShareX: r.MerkleNode(Bytes32(msg.RateLimitProof.ShareX)), ShareX: r.MerkleNode(Bytes32(msg.RateLimitProof.ShareX)),
ShareY: r.MerkleNode(Bytes32(msg.RateLimitProof.ShareY)), ShareY: r.MerkleNode(Bytes32(msg.RateLimitProof.ShareY)),
Nullifier: r.Nullifier(Bytes32(msg.RateLimitProof.Nullifier)), Nullifier: r.Nullifier(Bytes32(msg.RateLimitProof.Nullifier)),
RLNIdentifier: r.RLNIdentifier(Bytes32(msg.RateLimitProof.RlnIdentifier)),
} }
return result return result
@ -412,8 +414,8 @@ func Bytes32(b []byte) [32]byte {
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[:], b)
return result return result
} }

View File

@ -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"
) )

View File

@ -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.

View File

@ -22,6 +22,7 @@ type RateLimitProof struct {
ShareX HexBytes `json:"share_x,omitempty"` ShareX HexBytes `json:"share_x,omitempty"`
ShareY HexBytes `json:"share_y,omitempty"` ShareY HexBytes `json:"share_y,omitempty"`
Nullifier HexBytes `json:"nullifier,omitempty"` Nullifier HexBytes `json:"nullifier,omitempty"`
RlnIdentifier HexBytes `json:"rln_identifier,omitempty"`
} }
type RPCWakuMessage struct { type RPCWakuMessage struct {
@ -60,6 +61,7 @@ func ProtoWakuMessageToRPCWakuMessage(input *pb.WakuMessage) *RPCWakuMessage {
ShareX: input.RateLimitProof.ShareX, ShareX: input.RateLimitProof.ShareX,
ShareY: input.RateLimitProof.ShareY, ShareY: input.RateLimitProof.ShareY,
Nullifier: input.RateLimitProof.Nullifier, Nullifier: input.RateLimitProof.Nullifier,
RlnIdentifier: input.RateLimitProof.RlnIdentifier,
} }
} }
@ -86,6 +88,7 @@ func (r *RPCWakuMessage) toProto() *pb.WakuMessage {
ShareX: r.RateLimitProof.ShareX, ShareX: r.RateLimitProof.ShareX,
ShareY: r.RateLimitProof.ShareY, ShareY: r.RateLimitProof.ShareY,
Nullifier: r.RateLimitProof.Nullifier, Nullifier: r.RateLimitProof.Nullifier,
RlnIdentifier: r.RateLimitProof.RlnIdentifier,
} }
} }
@ -137,6 +140,7 @@ func ProtoWakuMessageToRPCWakuRelayMessage(input *pb.WakuMessage) *RPCWakuRelayM
ShareX: input.RateLimitProof.ShareX, ShareX: input.RateLimitProof.ShareX,
ShareY: input.RateLimitProof.ShareY, ShareY: input.RateLimitProof.ShareY,
Nullifier: input.RateLimitProof.Nullifier, Nullifier: input.RateLimitProof.Nullifier,
RlnIdentifier: input.RateLimitProof.RlnIdentifier,
} }
} }
@ -163,6 +167,7 @@ func (r *RPCWakuRelayMessage) toProto() *pb.WakuMessage {
ShareX: r.RateLimitProof.ShareX, ShareX: r.RateLimitProof.ShareX,
ShareY: r.RateLimitProof.ShareY, ShareY: r.RateLimitProof.ShareY,
Nullifier: r.RateLimitProof.Nullifier, Nullifier: r.RateLimitProof.Nullifier,
RlnIdentifier: r.RateLimitProof.RlnIdentifier,
} }
} }