diff options
author | polwex <polwex@sortug.com> | 2025-09-17 12:24:41 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-09-17 12:24:41 +0700 |
commit | 387af8fc1603805b02ce03f8adba4fa73a954f7c (patch) | |
tree | 6ac4fe9c33a14d9da418a97955a38efb9338d869 /backupdesk/lib/nostr.hoon | |
parent | 31a47ce72255bb56920e417d250541b04be82648 (diff) |
relay much more robust
Diffstat (limited to 'backupdesk/lib/nostr.hoon')
-rw-r--r-- | backupdesk/lib/nostr.hoon | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/backupdesk/lib/nostr.hoon b/backupdesk/lib/nostr.hoon new file mode 100644 index 0000000..7cb719b --- /dev/null +++ b/backupdesk/lib/nostr.hoon @@ -0,0 +1,31 @@ +/- sur=nostr +/+ js=json-nostr, sr=sortug +|% +++ gen-sub-id |= eny=@ ^- @t + %- crip (scag 60 (scow:sr %uw eny)) +++ gen-keys |= eny=@ ^- keys:sur + =, secp256k1:secp:crypto + =/ privkey + |- + =/ k (~(rad og eny) (bex 256)) + ?. (lth k n.t) $ k + + =/ pubkey (priv-to-pub privkey) + =/ pub (compress-point pubkey) + :: =/ pub (serialize-point pubkey) + [pub=pub priv=privkey] +:: +++ hash-event |= raw=raw-event:sur ^- @ux + =/ jon (raw-event:en:js raw) + =/ jstring (en:json:html jon) + (swp 3 (shax jstring)) + +++ raws + |= [eny=@ bits=@] + ^- [@ @] + [- +>-]:(~(raws og eny) bits) + +++ sign-event |= [priv=@ux hash=@ux eny=@] + =^ sed eny (raws eny 256) + (sign:schnorr:secp256k1:secp:crypto priv hash sed) +-- |