1 package kind
2 3 // Musiquay kind block.
4 //
5 // The block is described in docs/ARCHITECTURE.md of the musiquay specification.
6 // Addressable kinds occupy 32210-32217; the regular (immutable) kinds are 3221,
7 // 3222, 3223, 3224, 32218, 32219, and 32220. Kind 22243 is ephemeral and lives
8 // outside the block. All of these values were checked against the Nostr
9 // registry of kinds for collisions before adoption.
10 //
11 // Do not renumber: the values are on the wire and are referenced by the
12 // specification documents, the acceptance tests, and the relay policy.
13 var (
14 // PlayReport is a regular kind carrying an auditable play report. It is
15 // certified with a BDHKE blind signature and a NUT-12 DLEQ proof, so the
16 // host never learns which listener a certified play belongs to.
17 PlayReport = &K{3221}
18 // PurchaseOrder is a regular kind carrying a private purchase order. It is
19 // only ever transported inside a NIP-59 gift wrap; the relay sees 1059.
20 PurchaseOrder = &K{3222}
21 // EntitlementDeed is a regular kind carrying an owner-signed entitlement
22 // deed. The deed is a signed event inside the NIP-59 seal (not a rumor) so
23 // that a host which is not the recipient can verify it.
24 EntitlementDeed = &K{3223}
25 // AssetIdentity is a regular kind carrying the signed record that maps a
26 // stable asset id to the current addressable coordinate. It is keyed by a
27 // regular "d" tag holding the asset id so hosts can query it by address.
28 AssetIdentity = &K{3224}
29 30 // Track is the addressable kind for a recording. Every published encoding
31 // of the recording hangs off one track event as a Blossom blob.
32 Track = &K{32210}
33 // Album is the addressable kind for a release.
34 Album = &K{32211}
35 // Playlist is the addressable kind for an ordered list of track references.
36 Playlist = &K{32212}
37 // Setlist is the addressable kind for a per-artist song list for an event.
38 Setlist = &K{32213}
39 // ReleaseCredits is the addressable kind for structured release credits.
40 ReleaseCredits = &K{32214}
41 // TrackCredits is the addressable kind for per-track credit overrides.
42 TrackCredits = &K{32215}
43 // Edition is the addressable kind for a format-specific release edition.
44 Edition = &K{32216}
45 // AccessFilter is the addressable kind for an access filter event. It points
46 // at a Blossom blob holding the exact Golomb-coded membership set.
47 AccessFilter = &K{32217}
48 49 // DeliveryReceipt is a regular kind carrying a private host-signed delivery
50 // receipt. Like the purchase order it is only transported inside a NIP-59
51 // gift wrap.
52 DeliveryReceipt = &K{32218}
53 // HostAggregate is a regular kind carrying a host's public aggregate totals
54 // for one asset and one period.
55 HostAggregate = &K{32219}
56 // PublisherRollup is a regular kind carrying a publisher's rollup over
57 // surviving host aggregates.
58 PublisherRollup = &K{32220}
59 60 // DeedPresentation is an ephemeral kind carrying a buyer-signed proof of
61 // possession of a deed, bound to a deed id, the requested asset, a server,
62 // a client nonce, and a timestamp.
63 DeedPresentation = &K{22243}
64 )
65 66 // MusiquayAddressable is the set of addressable kinds in the block.
67 var MusiquayAddressable = []*K{
68 Track,
69 Album,
70 Playlist,
71 Setlist,
72 ReleaseCredits,
73 TrackCredits,
74 Edition,
75 AccessFilter,
76 }
77 78 // MusiquayRegular is the set of immutable (regular) kinds in the block.
79 var MusiquayRegular = []*K{
80 PlayReport,
81 PurchaseOrder,
82 EntitlementDeed,
83 AssetIdentity,
84 DeliveryReceipt,
85 HostAggregate,
86 PublisherRollup,
87 }
88 89 // MusiquayAll is every kind the relay must accept for musiquay, including the
90 // ephemeral presentation proof.
91 var MusiquayAll = []*K{
92 PlayReport,
93 PurchaseOrder,
94 EntitlementDeed,
95 AssetIdentity,
96 Track,
97 Album,
98 Playlist,
99 Setlist,
100 ReleaseCredits,
101 TrackCredits,
102 Edition,
103 AccessFilter,
104 DeliveryReceipt,
105 HostAggregate,
106 PublisherRollup,
107 DeedPresentation,
108 }
109 110 // MusiquayPrivate is the set of kinds that must never be published as plain
111 // events: orders, deeds, and receipts belong only inside a NIP-59 gift wrap.
112 // A public event of one of these kinds is a policy violation.
113 var MusiquayPrivate = []*K{
114 PurchaseOrder,
115 EntitlementDeed,
116 DeliveryReceipt,
117 }
118 119 // musiquayAllSet is the lookup form of MusiquayAll, built once at init.
120 var musiquayAllSet = func() (m map[uint16]bool) {
121 m = make(map[uint16]bool, len(MusiquayAll))
122 for _, k := range MusiquayAll {
123 m[k.ToU16()] = true
124 }
125 return
126 }()
127 128 // IsMusiquay reports whether a kind number belongs to the musiquay block.
129 func IsMusiquay(k uint16) bool { return musiquayAllSet[k] }
130 131 // IsMusiquayPrivate reports whether a kind must only travel inside a gift wrap.
132 func IsMusiquayPrivate(k uint16) bool {
133 for _, p := range MusiquayPrivate {
134 if p.ToU16() == k {
135 return true
136 }
137 }
138 return false
139 }
140 141 // IsMusiquayAddressable reports whether a kind is addressable in the block.
142 func IsMusiquayAddressable(k uint16) bool {
143 for _, a := range MusiquayAddressable {
144 if a.ToU16() == k {
145 return true
146 }
147 }
148 return false
149 }
150