mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-07-06 16:39:34 +00:00
feat(chat): consume RLN membership spec wire format on chat-side gifter
Updates the chat-side gifter caller in waku_client.nim to the new MembershipAllocationRequest / MembershipAllocationSuccess types: * identity commitment is sent as bytes (not hex string) * authentication_type='eth-allowlist' is set explicitly when signing * rate limit is passed as proto3 optional * configAccountId is read off success.configAccountId (the LEZ extension) Bumps vendor/nwaku and vendor/logos-lez-rln to pull in the spec-aligned wire format on both the gifter server and the auto-registering mix-node client paths.
This commit is contained in:
parent
34d570e3ff
commit
ce127b566a
@ -372,39 +372,48 @@ proc start*(client: WakuClient) {.async.} =
|
||||
mix_rln_interface.membershipKeyGen().valueOr:
|
||||
error "Failed to generate RLN identity", error = $error
|
||||
quit(QuitFailure)
|
||||
var idCommitmentHex = ""
|
||||
for b in idCred.idCommitment:
|
||||
idCommitmentHex.add(toHex(int(b), 2))
|
||||
let idCommitmentBytes = @(idCred.idCommitment)
|
||||
|
||||
info "Registering via RLN gifter",
|
||||
gifterPeer = client.cfg.gifterNodeAddr,
|
||||
idCommitment = idCommitmentHex[0 .. 15] & "..."
|
||||
identityCommitmentLen = idCommitmentBytes.len
|
||||
|
||||
var authPayload = none(seq[byte])
|
||||
var authType: seq[byte]
|
||||
var authPayload: seq[byte]
|
||||
if client.cfg.gifterAuthKey.len > 0:
|
||||
let seckey = eth_keys.PrivateKey.fromHex(client.cfg.gifterAuthKey).valueOr:
|
||||
error "Failed to parse gifter auth key", error = $error
|
||||
quit(QuitFailure)
|
||||
let sig = seckey.sign(rln_gifter_protocol.eip191Message(idCommitmentHex))
|
||||
authPayload = some(@(sig.toRaw()))
|
||||
let sig = seckey.sign(rln_gifter_protocol.eip191Message(idCommitmentBytes))
|
||||
authPayload = @(sig.toRaw())
|
||||
for c in rln_gifter_protocol.EthAllowlistAuthType:
|
||||
authType.add(byte(c))
|
||||
info "Signing gifter request with EIP-191 auth key",
|
||||
signer = seckey.toPublicKey().to(eth_addresses.Address).to0xHex()
|
||||
|
||||
let regRes = await gifterClient.requestMembership(
|
||||
idCommitmentHex, uint64(lezGm.userMessageLimit), gifterPeer, authPayload
|
||||
idCommitmentBytes,
|
||||
some(uint64(lezGm.userMessageLimit)),
|
||||
gifterPeer,
|
||||
authType,
|
||||
authPayload,
|
||||
)
|
||||
if regRes.isErr:
|
||||
error "Failed to register via gifter", error = regRes.error
|
||||
quit(QuitFailure)
|
||||
let regResult = regRes.get()
|
||||
let success = regRes.get()
|
||||
|
||||
let configAccountId = success.configAccountId.valueOr:
|
||||
error "Gifter response missing configAccountId extension"
|
||||
quit(QuitFailure)
|
||||
|
||||
lezGm.credentials = some(idCred)
|
||||
lezGm.membershipIndex = some(onchain_group_manager.MembershipIndex(regResult.leafIndex))
|
||||
mix_lez_client.setRlnConfig(regResult.configAccountId, regResult.leafIndex.int)
|
||||
lezGm.membershipIndex = some(onchain_group_manager.MembershipIndex(success.leafIndex))
|
||||
mix_lez_client.setRlnConfig(configAccountId, success.leafIndex.int)
|
||||
|
||||
info "Registered via RLN gifter",
|
||||
leafIndex = regResult.leafIndex,
|
||||
configAccount = regResult.configAccountId
|
||||
leafIndex = success.leafIndex,
|
||||
configAccount = configAccountId
|
||||
|
||||
asyncSpawn taskKeepAlive(client)
|
||||
|
||||
|
||||
2
vendor/logos-lez-rln
vendored
2
vendor/logos-lez-rln
vendored
@ -1 +1 @@
|
||||
Subproject commit 5f893fd4b99411ee880b99f3953b0ea32b765a9d
|
||||
Subproject commit 99ecf6b6a355e13bd857501009f98f5842057249
|
||||
2
vendor/nwaku
vendored
2
vendor/nwaku
vendored
@ -1 +1 @@
|
||||
Subproject commit 41d73f92eb4e7810f830d18e8634d72759472936
|
||||
Subproject commit ba1ce0280fc9dc3e84fc630d4680302e942942d0
|
||||
Loading…
x
Reference in New Issue
Block a user