From 0549cfd01f1feed9c313a84a3884328d08887caf Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 18 Sep 2025 05:08:24 +0700 Subject: nostr keys as annoying as usual, but this works reliably --- desk/lib/json/nostr.hoon | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'desk/lib') diff --git a/desk/lib/json/nostr.hoon b/desk/lib/json/nostr.hoon index 6f93c1c..cb10c1d 100644 --- a/desk/lib/json/nostr.hoon +++ b/desk/lib/json/nostr.hoon @@ -22,11 +22,12 @@ ~ == ++ req |= =req:shim:sur ^- json + =/ en-ev event :- %a :- s+(crip (cuss (trip -.req))) ?- -.req %req (enreq +.req) - %event :_ ~ (event +.req) - %auth :_ ~ (event +.req) + %event :_ ~ (en-ev(nostr .y) +.req) + %auth :_ ~ (en-ev(nostr .y) +.req) %close :_ ~ [%s +.req] == ++ enreq @@ -38,11 +39,12 @@ :: ++ raw-event |= raw-event:sur :: WTF nostr doesn't want the prefix on the pubkey - =/ scw scow:sr - =/ pubkeyt (scw(min-chars 64) %ux pubkey) + :: =/ scw scow:sr + :: =/ pubkeyt (scw(min-chars 64) %ux pubkey) + =/ pubkeyt (scow:sr %ux pubkey) ?~ pubkeyt !! - :: =/ pubkeyj [%s (crip t.pubkeyt)] - =/ pubkeyj [%s (crip pubkeyt)] + =/ pubkeyj [%s (crip t.pubkeyt)] + :: =/ pubkeyj [%s (crip pubkeyt)] :- %a :~ [%n '0'] pubkeyj @@ -52,14 +54,16 @@ s+content == ++ event + =/ nostr=? .n |= e=event:sur ^- json - :: =/ pubkeyt (scow:sr %ux pubkey.e) - :: ?~ pubkeyt !! - :: =/ pubkeyj [%s (crip t.pubkeyt)] + =/ pubkey ?. nostr + (hex:en:common pubkey.e) + =/ pubkeyt (scow:sr %ux pubkey.e) + ?~ pubkeyt !! + [%s (crip t.pubkeyt)] %: pairs id+(hex:en:common id.e) - pubkey+(hex:en:common pubkey.e) - :: pubkey+pubkeyj + pubkey+pubkey sig+(hex:en:common sig.e) ['created_at' (numb created-at.e)] kind+(numb kind.e) -- cgit v1.2.3