Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Dagur Valberg Johannsson
9ff77584fe
Add uri to relay private key generation
Making private key deterministic allows for easy session restoration
2026-03-09 16:03:21 +01:00
6 changed files with 13 additions and 9 deletions

View file

@ -50,9 +50,11 @@ test-integration:
publish: publish:
extends: .node-common extends: .node-common
# npm trusted publishing via GitLab OIDC — no NPM_TOKEN needed. # npm trusted publishing via GitLab OIDC — requires instance runner for OIDC support.
# Each @wizardconnect/* package must be linked to this GitLab project # Each @wizardconnect/* package must be linked to this GitLab project
# on npmjs.com: package Settings > Publishing access > Trusted publishers. # on npmjs.com: package Settings > Publishing access > Trusted publishers.
tags:
- saas-linux-small-amd64 # force gitlab instance runner
id_tokens: id_tokens:
SIGSTORE_ID_TOKEN: SIGSTORE_ID_TOKEN:
aud: sigstore aud: sigstore
@ -85,6 +87,8 @@ pages:
force-publish: force-publish:
extends: .node-common extends: .node-common
tags:
- saas-linux-small-amd64 # force gitlab instance runners
id_tokens: id_tokens:
SIGSTORE_ID_TOKEN: SIGSTORE_ID_TOKEN:
aud: sigstore aud: sigstore

View file

@ -37,7 +37,7 @@ async function buildAdapter(
walletName: "wiz-test CLI wallet", walletName: "wiz-test CLI wallet",
walletIcon: "", walletIcon: "",
getRelayPrivateKey(): Uint8Array { getRelayPrivateKey(_uri: string): Uint8Array {
return relayPrivateKey; return relayPrivateKey;
}, },

View file

@ -65,7 +65,7 @@ export function makeTestAdapter(seed?: Uint8Array): WalletAdapter {
walletName: "Test Wallet", walletName: "Test Wallet",
walletIcon: "", walletIcon: "",
getRelayPrivateKey(): Uint8Array { getRelayPrivateKey(_uri: string): Uint8Array {
return hdMaster.privateKey; return hdMaster.privateKey;
}, },

View file

@ -19,12 +19,12 @@ export interface WalletAdapter {
walletIcon: string; walletIcon: string;
/** /**
* Return the relay identity private key for this session. * Return the relay identity private key for a given connection URI.
* May be ephemeral (random per session) or stable (HD-derived) — both work. * Should be deterministic per URI so that reconnecting to the same URI
* The dapp learns the wallet's public key dynamically via wallet_ready * produces the same Nostr identity (relay recognizes the wallet after reload).
* so stability across restarts is not required. * Different URIs should yield different keys for privacy (dapps can't correlate).
*/ */
getRelayPrivateKey(): Uint8Array; getRelayPrivateKey(uri: string): Uint8Array;
/** /**
* Derive the compressed public key (33 bytes) for a given HD path and index. * Derive the compressed public key (33 bytes) for a given HD path and index.

View file

@ -161,7 +161,7 @@ export class WalletConnectionManager extends EventEmitter<WalletConnectionManage
const result = initiateWalletRelay(statusCallback, { const result = initiateWalletRelay(statusCallback, {
uri, uri,
walletPrivateKey: this.adapter.getRelayPrivateKey(), walletPrivateKey: this.adapter.getRelayPrivateKey(uri),
}); });
conn.cleanup = result.cleanup; conn.cleanup = result.cleanup;