Centralize hexToUint8Array and other privkey-handling helpers #43

Open
opened 2026-05-05 18:13:00 +00:00 by padreug · 0 comments
Owner

hexToUint8Array is currently duplicated inline in at least two composables (src/modules/activities/composables/useRSVP.ts and src/modules/base/nostr/ReactionService.ts). Once a third caller emerges, promote it to a shared module — src/lib/crypto/ already exists and is the natural home.

Scope:

  • Move hexToUint8Array (and its inverse if any caller needs it) to src/lib/crypto/hex.ts.
  • Audit other privkey-touching code paths for similar inline helpers (e.g. validation that a privkey is non-empty before signing, byte-length checks, etc.) and consolidate.
  • Update docs/nostr-patterns/publishing.md § "Sign with nostr-tools.finalizeEvent, take privkey as bytes" to point at the new location.

Non-goals:

  • Changing the auth flow or where the privkey is stored.
  • Adding NIP-49 / NIP-46 alternative signing paths — those are separate issues and should branch the signing call site, not the hex helper.

Trigger condition: do this when a third call site appears, or sooner if any of the existing call sites need to handle a non-hex input (e.g. NIP-49 ciphertext, NIP-46 remote signer).

`hexToUint8Array` is currently duplicated inline in at least two composables (`src/modules/activities/composables/useRSVP.ts` and `src/modules/base/nostr/ReactionService.ts`). Once a third caller emerges, promote it to a shared module — `src/lib/crypto/` already exists and is the natural home. Scope: - Move `hexToUint8Array` (and its inverse if any caller needs it) to `src/lib/crypto/hex.ts`. - Audit other privkey-touching code paths for similar inline helpers (e.g. validation that a privkey is non-empty before signing, byte-length checks, etc.) and consolidate. - Update `docs/nostr-patterns/publishing.md` § "Sign with `nostr-tools.finalizeEvent`, take privkey as bytes" to point at the new location. Non-goals: - Changing the auth flow or where the privkey is stored. - Adding NIP-49 / NIP-46 alternative signing paths — those are separate issues and should branch the signing call site, not the hex helper. Trigger condition: do this when a third call site appears, or sooner if any of the existing call sites need to handle a non-hex input (e.g. NIP-49 ciphertext, NIP-46 remote signer).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/webapp#43
No description provided.