blob: 90eb563b2f45e35d6c8a6ffae6b7dbdcd9738c9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/- 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)
::
++ validate-pubkey |= pubkey=@ux ^- ?
=/ tap (scow:sr %ux pubkey)
.= (lent tap) 64
::
++ diff-filters
|= [a=filter:sur b=filter:sur] ^- filter:sur
=/ ids (unit-set-dif ids.a ids.b)
=/ authors (unit-set-dif authors.a authors.b)
=/ kinds (unit-set-dif kinds.a kinds.b)
=/ tags ~
=/ since ~
=/ until ~
=/ limit ~ :: TODO
[ids authors kinds tags since until limit]
++ unit-set-dif
|* [a=(unit) b=(unit)]
%^ clap a b |* [x=(set) y=(set)] (~(dif in x) y)
--
|