mirror of https://github.com/status-im/go-waku.git
fix: nwaku / go-waku rlnKeystore compat
This commit is contained in:
parent
eb836d71e3
commit
da45dab68e
|
@ -1,6 +1,5 @@
|
|||
nodekey
|
||||
rlnCredentials.txt
|
||||
rlnCredentials.json
|
||||
rlnKeystore.json
|
||||
test_onchain.json
|
||||
*.bkp
|
||||
*.log
|
||||
|
|
|
@ -74,7 +74,7 @@ func rlnFlags() []cli.Flag {
|
|||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "rln-relay-eth-contract-address",
|
||||
Usage: "Address of membership contract ",
|
||||
Usage: "Address of membership contract",
|
||||
Value: &wcli.AddressValue{
|
||||
Value: &options.RLNRelay.MembershipContractAddress,
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"github.com/waku-org/go-waku/waku/v2/node"
|
||||
"github.com/waku-org/go-waku/waku/v2/peers"
|
||||
"github.com/waku-org/go-waku/waku/v2/peerstore"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/filter"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/lightpush"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/pb"
|
||||
|
@ -76,6 +76,7 @@ func execute(options Options) {
|
|||
options.RLNRelay.CredentialsPath,
|
||||
options.RLNRelay.CredentialsPassword,
|
||||
options.RLNRelay.CredentialsIndex,
|
||||
"", // Will use default tree path
|
||||
options.RLNRelay.MembershipContractAddress,
|
||||
uint(options.RLNRelay.MembershipIndex),
|
||||
spamHandler,
|
||||
|
@ -144,6 +145,6 @@ func addPeer(wakuNode *node.WakuNode, addr *multiaddr.Multiaddr, protocols ...pr
|
|||
if addr == nil {
|
||||
return nil
|
||||
}
|
||||
_, err := wakuNode.AddPeer(*addr, peers.Static, protocols...)
|
||||
_, err := wakuNode.AddPeer(*addr, peerstore.Static, protocols...)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ require (
|
|||
github.com/multiformats/go-multiaddr v0.9.0
|
||||
github.com/urfave/cli/v2 v2.24.4
|
||||
github.com/waku-org/go-waku v0.2.3-0.20221109195301-b2a5a68d28ba
|
||||
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb
|
||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20230807195439-655973b24310
|
||||
golang.org/x/crypto v0.9.0
|
||||
golang.org/x/term v0.8.0
|
||||
google.golang.org/protobuf v1.31.0
|
||||
|
@ -126,9 +126,9 @@ require (
|
|||
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
|
||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b // indirect
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 // indirect
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 // indirect
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230807124901-05ef8aca570d // indirect
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230807124929-ea702b1b4305 // indirect
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230807124913-ea636e5b4005 // indirect
|
||||
github.com/wk8/go-ordered-map v1.0.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
|
|
|
@ -693,14 +693,14 @@ github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 h1:xwY0kW5XZF
|
|||
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
|
||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
|
||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb h1:pxPRTh2DWCPCC5dhFisHuBCm1k54fMtR8VR6hUWD734=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb/go.mod h1:QYTnrByLh6OXvMzSvPNs5aykT/w4fQb4krGcZfKgSZw=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b h1:wWs8b91SVrxYy37gdNnFDCbjv1hMUHMTwaJUktyjrJE=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230726162122-13b66414cd5b/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0 h1:JU5aMzRFeyG/DOiMwLy3F1AMuuXjzPrUKZpW72kAHxE=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230726162204-c48a56712ef0/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8 h1:pQmTryFdSQuUe8dxt/dHgEfRdLwqf1DEGeReuMcJ9Yg=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230726162310-d761ca9911d8/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20230807195439-655973b24310 h1:/PqVk1fy61o4Wd/ud2qdd8Q9zI3+tpW+GFy/bJ9YTyc=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.14-0.20230807195439-655973b24310/go.mod h1:4KuePn2B86JtUH5U6VYd432A/KI8gHSqoX98Gh4EBbI=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230807124901-05ef8aca570d h1:7Ot7vJAniJWQkarZBFxmjRo39gGksKcqs4kZ10l+szs=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230807124901-05ef8aca570d/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230807124929-ea702b1b4305 h1:33LEcvkC5eRdCIKt0bTG6G6DYZRNQGcpdoScA1ZFgRI=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230807124929-ea702b1b4305/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230807124913-ea636e5b4005 h1:kJfvDpiZZGNTpHB7Mp4BBNj/hsG6UzMg84E+bl+n7Eo=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230807124913-ea636e5b4005/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
|
||||
github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/wk8/go-ordered-map v1.0.0 h1:BV7z+2PaK8LTSd/mWgY12HyMAo5CEgkHqbkVq2thqr8=
|
||||
github.com/wk8/go-ordered-map v1.0.0/go.mod h1:9ZIbRunKbuvfPKyBP1SIKLcXNlv74YCOZ3t3VTS6gRk=
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
];
|
||||
doCheck = false;
|
||||
# FIXME: This needs to be manually changed when updating modules.
|
||||
vendorSha256 = "sha256-JhbZJV0SG7QdKR386Pfg7CWi5bNg+MOKwrzClEzKruw=";
|
||||
vendorSha256 = "sha256-cMjGBz4/sDRcE55cfPBTl1lFkvHfZHeM4bTBcs5lO2s=";
|
||||
# Fix for 'nix run' trying to execute 'go-waku'.
|
||||
meta = { mainProgram = "waku"; };
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
)
|
||||
|
||||
var RLNAppInfo = keystore.AppInfo{
|
||||
Application: "go-waku-rln-relay",
|
||||
Application: "nwaku-rln-relay",
|
||||
AppIdentifier: "01234567890abcdef",
|
||||
Version: "0.1",
|
||||
}
|
||||
|
@ -141,12 +141,6 @@ func NewDynamicGroupManager(
|
|||
}
|
||||
|
||||
func (gm *DynamicGroupManager) getMembershipFee(ctx context.Context) (*big.Int, error) {
|
||||
auth, err := bind.NewKeyedTransactorWithChainID(gm.ethAccountPrivateKey, gm.chainId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
auth.Context = ctx
|
||||
|
||||
return gm.rlnContract.MEMBERSHIPDEPOSIT(&bind.CallOpts{Context: ctx})
|
||||
}
|
||||
|
||||
|
@ -192,7 +186,7 @@ func (gm *DynamicGroupManager) Start(ctx context.Context, rlnInstance *rln.RLN,
|
|||
RLNAppInfo,
|
||||
nil,
|
||||
[]keystore.MembershipContract{{
|
||||
ChainId: gm.chainId.String(),
|
||||
ChainId: fmt.Sprintf("0x%X", gm.chainId),
|
||||
Address: gm.membershipContractAddress.Hex(),
|
||||
}})
|
||||
if err != nil {
|
||||
|
@ -267,7 +261,7 @@ func (gm *DynamicGroupManager) persistCredentials() error {
|
|||
MembershipGroups: []keystore.MembershipGroup{{
|
||||
TreeIndex: *gm.membershipIndex,
|
||||
MembershipContract: keystore.MembershipContract{
|
||||
ChainId: gm.chainId.String(),
|
||||
ChainId: fmt.Sprintf("0x%X", gm.chainId),
|
||||
Address: gm.membershipContractAddress.String(),
|
||||
},
|
||||
}},
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
const RLN_CREDENTIALS_FILENAME = "rlnCredentials.json"
|
||||
const RLN_CREDENTIALS_FILENAME = "rlnKeystore.json"
|
||||
const RLN_CREDENTIALS_PASSWORD = "password"
|
||||
|
||||
type MembershipContract struct {
|
||||
|
@ -38,10 +38,14 @@ type AppInfo struct {
|
|||
}
|
||||
|
||||
type AppKeystore struct {
|
||||
Application string `json:"application"`
|
||||
AppIdentifier string `json:"appIdentifier"`
|
||||
Credentials []keystore.CryptoJSON `json:"credentials"`
|
||||
Version string `json:"version"`
|
||||
Application string `json:"application"`
|
||||
AppIdentifier string `json:"appIdentifier"`
|
||||
Credentials []AppKeystoreCredential `json:"credentials"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
type AppKeystoreCredential struct {
|
||||
Crypto keystore.CryptoJSON `json:"crypto"`
|
||||
}
|
||||
|
||||
const DefaultSeparator = "\n"
|
||||
|
@ -194,7 +198,7 @@ func GetMembershipCredentials(logger *zap.Logger, credentialsPath string, passwo
|
|||
var result []MembershipCredentials
|
||||
|
||||
for _, credential := range k.Credentials {
|
||||
credentialsBytes, err := keystore.DecryptDataV3(credential, password)
|
||||
credentialsBytes, err := keystore.DecryptDataV3(credential.Crypto, password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -226,7 +230,7 @@ func AddMembershipCredentials(path string, credentials []MembershipCredentials,
|
|||
// A flag to tell us if the keystore contains a credential associated to the input identity credential, i.e. membershipCredential
|
||||
found := -1
|
||||
for i, existingCredentials := range k.Credentials {
|
||||
credentialsBytes, err := keystore.DecryptDataV3(existingCredentials, password)
|
||||
credentialsBytes, err := keystore.DecryptDataV3(existingCredentials.Crypto, password)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
@ -259,7 +263,7 @@ func AddMembershipCredentials(path string, credentials []MembershipCredentials,
|
|||
}
|
||||
|
||||
// we update the original credential field in keystoreCredentials
|
||||
k.Credentials[i] = encryptedCredentials
|
||||
k.Credentials[i] = AppKeystoreCredential{Crypto: encryptedCredentials}
|
||||
|
||||
found = i
|
||||
|
||||
|
@ -284,7 +288,7 @@ func AddMembershipCredentials(path string, credentials []MembershipCredentials,
|
|||
return err
|
||||
}
|
||||
|
||||
k.Credentials = append(k.Credentials, encryptedCredentials)
|
||||
k.Credentials = append(k.Credentials, AppKeystoreCredential{Crypto: encryptedCredentials})
|
||||
}
|
||||
|
||||
return save(k, path, separator)
|
||||
|
|
Loading…
Reference in New Issue