mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-09 17:33:08 +00:00
refactor: use uint instead of int for RLN indexes
This commit is contained in:
parent
a4b038730c
commit
33344c2ae0
@ -16,7 +16,7 @@ func rlnFlags() []cli.Flag {
|
||||
Usage: "Enable spam protection through rln-relay",
|
||||
Destination: &options.RLNRelay.Enable,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
&cli.UintFlag{
|
||||
Name: "rln-relay-membership-group-index",
|
||||
Value: 0,
|
||||
Usage: "the index of credentials to use, within a specific rln membership set",
|
||||
@ -51,7 +51,7 @@ func rlnFlags() []cli.Flag {
|
||||
Usage: "Password for encrypting RLN credentials",
|
||||
Destination: &options.RLNRelay.CredentialsPassword,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
&cli.UintFlag{
|
||||
Name: "rln-relay-membership-index",
|
||||
Value: 0,
|
||||
Usage: "the index of credentials to use",
|
||||
|
||||
@ -37,8 +37,8 @@ type RLNRelayOptions struct {
|
||||
Enable bool
|
||||
CredentialsPath string
|
||||
CredentialsPassword string
|
||||
CredentialsIndex int
|
||||
MembershipGroupIndex int
|
||||
CredentialsIndex uint
|
||||
MembershipGroupIndex uint
|
||||
PubsubTopic string
|
||||
ContentTopic string
|
||||
Dynamic bool
|
||||
|
||||
@ -194,13 +194,13 @@ func getFlags() []cli.Flag {
|
||||
Usage: "Enable spam protection through rln-relay",
|
||||
Destination: &options.RLNRelay.Enable,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
&cli.UintFlag{
|
||||
Name: "rln-relay-membership-group-index",
|
||||
Value: 0,
|
||||
Usage: "the index of credentials to use, within a specific rln membership set",
|
||||
Destination: &options.RLNRelay.MembershipGroupIndex,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
&cli.UintFlag{
|
||||
Name: "rln-relay-membership-index",
|
||||
Value: 0,
|
||||
Usage: "the index of credentials to use",
|
||||
|
||||
@ -31,9 +31,9 @@ type RLNRelayOptions struct {
|
||||
Enable bool
|
||||
CredentialsPath string
|
||||
CredentialsPassword string
|
||||
CredentialsIndex int
|
||||
MembershipGroupIndex int
|
||||
MembershipIndex int
|
||||
CredentialsIndex uint
|
||||
MembershipGroupIndex uint
|
||||
MembershipIndex uint
|
||||
PubsubTopic string
|
||||
ContentTopic string
|
||||
Dynamic bool
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
];
|
||||
doCheck = false;
|
||||
# FIXME: This needs to be manually changed when updating modules.
|
||||
vendorSha256 = "sha256-tLlIROm613HFk7/8PduQL2KiuQ3iH1RhDOBneqbDbhc=";
|
||||
vendorSha256 = "sha256-1sioJgLOO5erkjeAIkTWMLZglJERvMo7OzFNvKHwJXA=";
|
||||
# Fix for 'nix run' trying to execute 'go-waku'.
|
||||
meta = { mainProgram = "waku"; };
|
||||
};
|
||||
|
||||
8
go.mod
8
go.mod
@ -39,7 +39,7 @@ require (
|
||||
github.com/jackc/pgx/v5 v5.4.1
|
||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7
|
||||
github.com/waku-org/go-noise v0.0.4
|
||||
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230726180145-0496a42e60fb
|
||||
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230803113701-ea89e5d7eedb
|
||||
github.com/wk8/go-ordered-map v1.0.0
|
||||
)
|
||||
|
||||
@ -71,9 +71,9 @@ require (
|
||||
github.com/rjeczalik/notify v0.9.3 // indirect
|
||||
github.com/rogpeppe/go-internal v1.10.0 // indirect
|
||||
github.com/status-im/status-go/extkeys v1.1.2 // 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-20230803113401-9a7ef94d120e // indirect
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230801152407-8101ff87ee0a // indirect
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230801140722-0a4e68d0b8f5 // indirect
|
||||
go.uber.org/dig v1.17.0 // indirect
|
||||
go.uber.org/fx v1.19.2 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
|
||||
|
||||
16
go.sum
16
go.sum
@ -1554,14 +1554,14 @@ github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0
|
||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
|
||||
github.com/waku-org/go-noise v0.0.4 h1:ZfQDcCw8pazm89EBl5SXY7GGAnzDQb9AHFXlw3Ktbvk=
|
||||
github.com/waku-org/go-noise v0.0.4/go.mod h1:+PWRfs2eSOVwKrPcQlfhwDngSh3faL/1QoxvoqggEKc=
|
||||
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.13-0.20230803113701-ea89e5d7eedb h1:f1UbFvroZbAul1HTlzM4ZGgjQ3mtn0bW8Jvk7XZQ5V4=
|
||||
github.com/waku-org/go-zerokit-rln v0.1.13-0.20230803113701-ea89e5d7eedb/go.mod h1:1S6g1KXC45HkDXhIWD9+mdAs9fdyzQy8gtmw4RLjVcM=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230803113401-9a7ef94d120e h1:Ad0rJod5F1FuYCJ8SUB/bQZsQwirNHQRE0IcaVloxZo=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230803113401-9a7ef94d120e/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230801152407-8101ff87ee0a h1:10cre+P76QvnLeyeCVAM8WDbUCri/y5xY3LtwI9Y5DE=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230801152407-8101ff87ee0a/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230801140722-0a4e68d0b8f5 h1:GseAHwGMixJ2zlY1kFYr3z1Ts0dREIYbgW4yIji9Ksw=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230801140722-0a4e68d0b8f5/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
|
||||
github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
|
||||
|
||||
@ -102,7 +102,7 @@ type WakuNodeParameters struct {
|
||||
rlnETHClientAddress string
|
||||
keystorePath string
|
||||
keystorePassword string
|
||||
keystoreIndex int
|
||||
keystoreIndex uint
|
||||
rlnMembershipContractAddress common.Address
|
||||
rlnRegistrationHandler func(tx *types.Transaction)
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ func WithStaticRLNRelay(pubsubTopic string, contentTopic string, memberIndex r.M
|
||||
|
||||
// WithDynamicRLNRelay enables the Waku V2 RLN protocol in onchain mode.
|
||||
// Requires the `gowaku_rln` build constrain (or the env variable RLN=true if building go-waku)
|
||||
func WithDynamicRLNRelay(pubsubTopic string, contentTopic string, keystorePath string, keystorePassword string, keystoreIndex int, membershipContract common.Address, membershipGroupIndex uint, spamHandler rln.SpamHandler, ethClientAddress string, ethPrivateKey *ecdsa.PrivateKey, registrationHandler rln.RegistrationHandler) WakuNodeOption {
|
||||
func WithDynamicRLNRelay(pubsubTopic string, contentTopic string, keystorePath string, keystorePassword string, keystoreIndex uint, membershipContract common.Address, membershipGroupIndex uint, spamHandler rln.SpamHandler, ethClientAddress string, ethPrivateKey *ecdsa.PrivateKey, registrationHandler rln.RegistrationHandler) WakuNodeOption {
|
||||
return func(params *WakuNodeParameters) error {
|
||||
params.enableRLN = true
|
||||
params.rlnRelayDynamic = true
|
||||
|
||||
@ -56,7 +56,7 @@ type DynamicGroupManager struct {
|
||||
saveKeystore bool
|
||||
keystorePath string
|
||||
keystorePassword string
|
||||
keystoreIndex int
|
||||
keystoreIndex uint
|
||||
|
||||
rootTracker *group_manager.MerkleRootTracker
|
||||
}
|
||||
@ -106,7 +106,7 @@ func NewDynamicGroupManager(
|
||||
membershipGroupIndex uint,
|
||||
keystorePath string,
|
||||
keystorePassword string,
|
||||
keystoreIndex int,
|
||||
keystoreIndex uint,
|
||||
saveKeystore bool,
|
||||
registrationHandler RegistrationHandler,
|
||||
log *zap.Logger,
|
||||
@ -199,9 +199,18 @@ func (gm *DynamicGroupManager) Start(ctx context.Context, rlnInstance *rln.RLN,
|
||||
return err
|
||||
}
|
||||
|
||||
if len(credentials) >= gm.keystoreIndex+1 {
|
||||
gm.identityCredential = &credentials[gm.keystoreIndex].IdentityCredential
|
||||
gm.membershipIndex = &credentials[gm.keystoreIndex].MembershipGroups[gm.membershipGroupIndex].TreeIndex
|
||||
if len(credentials) != 0 {
|
||||
if int(gm.keystoreIndex) <= len(credentials)-1 {
|
||||
credential := credentials[gm.keystoreIndex]
|
||||
gm.identityCredential = &credential.IdentityCredential
|
||||
if int(gm.membershipGroupIndex) <= len(credential.MembershipGroups)-1 {
|
||||
gm.membershipIndex = &credential.MembershipGroups[gm.membershipGroupIndex].TreeIndex
|
||||
} else {
|
||||
return errors.New("invalid membership group index")
|
||||
}
|
||||
} else {
|
||||
return errors.New("invalid keystore index")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user