@bcts/tags 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +48 -0
- package/README.md +11 -0
- package/dist/index.cjs +273 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +96 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +96 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.iife.js +276 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.mjs +197 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +74 -0
- package/src/index.ts +13 -0
- package/src/tags-registry.ts +269 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CBOR Tags Registry
|
|
3
|
+
*
|
|
4
|
+
* This is a 1:1 port of the Rust bc-tags-rust implementation.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-006-urtypes.md
|
|
7
|
+
*
|
|
8
|
+
* As of August 13 2022, the [IANA registry of CBOR tags](https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml)
|
|
9
|
+
* has the following low-numbered values available:
|
|
10
|
+
*
|
|
11
|
+
* One byte encoding: 6-15, 19-20
|
|
12
|
+
* Two byte encoding: 48-51, 53, 55-60, 62, 88-95, 99, 102, 105-109, 113-119,
|
|
13
|
+
* 128-255
|
|
14
|
+
*
|
|
15
|
+
* Tags in the range 0-23 require "standards action" for the IANA to recognize.
|
|
16
|
+
* Tags in the range 24-32767 require a specification to reserve.
|
|
17
|
+
* Tags in the range 24-255 only require two bytes to encode.
|
|
18
|
+
* Higher numbered tags are first-come, first-served.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
type Tag,
|
|
23
|
+
createTag,
|
|
24
|
+
type TagsStore,
|
|
25
|
+
getGlobalTagsStore,
|
|
26
|
+
registerTagsIn as registerDcborTagsIn,
|
|
27
|
+
} from "@bcts/dcbor";
|
|
28
|
+
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Standard IANA Tags (re-used from dcbor but defined here for completeness)
|
|
31
|
+
// ============================================================================
|
|
32
|
+
|
|
33
|
+
export const URI: Tag = createTag(32, "url");
|
|
34
|
+
export const UUID: Tag = createTag(37, "uuid");
|
|
35
|
+
|
|
36
|
+
// A previous version of the Envelope spec used tag #6.24 ("Encoded CBOR Item")
|
|
37
|
+
// as the header for the Envelope `leaf` case. Unfortunately, this was not a
|
|
38
|
+
// correct use of the tag, as the contents of #6.24 (RFC8949 §3.4.5.1) MUST
|
|
39
|
+
// always be a byte string, while we were simply using it as a wrapper/header
|
|
40
|
+
// for any dCBOR data item.
|
|
41
|
+
//
|
|
42
|
+
// https://www.rfc-editor.org/rfc/rfc8949.html#name-encoded-cbor-data-item
|
|
43
|
+
//
|
|
44
|
+
// The new leaf tag is #6.201, but we will still recognize #6.24 for backwards
|
|
45
|
+
// compatibility.
|
|
46
|
+
|
|
47
|
+
// The only two tags that Blockchain Commons has registered in the
|
|
48
|
+
// "Specification Required" range are the two tags for "Gordian Envelope"
|
|
49
|
+
// (#6.200) and "dCBOR/Envelope Leaf" (#6.201).
|
|
50
|
+
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Core Envelope tags.
|
|
53
|
+
// ============================================================================
|
|
54
|
+
|
|
55
|
+
export const ENCODED_CBOR: Tag = createTag(24, "encoded-cbor");
|
|
56
|
+
export const ENVELOPE: Tag = createTag(200, "envelope");
|
|
57
|
+
export const LEAF: Tag = createTag(201, "leaf"); // dCBOR data item
|
|
58
|
+
export const JSON: Tag = createTag(262, "json"); // bstr containing UTF-8 JSON text
|
|
59
|
+
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// Envelope extension tags
|
|
62
|
+
// ============================================================================
|
|
63
|
+
|
|
64
|
+
export const KNOWN_VALUE: Tag = createTag(40000, "known-value");
|
|
65
|
+
export const DIGEST: Tag = createTag(40001, "digest");
|
|
66
|
+
export const ENCRYPTED: Tag = createTag(40002, "encrypted");
|
|
67
|
+
export const COMPRESSED: Tag = createTag(40003, "compressed");
|
|
68
|
+
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Tags for subtypes specific to Distributed Function Calls.
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
73
|
+
export const REQUEST: Tag = createTag(40004, "request");
|
|
74
|
+
export const RESPONSE: Tag = createTag(40005, "response");
|
|
75
|
+
export const FUNCTION: Tag = createTag(40006, "function");
|
|
76
|
+
export const PARAMETER: Tag = createTag(40007, "parameter");
|
|
77
|
+
export const PLACEHOLDER: Tag = createTag(40008, "placeholder");
|
|
78
|
+
export const REPLACEMENT: Tag = createTag(40009, "replacement");
|
|
79
|
+
|
|
80
|
+
export const X25519_PRIVATE_KEY: Tag = createTag(40010, "agreement-private-key");
|
|
81
|
+
export const X25519_PUBLIC_KEY: Tag = createTag(40011, "agreement-public-key");
|
|
82
|
+
export const ARID: Tag = createTag(40012, "arid");
|
|
83
|
+
export const PRIVATE_KEYS: Tag = createTag(40013, "crypto-prvkeys");
|
|
84
|
+
export const NONCE: Tag = createTag(40014, "nonce");
|
|
85
|
+
export const PASSWORD: Tag = createTag(40015, "password");
|
|
86
|
+
export const PRIVATE_KEY_BASE: Tag = createTag(40016, "crypto-prvkey-base");
|
|
87
|
+
|
|
88
|
+
export const PUBLIC_KEYS: Tag = createTag(40017, "crypto-pubkeys");
|
|
89
|
+
export const SALT: Tag = createTag(40018, "salt");
|
|
90
|
+
export const SEALED_MESSAGE: Tag = createTag(40019, "crypto-sealed");
|
|
91
|
+
export const SIGNATURE: Tag = createTag(40020, "signature");
|
|
92
|
+
export const SIGNING_PRIVATE_KEY: Tag = createTag(40021, "signing-private-key");
|
|
93
|
+
export const SIGNING_PUBLIC_KEY: Tag = createTag(40022, "signing-public-key");
|
|
94
|
+
export const SYMMETRIC_KEY: Tag = createTag(40023, "crypto-key");
|
|
95
|
+
export const XID: Tag = createTag(40024, "xid");
|
|
96
|
+
export const REFERENCE: Tag = createTag(40025, "reference");
|
|
97
|
+
export const EVENT: Tag = createTag(40026, "event");
|
|
98
|
+
|
|
99
|
+
export const ENCRYPTED_KEY: Tag = createTag(40027, "encrypted-key");
|
|
100
|
+
export const MLKEM_PRIVATE_KEY: Tag = createTag(40100, "mlkem-private-key");
|
|
101
|
+
export const MLKEM_PUBLIC_KEY: Tag = createTag(40101, "mlkem-public-key");
|
|
102
|
+
export const MLKEM_CIPHERTEXT: Tag = createTag(40102, "mlkem-ciphertext");
|
|
103
|
+
export const MLDSA_PRIVATE_KEY: Tag = createTag(40103, "mldsa-private-key");
|
|
104
|
+
export const MLDSA_PUBLIC_KEY: Tag = createTag(40104, "mldsa-public-key");
|
|
105
|
+
export const MLDSA_SIGNATURE: Tag = createTag(40105, "mldsa-signature");
|
|
106
|
+
export const SEED: Tag = createTag(40300, "seed");
|
|
107
|
+
export const HDKEY: Tag = createTag(40303, "hdkey");
|
|
108
|
+
export const DERIVATION_PATH: Tag = createTag(40304, "keypath");
|
|
109
|
+
|
|
110
|
+
export const USE_INFO: Tag = createTag(40305, "coin-info");
|
|
111
|
+
export const EC_KEY: Tag = createTag(40306, "eckey");
|
|
112
|
+
export const ADDRESS: Tag = createTag(40307, "address");
|
|
113
|
+
export const OUTPUT_DESCRIPTOR: Tag = createTag(40308, "output-descriptor");
|
|
114
|
+
export const SSKR_SHARE: Tag = createTag(40309, "sskr");
|
|
115
|
+
export const PSBT: Tag = createTag(40310, "psbt");
|
|
116
|
+
export const ACCOUNT_DESCRIPTOR: Tag = createTag(40311, "account-descriptor");
|
|
117
|
+
export const SSH_TEXT_PRIVATE_KEY: Tag = createTag(40800, "ssh-private");
|
|
118
|
+
export const SSH_TEXT_PUBLIC_KEY: Tag = createTag(40801, "ssh-public");
|
|
119
|
+
export const SSH_TEXT_SIGNATURE: Tag = createTag(40802, "ssh-signature");
|
|
120
|
+
export const SSH_TEXT_CERTIFICATE: Tag = createTag(40803, "ssh-certificate");
|
|
121
|
+
|
|
122
|
+
export const PROVENANCE_MARK: Tag = createTag(1347571542, "provenance");
|
|
123
|
+
|
|
124
|
+
// ============================================================================
|
|
125
|
+
// DEPRECATED TAGS
|
|
126
|
+
// ============================================================================
|
|
127
|
+
//
|
|
128
|
+
// The following tags are deprecated and should not be used in new code.
|
|
129
|
+
// Unfortunately, they are likely to be in active use by external developers,
|
|
130
|
+
// but should never have been used as they are in the range of CBOR tags
|
|
131
|
+
// requiring "Specification" action by IANA, which requires IANA experts to
|
|
132
|
+
// review and approve the specification. These are harder to get approved than
|
|
133
|
+
// "First Come First Served" tags, and we don't want to have to do that for
|
|
134
|
+
// every new tag we create. Most of these tags have been replaced by "First Come
|
|
135
|
+
// First Served" tags in the range of 40000+.
|
|
136
|
+
|
|
137
|
+
export const SEED_V1: Tag = createTag(300, "crypto-seed");
|
|
138
|
+
export const EC_KEY_V1: Tag = createTag(306, "crypto-eckey");
|
|
139
|
+
export const SSKR_SHARE_V1: Tag = createTag(309, "crypto-sskr");
|
|
140
|
+
|
|
141
|
+
export const HDKEY_V1: Tag = createTag(303, "crypto-hdkey");
|
|
142
|
+
export const DERIVATION_PATH_V1: Tag = createTag(304, "crypto-keypath");
|
|
143
|
+
export const USE_INFO_V1: Tag = createTag(305, "crypto-coin-info");
|
|
144
|
+
export const OUTPUT_DESCRIPTOR_V1: Tag = createTag(307, "crypto-output");
|
|
145
|
+
export const PSBT_V1: Tag = createTag(310, "crypto-psbt");
|
|
146
|
+
export const ACCOUNT_V1: Tag = createTag(311, "crypto-account");
|
|
147
|
+
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// Tags for subtypes specific to AccountBundle (crypto-output).
|
|
150
|
+
// ============================================================================
|
|
151
|
+
|
|
152
|
+
export const OUTPUT_SCRIPT_HASH: Tag = createTag(400, "output-script-hash");
|
|
153
|
+
export const OUTPUT_WITNESS_SCRIPT_HASH: Tag = createTag(401, "output-witness-script-hash");
|
|
154
|
+
export const OUTPUT_PUBLIC_KEY: Tag = createTag(402, "output-public-key");
|
|
155
|
+
export const OUTPUT_PUBLIC_KEY_HASH: Tag = createTag(403, "output-public-key-hash");
|
|
156
|
+
export const OUTPUT_WITNESS_PUBLIC_KEY_HASH: Tag = createTag(404, "output-witness-public-key-hash");
|
|
157
|
+
export const OUTPUT_COMBO: Tag = createTag(405, "output-combo");
|
|
158
|
+
export const OUTPUT_MULTISIG: Tag = createTag(406, "output-multisig");
|
|
159
|
+
export const OUTPUT_SORTED_MULTISIG: Tag = createTag(407, "output-sorted-multisig");
|
|
160
|
+
export const OUTPUT_RAW_SCRIPT: Tag = createTag(408, "output-raw-script");
|
|
161
|
+
export const OUTPUT_TAPROOT: Tag = createTag(409, "output-taproot");
|
|
162
|
+
export const OUTPUT_COSIGNER: Tag = createTag(410, "output-cosigner");
|
|
163
|
+
|
|
164
|
+
// ============================================================================
|
|
165
|
+
// Registration Functions
|
|
166
|
+
// ============================================================================
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Register all Blockchain Commons tags in a specific tags store.
|
|
170
|
+
* This matches the Rust function `register_tags_in()`.
|
|
171
|
+
*
|
|
172
|
+
* @param tagsStore - The tags store to register tags into
|
|
173
|
+
*/
|
|
174
|
+
export function registerTagsIn(tagsStore: TagsStore): void {
|
|
175
|
+
// First register dcbor's tags
|
|
176
|
+
registerDcborTagsIn(tagsStore);
|
|
177
|
+
|
|
178
|
+
// Then register all Blockchain Commons tags
|
|
179
|
+
const tags: Tag[] = [
|
|
180
|
+
URI,
|
|
181
|
+
UUID,
|
|
182
|
+
ENCODED_CBOR,
|
|
183
|
+
ENVELOPE,
|
|
184
|
+
LEAF,
|
|
185
|
+
JSON,
|
|
186
|
+
KNOWN_VALUE,
|
|
187
|
+
DIGEST,
|
|
188
|
+
ENCRYPTED,
|
|
189
|
+
COMPRESSED,
|
|
190
|
+
REQUEST,
|
|
191
|
+
RESPONSE,
|
|
192
|
+
FUNCTION,
|
|
193
|
+
PARAMETER,
|
|
194
|
+
PLACEHOLDER,
|
|
195
|
+
REPLACEMENT,
|
|
196
|
+
EVENT,
|
|
197
|
+
SEED_V1,
|
|
198
|
+
EC_KEY_V1,
|
|
199
|
+
SSKR_SHARE_V1,
|
|
200
|
+
SEED,
|
|
201
|
+
EC_KEY,
|
|
202
|
+
SSKR_SHARE,
|
|
203
|
+
X25519_PRIVATE_KEY,
|
|
204
|
+
X25519_PUBLIC_KEY,
|
|
205
|
+
ARID,
|
|
206
|
+
PRIVATE_KEYS,
|
|
207
|
+
NONCE,
|
|
208
|
+
PASSWORD,
|
|
209
|
+
PRIVATE_KEY_BASE,
|
|
210
|
+
PUBLIC_KEYS,
|
|
211
|
+
SALT,
|
|
212
|
+
SEALED_MESSAGE,
|
|
213
|
+
SIGNATURE,
|
|
214
|
+
SIGNING_PRIVATE_KEY,
|
|
215
|
+
SIGNING_PUBLIC_KEY,
|
|
216
|
+
SYMMETRIC_KEY,
|
|
217
|
+
XID,
|
|
218
|
+
REFERENCE,
|
|
219
|
+
ENCRYPTED_KEY,
|
|
220
|
+
MLKEM_PRIVATE_KEY,
|
|
221
|
+
MLKEM_PUBLIC_KEY,
|
|
222
|
+
MLKEM_CIPHERTEXT,
|
|
223
|
+
MLDSA_PRIVATE_KEY,
|
|
224
|
+
MLDSA_PUBLIC_KEY,
|
|
225
|
+
MLDSA_SIGNATURE,
|
|
226
|
+
HDKEY_V1,
|
|
227
|
+
DERIVATION_PATH_V1,
|
|
228
|
+
USE_INFO_V1,
|
|
229
|
+
OUTPUT_DESCRIPTOR_V1,
|
|
230
|
+
PSBT_V1,
|
|
231
|
+
ACCOUNT_V1,
|
|
232
|
+
HDKEY,
|
|
233
|
+
DERIVATION_PATH,
|
|
234
|
+
USE_INFO,
|
|
235
|
+
ADDRESS,
|
|
236
|
+
OUTPUT_DESCRIPTOR,
|
|
237
|
+
PSBT,
|
|
238
|
+
ACCOUNT_DESCRIPTOR,
|
|
239
|
+
SSH_TEXT_PRIVATE_KEY,
|
|
240
|
+
SSH_TEXT_PUBLIC_KEY,
|
|
241
|
+
SSH_TEXT_SIGNATURE,
|
|
242
|
+
SSH_TEXT_CERTIFICATE,
|
|
243
|
+
OUTPUT_SCRIPT_HASH,
|
|
244
|
+
OUTPUT_WITNESS_SCRIPT_HASH,
|
|
245
|
+
OUTPUT_PUBLIC_KEY,
|
|
246
|
+
OUTPUT_PUBLIC_KEY_HASH,
|
|
247
|
+
OUTPUT_WITNESS_PUBLIC_KEY_HASH,
|
|
248
|
+
OUTPUT_COMBO,
|
|
249
|
+
OUTPUT_MULTISIG,
|
|
250
|
+
OUTPUT_SORTED_MULTISIG,
|
|
251
|
+
OUTPUT_RAW_SCRIPT,
|
|
252
|
+
OUTPUT_TAPROOT,
|
|
253
|
+
OUTPUT_COSIGNER,
|
|
254
|
+
PROVENANCE_MARK,
|
|
255
|
+
];
|
|
256
|
+
|
|
257
|
+
tagsStore.insertAll(tags);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Register all Blockchain Commons tags in the global tags store.
|
|
262
|
+
* This matches the Rust function `register_tags()`.
|
|
263
|
+
*
|
|
264
|
+
* This function is idempotent - calling it multiple times is safe.
|
|
265
|
+
*/
|
|
266
|
+
export function registerTags(): void {
|
|
267
|
+
const globalStore = getGlobalTagsStore();
|
|
268
|
+
registerTagsIn(globalStore);
|
|
269
|
+
}
|