feat: use verifyProofWithRoots

This commit is contained in:
Richard Ramos 2022-10-07 18:58:16 -04:00 committed by RichΛrd
parent 4841f89eff
commit e91fd0e649
9 changed files with 23 additions and 6 deletions

View File

@ -126,7 +126,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-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.3 // indirect github.com/status-im/go-zerokit-rln v0.1.4 // 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

@ -1618,6 +1618,8 @@ github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 h1:Gg
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.3 h1:3UxA29BoMPlBrXw1Cddubmq4XR96ihH9KpnwfzzPtq4= 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/go-zerokit-rln v0.1.3/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/go-zerokit-rln v0.1.4 h1:rHrtmm6jl0y5oLswNZHrTmAVmA6Sz16V1QjBTYHmm3Y=
github.com/status-im/go-zerokit-rln v0.1.4/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

@ -19,7 +19,7 @@ require (
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-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.3 github.com/status-im/go-zerokit-rln v0.1.4
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

@ -1653,6 +1653,8 @@ github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 h1:Gg
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.3 h1:3UxA29BoMPlBrXw1Cddubmq4XR96ihH9KpnwfzzPtq4= 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/go-zerokit-rln v0.1.3/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/go-zerokit-rln v0.1.4 h1:rHrtmm6jl0y5oLswNZHrTmAVmA6Sz16V1QjBTYHmm3Y=
github.com/status-im/go-zerokit-rln v0.1.4/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

@ -127,7 +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.3 // indirect github.com/status-im/go-zerokit-rln v0.1.4 // 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

@ -1619,6 +1619,8 @@ github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 h1:Gg
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.3 h1:3UxA29BoMPlBrXw1Cddubmq4XR96ihH9KpnwfzzPtq4= 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/go-zerokit-rln v0.1.3/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/go-zerokit-rln v0.1.4 h1:rHrtmm6jl0y5oLswNZHrTmAVmA6Sz16V1QjBTYHmm3Y=
github.com/status-im/go-zerokit-rln v0.1.4/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-zerokit-rln v0.1.3 github.com/status-im/go-zerokit-rln v0.1.4
golang.org/x/text v0.3.7 golang.org/x/text v0.3.7
) )

2
go.sum
View File

@ -1643,6 +1643,8 @@ github.com/status-im/go-watchdog v1.2.0-ios-nolibproc h1:BJwZEF7OVKaXc2zErBUAolF
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 h1:3UxA29BoMPlBrXw1Cddubmq4XR96ihH9KpnwfzzPtq4=
github.com/status-im/go-zerokit-rln v0.1.3/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI= github.com/status-im/go-zerokit-rln v0.1.3/go.mod h1:buDqUAAFez13mhNTGAJKD03XyEe8PdlTKdsTbfi8imI=
github.com/status-im/go-zerokit-rln v0.1.4 h1:rHrtmm6jl0y5oLswNZHrTmAVmA6Sz16V1QjBTYHmm3Y=
github.com/status-im/go-zerokit-rln v0.1.4/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

@ -217,9 +217,18 @@ func (rln *WakuRLNRelay) ValidateMessage(msg *pb.WakuMessage, optionalTime *time
// verify the proof // verify the proof
contentTopicBytes := []byte(msg.ContentTopic) contentTopicBytes := []byte(msg.ContentTopic)
input := append(msg.Payload, contentTopicBytes...) input := append(msg.Payload, contentTopicBytes...)
if !rln.RLN.Verify(input, *msgProof) {
// TODO: set window of roots
roots := [][32]byte{}
valid, err := rln.RLN.VerifyWithRoots(input, *msgProof, roots)
if err != nil {
rln.log.Debug("could not verify proof", zap.Error(err))
return MessageValidationResult_Invalid, nil
}
if !valid {
// invalid proof // invalid proof
rln.log.Debug("invalid message: invalid proof") rln.log.Debug("Invalid proof")
return MessageValidationResult_Invalid, nil return MessageValidationResult_Invalid, nil
} }