v0.1.18 - Fixed template-role pubkey caching: re-derive on each concrete path request (nostr_range wildcard was returning the same key for all account indices)

This commit is contained in:
Laan Tungir
2026-08-06 08:00:25 -04:00
parent 75dddac223
commit 32151b3ffd
2 changed files with 13 additions and 6 deletions
+2 -2
View File
@@ -813,8 +813,8 @@ int socket_name_random(char *out, size_t out_len);
/* Version information (auto-updated by build/version tooling) */
#define NSIGNER_VERSION_MAJOR 0
#define NSIGNER_VERSION_MINOR 1
#define NSIGNER_VERSION_PATCH 17
#define NSIGNER_VERSION "v0.1.17"
#define NSIGNER_VERSION_PATCH 18
#define NSIGNER_VERSION "v0.1.18"
/* NSIGNER_HEADERLESS_DECLS_END */
+11 -4
View File
@@ -2443,12 +2443,19 @@ int server_handle_one(server_ctx_t *ctx, server_activity_cb cb, void *cb_data) {
if (selector_req.has_role_path) {
/* Case (a): client supplied a concrete path that was already
* validated by selector_resolve. Use it directly. */
* validated by selector_resolve. Use it directly.
*
* Always re-derive for template roles: the client may request
* a different concrete path (e.g. a different account index)
* than the one previously derived and cached on the role.
* The derivation block below swaps in the concrete path,
* clears derived/pubkey, re-derives, and restores the
* template — so forcing pending_derivation here is safe and
* correct. Without this, a second request with a different
* path would return the stale cached pubkey from the first. */
snprintf(concrete_path, sizeof(concrete_path),
"%s", selector_req.role_path);
if (!role->derived) {
pending_derivation = 1;
}
pending_derivation = 1;
} else {
/* Case (b): role only — resolve index from --index or default */
int chosen_index;