diff --git a/src/chat/chat_channel.c b/src/chat/chat_channel.c index 116fc010f..d3decd2c4 100644 --- a/src/chat/chat_channel.c +++ b/src/chat/chat_channel.c @@ -131,7 +131,7 @@ int chat_core_create_channel(struct UTUN_INSTANCE* inst, const struct chat_chann bytes = member_sync_build_join_msg(req->x25519_pubkey, req->ed25519_pubkey, inst->node_id, inst->my_keys.public_key, timestamp, body, sizeof(body)); if (bytes < 0 || sc_ed25519_sign(inst->my_ed25519_privkey, body, (size_t)bytes, join) != SC_OK || - member_sync_sign_pubkey(req->ed25519_privkey, inst->my_keys.public_key, root) < 0) { + member_sync_sign_join(req->ed25519_privkey, join, root) < 0) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "channel create: root JOIN/invitation signing failed ch=%s", req->channel_id); return -1; } if (chat_core_name_userinfo(inst->name, profile, sizeof(profile))) return -1; diff --git a/src/chat/chat_join.c b/src/chat/chat_join.c index eb0a0635e..7dd14d0da 100644 --- a/src/chat/chat_join.c +++ b/src/chat/chat_join.c @@ -218,7 +218,7 @@ int chat_join_process_request(struct UTUN_INSTANCE* inst, uint64_t group_id, /* 3. добавить мембера + подписать его pubkey (дерево приглашений) */ uint8_t tree_sig[64]; - if (member_sync_sign_pubkey(inst->my_ed25519_privkey, m.x25519, tree_sig) != 0) { + if (member_sync_sign_join(inst->my_ed25519_privkey, m.join_sig, tree_sig) != 0) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: process_request sign_pubkey FAILED nid=0x%016llx", CJ_ID, (unsigned long long)m.node_id); return CHAT_CONNECT_ERROR; } diff --git a/src/chat/group_policy.c b/src/chat/group_policy.c index 98a7699ae..820732c4b 100644 --- a/src/chat/group_policy.c +++ b/src/chat/group_policy.c @@ -108,7 +108,7 @@ int group_policy_apply(sqlite3* db, const char* channel, const struct group_poli struct gp_member { uint64_t node, signer; - uint8_t x[32], ed[32], valid, admin, previous, allowed, keep; + uint8_t x[32], ed[32], join[64], valid, admin, previous, allowed, keep; size_t child, sibling; /* Индексы + 1, 0 — конец списка детей. */ char name[128]; }; @@ -150,6 +150,7 @@ static int gp_load(struct UTUN_INSTANCE* inst, const char* ch, struct gp_member* if (!m.x25519 || !m.ed25519 || !m.join_sig || !m.signature) { rc = SQLITE_NOMEM; goto done; } memcpy(p->x, m.x25519, 32); memcpy(p->ed, m.ed25519, 32); + memcpy(p->join, m.join_sig, 64); int verified = member_sync_verify_local_record(db, ch, &m); if (verified < 0) goto done; int tree = member_sync_verify_signature(db, ch, &m); @@ -313,7 +314,7 @@ int group_policy_command(struct UTUN_INSTANCE* inst, const char* channel, int al transaction = 1; for (size_t i = 0; i < count; i++) if (m[i].keep && m[i].signer) { uint8_t signature[64]; - if (member_sync_sign_pubkey(key, m[i].x, signature) || + if (member_sync_sign_join(key, m[i].join, signature) || member_sync_put(inst, channel, m[i].node, m[i].x, m[i].ed, NULL, 0, NULL, 0, NULL, NULL, NULL, 0, 0, signature) < 0) goto done; } if (policy.version == INT64_MAX) { error = "version_exhausted"; goto done; }