5.3 KiB
Plan: Legacy Verb Aliases (Migration Path)
Context
n_signer is being moved to a clean, unified API (see api.md). The current implementation in src/dispatcher.c still uses the legacy unprefixed verb names. This document captures the old → new mapping so the implementation can be updated in one pass. Since this is a new project, there are no external clients to migrate — the legacy names are an internal cleanup item, not a long-term compatibility surface.
Goal
Rename the verbs in src/dispatcher.c to match api.md, remove the legacy aliases, and delete the alias-routing logic. No backward-compatibility shim is needed.
Old → New Verb Mapping
Nostr protocol verbs (add nostr_ prefix)
| Legacy verb | New verb |
|---|---|
sign_event |
nostr_sign_event |
mine_event |
nostr_mine_event |
nip04_encrypt |
nostr_nip04_encrypt |
nip04_decrypt |
nostr_nip04_decrypt |
nip44_encrypt |
nostr_nip44_encrypt |
nip44_decrypt |
nostr_nip44_decrypt |
The role-based get_public_key (with nostr_index/role/role_path selector) becomes nostr_get_public_key. The algorithm-based get_public_key (with algorithm option) stays get_public_key.
Algorithm-based verb aliases (collapse into canonical names)
| Legacy verb | Canonical verb | Default algorithm (when algorithm omitted) |
|---|---|---|
sign_data |
sign |
(from role) |
ssh_sign |
sign |
ed25519 |
verify_signature |
verify |
(from role) |
kem_encapsulate |
encapsulate |
ml-kem-768 |
kem_decapsulate |
decapsulate |
ml-kem-768 |
After the rename, callers must always supply algorithm explicitly — the "default algorithm" fallbacks are removed. This makes the algorithm-based verbs uniform: every call specifies its algorithm.
OTP verb aliases (collapse into encrypt/decrypt)
| Legacy verb | Canonical verb | Required option |
|---|---|---|
otp_encrypt |
encrypt |
{"algorithm":"otp"} |
otp_decrypt |
decrypt |
{"algorithm":"otp"} |
The general encrypt/decrypt with curve:"otp" routing is replaced by algorithm:"otp".
Implementation Steps
-
src/dispatcher.c— rename theVERB_*string constants:VERB_SIGN_EVENT→"nostr_sign_event"VERB_MINE_EVENT→"nostr_mine_event"VERB_NIP04_ENCRYPT→"nostr_nip04_encrypt"VERB_NIP04_DECRYPT→"nostr_nip04_decrypt"VERB_NIP44_ENCRYPT→"nostr_nip44_encrypt"VERB_NIP44_DECRYPT→"nostr_nip44_decrypt"- Add
VERB_NOSTR_GET_PUBLIC_KEY="nostr_get_public_key"; split the currentget_public_keyhandler into two branches based on whetheralgorithmis present (algorithm-based) ornostr_index/role/role_pathis present (Nostr).
-
Remove alias routing — delete
is_algorithm_verb(),canonical_alg_verb(), and the alias-fallthrough logic indispatcher_handle_request(). The verbssign_data,ssh_sign,verify_signature,kem_encapsulate,kem_decapsulate,otp_encrypt,otp_decryptare no longer recognized. -
Remove
curve:"otp"routing — theencrypt/decrypthandler no longer special-casescurve:"otp"; OTP is selected viaalgorithm:"otp"like every other algorithm. -
Update tests —
tests/test_dispatcher.c,tests/test_integration.c,tests/test_algorithm_api.c, and any other test that uses the legacy verb names. Rename all call sites to the new verbs and addalgorithmexplicitly where it was previously defaulted. -
Update examples and clients:
client/demo_c99.cclient/demo_javascript.jsclient/demo_python.pyexamples/— all example files using legacy verb namesREADME.md— the §5 summary and any inline examples
-
Update policy/preapprove —
src/policy.cand the--preapproveCLI parsing insrc/main.cshould accept the new verb names. The role-based preapprove examples inapi.md§6 already use thenostr_prefix.
Verification
make dev && ./build/nsigner --versionbuilds clean.make test— all tests pass with the new verb names.- Manual smoke test over HTTP: each verb in
api.md§3 responds as documented. grep -rn "sign_event\|mine_event\|nip04_\|nip44_\|sign_data\|ssh_sign\|verify_signature\|kem_encapsulate\|kem_decapsulate\|otp_encrypt\|otp_decrypt" src/ tests/ client/ examples/returns no matches (all legacy names gone).