@@ -11,9 +11,11 @@ import
1111 confutils/ std/ net,
1212 confutils/ toml/ defs as confTomlDefs,
1313 confutils/ toml/ std/ net as confTomlNet,
14+ libp2p/ crypto/ curve25519,
1415 libp2p/ crypto/ crypto,
1516 libp2p/ crypto/ secp,
1617 libp2p/ multiaddress,
18+ libp2p/ multicodec,
1719 nimcrypto/ utils,
1820 secp256k1,
1921 json
2628 node/ peer_manager,
2729 waku_core/ topics/ pubsub_topic,
2830 waku_core/ message/ default_values,
31+ waku_mix,
2932 ],
3033 ../../ tools/ rln_keystore_generator/ rln_keystore_generator
3134
@@ -615,6 +618,12 @@ with the drawback of consuming some more bandwidth.""",
615618 name : " mixkey"
616619 .}: Option [string ]
617620
621+ mixnodes* {.
622+ desc :
623+ " Multiaddress and mix-key of mix node to be statically specified in format multiaddr:mixPubKey. Argument may be repeated." ,
624+ name : " mixnode"
625+ .}: seq [MixNodePubInfo ]
626+
618627 # # websocket config
619628 websocketSupport* {.
620629 desc : " Enable websocket: true|false" ,
@@ -694,6 +703,22 @@ proc isNumber(x: string): bool =
694703 except ValueError :
695704 result = false
696705
706+ proc parseCmdArg * (T: type MixNodePubInfo , p: string ): T =
707+ let elements = p.split (" :" )
708+ if elements.len != 2 :
709+ raise newException (
710+ ValueError , " Invalid format for mix node expected multiaddr:mixPublicKey"
711+ )
712+ let multiaddr = MultiAddress .init (elements[0 ]).valueOr:
713+ raise newException (ValueError , " Invalid multiaddress format" )
714+ if not multiaddr.contains (multiCodec (" ip4" )).get ():
715+ raise newException (
716+ ValueError , " Invalid format for ip address, expected a ipv4 multiaddress"
717+ )
718+ return MixNodePubInfo (
719+ multiaddr: elements[0 ], pubKey: intoCurve25519Key (ncrutils.fromHex (elements[1 ]))
720+ )
721+
697722proc parseCmdArg * (T: type ProtectedShard , p: string ): T =
698723 let elements = p.split (" :" )
699724 if elements.len != 2 :
@@ -778,6 +803,22 @@ proc readValue*(
778803 except CatchableError :
779804 raise newException (SerializationError , getCurrentExceptionMsg ())
780805
806+ proc readValue * (
807+ r: var TomlReader , value: var MixNodePubInfo
808+ ) {.raises : [SerializationError ].} =
809+ try :
810+ value = parseCmdArg (MixNodePubInfo , r.readValue (string ))
811+ except CatchableError :
812+ raise newException (SerializationError , getCurrentExceptionMsg ())
813+
814+ proc readValue * (
815+ r: var EnvvarReader , value: var MixNodePubInfo
816+ ) {.raises : [SerializationError ].} =
817+ try :
818+ value = parseCmdArg (MixNodePubInfo , r.readValue (string ))
819+ except CatchableError :
820+ raise newException (SerializationError , getCurrentExceptionMsg ())
821+
781822proc readValue * (
782823 r: var TomlReader , value: var ProtectedShard
783824) {.raises : [SerializationError ].} =
@@ -972,6 +1013,7 @@ proc toWakuConf*(n: WakuNodeConf): ConfResult[WakuConf] =
9721013 b.storeServiceConf.storeSyncConf.withRelayJitterSec (n.storeSyncRelayJitter)
9731014
9741015 b.mixConf.withEnabled (n.mix)
1016+ b.mixConf.withMixNodes (n.mixnodes)
9751017 b.withMix (n.mix)
9761018 if n.mixkey.isSome ():
9771019 b.mixConf.withMixKey (n.mixkey.get ())
0 commit comments