@motebit/crypto 1.2.0 → 1.3.0
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/dist/artifacts.d.ts +42 -0
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/content-artifact.d.ts +150 -0
- package/dist/content-artifact.d.ts.map +1 -0
- package/dist/hardware-attestation.d.ts +5 -5
- package/dist/index.d.ts +36 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6851 -1076
- package/dist/suite-dispatch.js +3223 -189
- package/package.json +2 -2
- package/dist/artifacts.js +0 -1158
- package/dist/artifacts.js.map +0 -1
- package/dist/credential-anchor.js +0 -200
- package/dist/credential-anchor.js.map +0 -1
- package/dist/credentials.js +0 -212
- package/dist/credentials.js.map +0 -1
- package/dist/deletion-certificate.js +0 -562
- package/dist/deletion-certificate.js.map +0 -1
- package/dist/hardware-attestation.js +0 -400
- package/dist/hardware-attestation.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/merkle.js +0 -84
- package/dist/merkle.js.map +0 -1
- package/dist/signing.js +0 -314
- package/dist/signing.js.map +0 -1
- package/dist/skills.js +0 -228
- package/dist/skills.js.map +0 -1
- package/dist/suite-dispatch.js.map +0 -1
- package/dist/witness-omission-dispute.js +0 -237
- package/dist/witness-omission-dispute.js.map +0 -1
package/dist/signing.js
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Protocol signing primitives — Ed25519, encoding, canonical JSON, signed tokens.
|
|
3
|
-
*
|
|
4
|
-
* These are the cryptographic building blocks that any protocol participant
|
|
5
|
-
* needs to produce valid Motebit artifacts. Moved from BSL @motebit/encryption
|
|
6
|
-
* to the permissive floor in @motebit/crypto (Apache-2.0) so the protocol's
|
|
7
|
-
* signing format is open.
|
|
8
|
-
*
|
|
9
|
-
* Zero monorepo dependencies — only @noble/ed25519 for cryptography.
|
|
10
|
-
*/
|
|
11
|
-
import * as ed from "@noble/ed25519";
|
|
12
|
-
import { sha512 } from "@noble/hashes/sha512";
|
|
13
|
-
// @noble/ed25519 v3 requires explicit SHA-512 binding
|
|
14
|
-
if (!ed.hashes.sha512) {
|
|
15
|
-
ed.hashes.sha512 = (msg) => sha512(msg);
|
|
16
|
-
}
|
|
17
|
-
/** The one suite this token shape uses. Exported as a const so the
|
|
18
|
-
* signer emits exactly this value and the verifier checks for exactly
|
|
19
|
-
* this value — no string drift risk.
|
|
20
|
-
*/
|
|
21
|
-
export const SIGNED_TOKEN_SUITE = "motebit-jwt-ed25519-v1";
|
|
22
|
-
// === Canonical JSON (JCS/RFC 8785) ===
|
|
23
|
-
/**
|
|
24
|
-
* Deterministic JSON serialization with sorted keys (recursive).
|
|
25
|
-
* Produces identical output regardless of insertion order.
|
|
26
|
-
*
|
|
27
|
-
* Used by every signed-payload helper: execution receipts, identity files,
|
|
28
|
-
* succession records, settlement leaves, etc. Two structurally-equal payloads
|
|
29
|
-
* always produce identical bytes here, which is what makes the Ed25519
|
|
30
|
-
* signatures verifiable.
|
|
31
|
-
*/
|
|
32
|
-
export function canonicalJson(obj) {
|
|
33
|
-
if (obj === null || obj === undefined)
|
|
34
|
-
return JSON.stringify(obj);
|
|
35
|
-
if (typeof obj !== "object")
|
|
36
|
-
return JSON.stringify(obj);
|
|
37
|
-
if (Array.isArray(obj)) {
|
|
38
|
-
return "[" + obj.map((item) => canonicalJson(item)).join(",") + "]";
|
|
39
|
-
}
|
|
40
|
-
const sorted = Object.keys(obj).sort();
|
|
41
|
-
const entries = [];
|
|
42
|
-
for (const key of sorted) {
|
|
43
|
-
const val = obj[key];
|
|
44
|
-
if (val === undefined)
|
|
45
|
-
continue;
|
|
46
|
-
entries.push(JSON.stringify(key) + ":" + canonicalJson(val));
|
|
47
|
-
}
|
|
48
|
-
return "{" + entries.join(",") + "}";
|
|
49
|
-
}
|
|
50
|
-
// === Encoding Helpers ===
|
|
51
|
-
export function bytesToHex(bytes) {
|
|
52
|
-
return Array.from(bytes)
|
|
53
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
54
|
-
.join("");
|
|
55
|
-
}
|
|
56
|
-
export function hexToBytes(hex) {
|
|
57
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
58
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
59
|
-
bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
60
|
-
}
|
|
61
|
-
return bytes;
|
|
62
|
-
}
|
|
63
|
-
export function toBase64Url(data) {
|
|
64
|
-
let binary = "";
|
|
65
|
-
for (let i = 0; i < data.length; i++) {
|
|
66
|
-
binary += String.fromCharCode(data[i]);
|
|
67
|
-
}
|
|
68
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
69
|
-
}
|
|
70
|
-
export function fromBase64Url(str) {
|
|
71
|
-
const padded = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
72
|
-
const binary = atob(padded);
|
|
73
|
-
const bytes = new Uint8Array(binary.length);
|
|
74
|
-
for (let i = 0; i < binary.length; i++) {
|
|
75
|
-
bytes[i] = binary.charCodeAt(i);
|
|
76
|
-
}
|
|
77
|
-
return bytes;
|
|
78
|
-
}
|
|
79
|
-
// === Base58btc ===
|
|
80
|
-
const BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
81
|
-
export function base58btcEncode(bytes) {
|
|
82
|
-
let zeros = 0;
|
|
83
|
-
while (zeros < bytes.length && bytes[zeros] === 0)
|
|
84
|
-
zeros++;
|
|
85
|
-
let value = 0n;
|
|
86
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
87
|
-
value = value * 256n + BigInt(bytes[i]);
|
|
88
|
-
}
|
|
89
|
-
let result = "";
|
|
90
|
-
while (value > 0n) {
|
|
91
|
-
const remainder = Number(value % 58n);
|
|
92
|
-
value = value / 58n;
|
|
93
|
-
result = BASE58_ALPHABET[remainder] + result;
|
|
94
|
-
}
|
|
95
|
-
return BASE58_ALPHABET[0].repeat(zeros) + result;
|
|
96
|
-
}
|
|
97
|
-
export function base58btcDecode(str) {
|
|
98
|
-
let zeros = 0;
|
|
99
|
-
while (zeros < str.length && str[zeros] === BASE58_ALPHABET[0])
|
|
100
|
-
zeros++;
|
|
101
|
-
let value = 0n;
|
|
102
|
-
for (let i = 0; i < str.length; i++) {
|
|
103
|
-
const idx = BASE58_ALPHABET.indexOf(str[i]);
|
|
104
|
-
if (idx === -1)
|
|
105
|
-
throw new Error(`Invalid base58 character: ${str[i]}`);
|
|
106
|
-
value = value * 58n + BigInt(idx);
|
|
107
|
-
}
|
|
108
|
-
const hex = [];
|
|
109
|
-
while (value > 0n) {
|
|
110
|
-
const byte = Number(value & 0xffn);
|
|
111
|
-
hex.unshift(byte.toString(16).padStart(2, "0"));
|
|
112
|
-
value >>= 8n;
|
|
113
|
-
}
|
|
114
|
-
const dataBytes = hex.length > 0 ? new Uint8Array(hex.map((h) => parseInt(h, 16))) : new Uint8Array(0);
|
|
115
|
-
const result = new Uint8Array(zeros + dataBytes.length);
|
|
116
|
-
result.set(dataBytes, zeros);
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
// === did:key (W3C Decentralized Identifier) ===
|
|
120
|
-
/**
|
|
121
|
-
* Extract a raw 32-byte Ed25519 public key from a did:key URI.
|
|
122
|
-
*
|
|
123
|
-
* Parses `did:key:z<base58btc(0xed01 + publicKey)>`, strips the 2-byte
|
|
124
|
-
* multicodec prefix, and returns the raw public key bytes.
|
|
125
|
-
*/
|
|
126
|
-
export function didKeyToPublicKey(did) {
|
|
127
|
-
if (!did.startsWith("did:key:z")) {
|
|
128
|
-
throw new Error("Invalid did:key URI: must start with did:key:z");
|
|
129
|
-
}
|
|
130
|
-
const encoded = did.slice("did:key:z".length);
|
|
131
|
-
const decoded = base58btcDecode(encoded);
|
|
132
|
-
if (decoded.length !== 34) {
|
|
133
|
-
throw new Error(`Invalid did:key: expected 34 bytes (2 prefix + 32 key), got ${decoded.length}`);
|
|
134
|
-
}
|
|
135
|
-
if (decoded[0] !== 0xed || decoded[1] !== 0x01) {
|
|
136
|
-
throw new Error("Invalid did:key: multicodec prefix is not ed25519-pub (0xed01)");
|
|
137
|
-
}
|
|
138
|
-
return decoded.slice(2);
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Derive a did:key URI from an Ed25519 public key.
|
|
142
|
-
*
|
|
143
|
-
* Format: did:key:z<base58btc(0xed01 + publicKey)>
|
|
144
|
-
* See: https://w3c-ccg.github.io/did-method-key/
|
|
145
|
-
*/
|
|
146
|
-
export function publicKeyToDidKey(publicKey) {
|
|
147
|
-
if (publicKey.length !== 32) {
|
|
148
|
-
throw new Error("Ed25519 public key must be 32 bytes");
|
|
149
|
-
}
|
|
150
|
-
const prefixed = new Uint8Array(34);
|
|
151
|
-
prefixed[0] = 0xed;
|
|
152
|
-
prefixed[1] = 0x01;
|
|
153
|
-
prefixed.set(publicKey, 2);
|
|
154
|
-
return `did:key:z${base58btcEncode(prefixed)}`;
|
|
155
|
-
}
|
|
156
|
-
export function hexPublicKeyToDidKey(hexPublicKey) {
|
|
157
|
-
return publicKeyToDidKey(hexToBytes(hexPublicKey));
|
|
158
|
-
}
|
|
159
|
-
// === SHA-256 ===
|
|
160
|
-
export async function hash(data) {
|
|
161
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
162
|
-
const hashArray = new Uint8Array(hashBuffer);
|
|
163
|
-
return Array.from(hashArray)
|
|
164
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
165
|
-
.join("");
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Canonical-bytes hash. Convenience wrapper over `canonicalJson` + SHA-256
|
|
169
|
-
* for diagnostic and audit use: lets a producer and a verifier deterministically
|
|
170
|
-
* agree on (or disagree about) the exact bytes a signature was computed over,
|
|
171
|
-
* without re-implementing the canonicalization recipe at the call site.
|
|
172
|
-
*
|
|
173
|
-
* Returns the hex SHA-256 of the UTF-8 bytes of `canonicalJson(obj)`. Stable
|
|
174
|
-
* across processes, machines, and Node versions — same input ⇒ same output,
|
|
175
|
-
* always. The only requirement on `obj` is that it be a JSON-serializable
|
|
176
|
-
* value (no functions, no symbols, no cycles).
|
|
177
|
-
*
|
|
178
|
-
* Primary use case: when a signed-artifact verification fails, both ends of
|
|
179
|
-
* the pipeline can log `canonicalSha256(body)` and the producer can confirm
|
|
180
|
-
* whether the bytes the verifier reproduced match the bytes the producer
|
|
181
|
-
* signed. A hash mismatch localizes the bug to the wire path; a hash match
|
|
182
|
-
* localizes it to the signature primitive (which is far less likely).
|
|
183
|
-
*/
|
|
184
|
-
export async function canonicalSha256(obj) {
|
|
185
|
-
return hash(new TextEncoder().encode(canonicalJson(obj)));
|
|
186
|
-
}
|
|
187
|
-
/** SHA-256 returning raw bytes (used by credential signing). */
|
|
188
|
-
export async function sha256(data) {
|
|
189
|
-
const buf = await crypto.subtle.digest("SHA-256", data);
|
|
190
|
-
return new Uint8Array(buf);
|
|
191
|
-
}
|
|
192
|
-
// === Ed25519 Signing ===
|
|
193
|
-
//
|
|
194
|
-
// The primitive sign/verify functions and keypair generation now live
|
|
195
|
-
// in `./suite-dispatch.ts`, which is the one file in @motebit/crypto
|
|
196
|
-
// permitted to call `ed.signAsync` / `ed.verifyAsync` directly (the
|
|
197
|
-
// `check-suite-dispatch` drift gate enforces that rule). These
|
|
198
|
-
// re-exports preserve the historical call sites that import from
|
|
199
|
-
// signing.ts directly (especially tests and @motebit/encryption).
|
|
200
|
-
// New artifact-level verifiers should prefer `verifyBySuite`.
|
|
201
|
-
import { generateEd25519Keypair, signBySuite, verifyBySuite } from "./suite-dispatch.js";
|
|
202
|
-
export { ed25519Sign, ed25519Verify, generateEd25519Keypair, getPublicKeyBySuite, signBySuite, verifyBySuite, } from "./suite-dispatch.js";
|
|
203
|
-
export async function generateKeypair() {
|
|
204
|
-
return generateEd25519Keypair();
|
|
205
|
-
}
|
|
206
|
-
// === Signed Tokens ===
|
|
207
|
-
/**
|
|
208
|
-
* Create a signed token: base64url(payload) + "." + base64url(signature).
|
|
209
|
-
* Default expiry: 5 minutes from now.
|
|
210
|
-
*
|
|
211
|
-
* The payload includes a fixed `suite` field (`SIGNED_TOKEN_SUITE`) so
|
|
212
|
-
* the verifier can dispatch primitive verification explicitly rather
|
|
213
|
-
* than implicitly assuming Ed25519. Callers MUST supply every other
|
|
214
|
-
* required payload field; this function does not fill defaults for
|
|
215
|
-
* `mid` / `did` / `iat` / `exp` / `jti` / `aud`.
|
|
216
|
-
*/
|
|
217
|
-
export async function createSignedToken(payload, privateKey) {
|
|
218
|
-
const withSuite = { ...payload, suite: SIGNED_TOKEN_SUITE };
|
|
219
|
-
const payloadBytes = new TextEncoder().encode(JSON.stringify(withSuite));
|
|
220
|
-
const payloadB64 = toBase64Url(payloadBytes);
|
|
221
|
-
const signature = await signBySuite(SIGNED_TOKEN_SUITE, payloadBytes, privateKey);
|
|
222
|
-
const sigB64 = toBase64Url(signature);
|
|
223
|
-
return `${payloadB64}.${sigB64}`;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Verify a signed token. Returns the parsed payload if valid and not
|
|
227
|
-
* expired, null otherwise.
|
|
228
|
-
*
|
|
229
|
-
* Rejects fail-closed on:
|
|
230
|
-
* - malformed token string (no dot separator, invalid base64url),
|
|
231
|
-
* - missing `suite` field,
|
|
232
|
-
* - `suite` value other than `SIGNED_TOKEN_SUITE`,
|
|
233
|
-
* - signature mismatch,
|
|
234
|
-
* - expired token,
|
|
235
|
-
* - missing `jti` (replay defense),
|
|
236
|
-
* - missing `aud` (cross-endpoint replay defense).
|
|
237
|
-
*/
|
|
238
|
-
export async function verifySignedToken(token, publicKey) {
|
|
239
|
-
const dotIdx = token.indexOf(".");
|
|
240
|
-
if (dotIdx === -1)
|
|
241
|
-
return null;
|
|
242
|
-
const payloadB64 = token.slice(0, dotIdx);
|
|
243
|
-
const sigB64 = token.slice(dotIdx + 1);
|
|
244
|
-
let payloadBytes;
|
|
245
|
-
let signature;
|
|
246
|
-
try {
|
|
247
|
-
payloadBytes = fromBase64Url(payloadB64);
|
|
248
|
-
signature = fromBase64Url(sigB64);
|
|
249
|
-
}
|
|
250
|
-
catch {
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
// Parse before verify so the suite value routes the primitive call.
|
|
254
|
-
// Malformed JSON → reject.
|
|
255
|
-
let payload;
|
|
256
|
-
try {
|
|
257
|
-
payload = JSON.parse(new TextDecoder().decode(payloadBytes));
|
|
258
|
-
}
|
|
259
|
-
catch {
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
// Missing or unknown suite → reject fail-closed. No legacy-no-suite path.
|
|
263
|
-
if (payload.suite !== SIGNED_TOKEN_SUITE)
|
|
264
|
-
return null;
|
|
265
|
-
const valid = await verifyBySuite(payload.suite, payloadBytes, signature, publicKey);
|
|
266
|
-
if (!valid)
|
|
267
|
-
return null;
|
|
268
|
-
if (payload.exp <= Date.now())
|
|
269
|
-
return null;
|
|
270
|
-
if (!payload.jti)
|
|
271
|
-
return null;
|
|
272
|
-
if (!payload.aud)
|
|
273
|
-
return null;
|
|
274
|
-
return payload;
|
|
275
|
-
}
|
|
276
|
-
// === Scope Utilities (Capability Attenuation) ===
|
|
277
|
-
/**
|
|
278
|
-
* Parse a comma-separated scope string into a Set.
|
|
279
|
-
* `"*"` is the wildcard meaning "all capabilities".
|
|
280
|
-
* Trims whitespace from each element.
|
|
281
|
-
*/
|
|
282
|
-
export function parseScopeSet(scope) {
|
|
283
|
-
if (scope === "*")
|
|
284
|
-
return new Set(["*"]);
|
|
285
|
-
return new Set(scope
|
|
286
|
-
.split(",")
|
|
287
|
-
.map((s) => s.trim())
|
|
288
|
-
.filter((s) => s.length > 0));
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Returns true if `childScope` is a proper subset of (or equal to) `parentScope`.
|
|
292
|
-
*
|
|
293
|
-
* Rules:
|
|
294
|
-
* - If parentScope is `"*"`, any childScope is valid (wildcard grants all).
|
|
295
|
-
* - If childScope is `"*"`, it's only valid if parentScope is also `"*"`.
|
|
296
|
-
* - Otherwise, every capability in childScope must appear in parentScope.
|
|
297
|
-
*/
|
|
298
|
-
export function isScopeNarrowed(parentScope, childScope) {
|
|
299
|
-
const parent = parseScopeSet(parentScope);
|
|
300
|
-
const child = parseScopeSet(childScope);
|
|
301
|
-
// Wildcard parent allows anything
|
|
302
|
-
if (parent.has("*"))
|
|
303
|
-
return true;
|
|
304
|
-
// Child requests wildcard but parent is not wildcard — scope widening
|
|
305
|
-
if (child.has("*"))
|
|
306
|
-
return false;
|
|
307
|
-
// Every capability in child must exist in parent
|
|
308
|
-
for (const cap of child) {
|
|
309
|
-
if (!parent.has(cap))
|
|
310
|
-
return false;
|
|
311
|
-
}
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
//# sourceMappingURL=signing.js.map
|
package/dist/signing.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signing.js","sourceRoot":"","sources":["../src/signing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,sDAAsD;AACtD,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACtB,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,GAAe,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACtD,CAAC;AA4BD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,wBAAiC,CAAC;AAEpE,wCAAwC;AAExC;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC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AK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/skills.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill manifest + envelope signing and verification — spec/skills-v1.md.
|
|
3
|
-
*
|
|
4
|
-
* Skills are motebit-internal protocol artifacts. They install locally,
|
|
5
|
-
* verify on motebit runtimes, and are signed by their author's motebit
|
|
6
|
-
* identity using `motebit-jcs-ed25519-b64-v1` — the same suite used for
|
|
7
|
-
* execution receipts, tool invocation receipts, settlement anchors, and
|
|
8
|
-
* migration artifacts. NOT W3C `eddsa-jcs-2022` (that suite is reserved for
|
|
9
|
-
* credentials, identity files, and presentations needing third-party W3C
|
|
10
|
-
* interop).
|
|
11
|
-
*
|
|
12
|
-
* Signature recipe (spec §5.1):
|
|
13
|
-
*
|
|
14
|
-
* manifest_bytes = JCS(manifest_with_signature_value_removed) || 0x0A || lf_body
|
|
15
|
-
* envelope_bytes = JCS(envelope_with_signature_value_removed)
|
|
16
|
-
* signature = Ed25519.sign(bytes, privateKey) -- routed through verifyBySuite
|
|
17
|
-
*
|
|
18
|
-
* Verification is offline: no relay, no registry, no external service. Per
|
|
19
|
-
* @motebit/crypto/CLAUDE.md rule 4, third-party verifiers using only this
|
|
20
|
-
* package and the signer's public key can validate any motebit-signed skill.
|
|
21
|
-
*/
|
|
22
|
-
import { canonicalJson, fromBase64Url, hexToBytes, signBySuite, toBase64Url, verifyBySuite, } from "./signing.js";
|
|
23
|
-
/** The suite skills sign under in v1. Mirrors EXECUTION_RECEIPT_SUITE. */
|
|
24
|
-
export const SKILL_SIGNATURE_SUITE = "motebit-jcs-ed25519-b64-v1";
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
// Canonicalization — pure, deterministic, dependency-free
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
/**
|
|
29
|
-
* Strip `signature.value` from a SkillSignature, preserving `suite` and
|
|
30
|
-
* `public_key` (those ARE part of the signed canonical form per spec §5.1).
|
|
31
|
-
*/
|
|
32
|
-
function signatureWithoutValue(sig) {
|
|
33
|
-
return { suite: sig.suite, public_key: sig.public_key };
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Compute the canonical bytes that a SkillManifest signature is computed over.
|
|
37
|
-
* `body` is the LF-normalized SKILL.md body bytes (everything after the
|
|
38
|
-
* closing `---` delimiter), with CRLF/CR converted to LF, no BOM, UTF-8.
|
|
39
|
-
*
|
|
40
|
-
* Caller is responsible for body normalization. The reference parser in
|
|
41
|
-
* @motebit/skills (BSL) does the normalization at file-read time.
|
|
42
|
-
*
|
|
43
|
-
* The manifest's `motebit.signature.value` is removed before canonicalization;
|
|
44
|
-
* `suite` and `public_key` are preserved (they are signature-bound).
|
|
45
|
-
*/
|
|
46
|
-
export function canonicalizeSkillManifestBytes(manifest, body) {
|
|
47
|
-
const motebitForCanonical = manifest.motebit.signature
|
|
48
|
-
? {
|
|
49
|
-
...manifest.motebit,
|
|
50
|
-
signature: signatureWithoutValue(manifest.motebit.signature),
|
|
51
|
-
}
|
|
52
|
-
: manifest.motebit;
|
|
53
|
-
const manifestForCanonical = { ...manifest, motebit: motebitForCanonical };
|
|
54
|
-
const canonical = canonicalJson(manifestForCanonical);
|
|
55
|
-
const manifestBytes = new TextEncoder().encode(canonical);
|
|
56
|
-
const out = new Uint8Array(manifestBytes.length + 1 + body.length);
|
|
57
|
-
out.set(manifestBytes, 0);
|
|
58
|
-
out[manifestBytes.length] = 0x0a; // LF separator
|
|
59
|
-
out.set(body, manifestBytes.length + 1);
|
|
60
|
-
return out;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Compute the canonical bytes that a SkillEnvelope signature is computed
|
|
64
|
-
* over. Sibling to manifest canonicalization; envelope is pure JSON so no
|
|
65
|
-
* body concatenation.
|
|
66
|
-
*/
|
|
67
|
-
export function canonicalizeSkillEnvelopeBytes(envelope) {
|
|
68
|
-
const envelopeForCanonical = {
|
|
69
|
-
...envelope,
|
|
70
|
-
signature: signatureWithoutValue(envelope.signature),
|
|
71
|
-
};
|
|
72
|
-
const canonical = canonicalJson(envelopeForCanonical);
|
|
73
|
-
return new TextEncoder().encode(canonical);
|
|
74
|
-
}
|
|
75
|
-
// ---------------------------------------------------------------------------
|
|
76
|
-
// Signing — for skill authors
|
|
77
|
-
// ---------------------------------------------------------------------------
|
|
78
|
-
/**
|
|
79
|
-
* Sign a SkillManifest, returning the signed manifest with `motebit.signature`
|
|
80
|
-
* populated. Caller provides the LF-normalized body bytes; signing recipe is
|
|
81
|
-
* spec §5.1.
|
|
82
|
-
*
|
|
83
|
-
* The returned manifest's `motebit.signature.public_key` is hex-encoded and
|
|
84
|
-
* `motebit.signature.value` is base64url-encoded, matching the suite contract.
|
|
85
|
-
*/
|
|
86
|
-
export async function signSkillManifest(unsigned, privateKey, publicKey, body) {
|
|
87
|
-
const publicKeyHex = bytesToLowerHex(publicKey);
|
|
88
|
-
// Stamp the unsigned signature block (suite + public_key) so it participates
|
|
89
|
-
// in canonicalization at sign time.
|
|
90
|
-
const unsignedWithSig = {
|
|
91
|
-
...unsigned,
|
|
92
|
-
motebit: {
|
|
93
|
-
...unsigned.motebit,
|
|
94
|
-
signature: {
|
|
95
|
-
suite: SKILL_SIGNATURE_SUITE,
|
|
96
|
-
public_key: publicKeyHex,
|
|
97
|
-
value: "", // placeholder; stripped by canonicalize
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
const message = canonicalizeSkillManifestBytes(unsignedWithSig, body);
|
|
102
|
-
const sig = await signBySuite(SKILL_SIGNATURE_SUITE, message, privateKey);
|
|
103
|
-
return {
|
|
104
|
-
...unsigned,
|
|
105
|
-
motebit: {
|
|
106
|
-
...unsigned.motebit,
|
|
107
|
-
signature: {
|
|
108
|
-
suite: SKILL_SIGNATURE_SUITE,
|
|
109
|
-
public_key: publicKeyHex,
|
|
110
|
-
value: toBase64Url(sig),
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Sign a SkillEnvelope, returning the signed envelope. Sibling to
|
|
117
|
-
* `signSkillManifest`. Envelope canonicalization is pure JSON (§5.1).
|
|
118
|
-
*/
|
|
119
|
-
export async function signSkillEnvelope(unsigned, privateKey, publicKey) {
|
|
120
|
-
const publicKeyHex = bytesToLowerHex(publicKey);
|
|
121
|
-
const unsignedWithSig = {
|
|
122
|
-
...unsigned,
|
|
123
|
-
signature: {
|
|
124
|
-
suite: SKILL_SIGNATURE_SUITE,
|
|
125
|
-
public_key: publicKeyHex,
|
|
126
|
-
value: "", // placeholder; stripped by canonicalize
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
const message = canonicalizeSkillEnvelopeBytes(unsignedWithSig);
|
|
130
|
-
const sig = await signBySuite(SKILL_SIGNATURE_SUITE, message, privateKey);
|
|
131
|
-
return {
|
|
132
|
-
...unsigned,
|
|
133
|
-
signature: {
|
|
134
|
-
suite: SKILL_SIGNATURE_SUITE,
|
|
135
|
-
public_key: publicKeyHex,
|
|
136
|
-
value: toBase64Url(sig),
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
// ---------------------------------------------------------------------------
|
|
141
|
-
// Verification — fail-closed on every error path
|
|
142
|
-
// ---------------------------------------------------------------------------
|
|
143
|
-
/**
|
|
144
|
-
* Verify a SkillManifest's signature against the provided public key and
|
|
145
|
-
* LF-normalized body bytes. Returns `false` on any failure path:
|
|
146
|
-
*
|
|
147
|
-
* - manifest is unsigned (`motebit.signature` absent)
|
|
148
|
-
* - suite mismatch (only `motebit-jcs-ed25519-b64-v1` accepted in v1)
|
|
149
|
-
* - public_key in the signature doesn't match the supplied public key
|
|
150
|
-
* - signature value fails base64url decode
|
|
151
|
-
* - Ed25519 verification fails
|
|
152
|
-
*
|
|
153
|
-
* Per CLAUDE.md rule 4, this is the third-party self-verification entry
|
|
154
|
-
* point. Only this package + the signer's public key are required.
|
|
155
|
-
*/
|
|
156
|
-
export async function verifySkillManifest(manifest, body, publicKey) {
|
|
157
|
-
return (await verifySkillManifestDetailed(manifest, body, publicKey)).valid;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Companion to `verifySkillManifest` that returns a categorized failure
|
|
161
|
-
* reason for observability. Same recipe; same fail-closed behavior.
|
|
162
|
-
*/
|
|
163
|
-
export async function verifySkillManifestDetailed(manifest, body, publicKey) {
|
|
164
|
-
const sig = manifest.motebit.signature;
|
|
165
|
-
if (!sig)
|
|
166
|
-
return { valid: false, reason: "no_signature" };
|
|
167
|
-
if (sig.suite !== SKILL_SIGNATURE_SUITE)
|
|
168
|
-
return { valid: false, reason: "wrong_suite" };
|
|
169
|
-
const publicKeyHex = bytesToLowerHex(publicKey);
|
|
170
|
-
if (sig.public_key.toLowerCase() !== publicKeyHex) {
|
|
171
|
-
return { valid: false, reason: "bad_public_key" };
|
|
172
|
-
}
|
|
173
|
-
let sigBytes;
|
|
174
|
-
try {
|
|
175
|
-
sigBytes = fromBase64Url(sig.value);
|
|
176
|
-
}
|
|
177
|
-
catch {
|
|
178
|
-
return { valid: false, reason: "bad_signature_value" };
|
|
179
|
-
}
|
|
180
|
-
const message = canonicalizeSkillManifestBytes(manifest, body);
|
|
181
|
-
const valid = await verifyBySuite(SKILL_SIGNATURE_SUITE, message, sigBytes, publicKey);
|
|
182
|
-
return { valid, reason: valid ? "ok" : "ed25519_mismatch" };
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Verify a SkillEnvelope's signature. Sibling to `verifySkillManifest` —
|
|
186
|
-
* same suite, same fail-closed semantics. Note: envelope verification does
|
|
187
|
-
* NOT cross-check `body_hash` or `files[].hash` against on-disk bytes; the
|
|
188
|
-
* caller (install-time logic in the registry) is responsible for that pass
|
|
189
|
-
* after signature verification succeeds.
|
|
190
|
-
*/
|
|
191
|
-
export async function verifySkillEnvelope(envelope, publicKey) {
|
|
192
|
-
return (await verifySkillEnvelopeDetailed(envelope, publicKey)).valid;
|
|
193
|
-
}
|
|
194
|
-
export async function verifySkillEnvelopeDetailed(envelope, publicKey) {
|
|
195
|
-
const sig = envelope.signature;
|
|
196
|
-
if (sig.suite !== SKILL_SIGNATURE_SUITE)
|
|
197
|
-
return { valid: false, reason: "wrong_suite" };
|
|
198
|
-
const publicKeyHex = bytesToLowerHex(publicKey);
|
|
199
|
-
if (sig.public_key.toLowerCase() !== publicKeyHex) {
|
|
200
|
-
return { valid: false, reason: "bad_public_key" };
|
|
201
|
-
}
|
|
202
|
-
let sigBytes;
|
|
203
|
-
try {
|
|
204
|
-
sigBytes = fromBase64Url(sig.value);
|
|
205
|
-
}
|
|
206
|
-
catch {
|
|
207
|
-
return { valid: false, reason: "bad_signature_value" };
|
|
208
|
-
}
|
|
209
|
-
const message = canonicalizeSkillEnvelopeBytes(envelope);
|
|
210
|
-
const valid = await verifyBySuite(SKILL_SIGNATURE_SUITE, message, sigBytes, publicKey);
|
|
211
|
-
return { valid, reason: valid ? "ok" : "ed25519_mismatch" };
|
|
212
|
-
}
|
|
213
|
-
// ---------------------------------------------------------------------------
|
|
214
|
-
// Helpers
|
|
215
|
-
// ---------------------------------------------------------------------------
|
|
216
|
-
/** Hex-encode a 32-byte public key as 64 lowercase hex chars. */
|
|
217
|
-
function bytesToLowerHex(bytes) {
|
|
218
|
-
let hex = "";
|
|
219
|
-
for (const b of bytes) {
|
|
220
|
-
hex += b.toString(16).padStart(2, "0");
|
|
221
|
-
}
|
|
222
|
-
return hex;
|
|
223
|
-
}
|
|
224
|
-
/** Decode a hex public key from a SkillSignature for caller convenience. */
|
|
225
|
-
export function decodeSkillSignaturePublicKey(sig) {
|
|
226
|
-
return hexToBytes(sig.public_key);
|
|
227
|
-
}
|
|
228
|
-
//# sourceMappingURL=sk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