@mikeargento/bitgraph 1.9.1 → 1.10.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/README.md +21 -21
- package/dist/fuse-cli.js +2 -2
- package/dist/fuse-cli.js.map +1 -1
- package/dist/fuse.d.ts +15 -1
- package/dist/fuse.d.ts.map +1 -1
- package/dist/fuse.js +29 -12
- package/dist/fuse.js.map +1 -1
- package/package.json +12 -8
- package/src/fuse-cli.ts +2 -2
- package/src/fuse.ts +46 -13
- package/dist/__tests__/audit-anchors.test.d.ts +0 -2
- package/dist/__tests__/audit-anchors.test.d.ts.map +0 -1
- package/dist/__tests__/audit-anchors.test.js +0 -152
- package/dist/__tests__/audit-anchors.test.js.map +0 -1
- package/dist/__tests__/audit-anomalies.test.d.ts +0 -2
- package/dist/__tests__/audit-anomalies.test.d.ts.map +0 -1
- package/dist/__tests__/audit-anomalies.test.js +0 -663
- package/dist/__tests__/audit-anomalies.test.js.map +0 -1
- package/dist/__tests__/audit-attestation.test.d.ts +0 -2
- package/dist/__tests__/audit-attestation.test.d.ts.map +0 -1
- package/dist/__tests__/audit-attestation.test.js +0 -403
- package/dist/__tests__/audit-attestation.test.js.map +0 -1
- package/dist/__tests__/audit-bench-smoke.test.d.ts +0 -2
- package/dist/__tests__/audit-bench-smoke.test.d.ts.map +0 -1
- package/dist/__tests__/audit-bench-smoke.test.js +0 -87
- package/dist/__tests__/audit-bench-smoke.test.js.map +0 -1
- package/dist/__tests__/audit-boundary.test.d.ts +0 -20
- package/dist/__tests__/audit-boundary.test.d.ts.map +0 -1
- package/dist/__tests__/audit-boundary.test.js +0 -84
- package/dist/__tests__/audit-boundary.test.js.map +0 -1
- package/dist/__tests__/audit-cli.test.d.ts +0 -2
- package/dist/__tests__/audit-cli.test.d.ts.map +0 -1
- package/dist/__tests__/audit-cli.test.js +0 -239
- package/dist/__tests__/audit-cli.test.js.map +0 -1
- package/dist/__tests__/audit-dependencies.test.d.ts +0 -2
- package/dist/__tests__/audit-dependencies.test.d.ts.map +0 -1
- package/dist/__tests__/audit-dependencies.test.js +0 -116
- package/dist/__tests__/audit-dependencies.test.js.map +0 -1
- package/dist/__tests__/audit-fixtures.d.ts +0 -265
- package/dist/__tests__/audit-fixtures.d.ts.map +0 -1
- package/dist/__tests__/audit-fixtures.js +0 -511
- package/dist/__tests__/audit-fixtures.js.map +0 -1
- package/dist/__tests__/audit-ingest.test.d.ts +0 -2
- package/dist/__tests__/audit-ingest.test.d.ts.map +0 -1
- package/dist/__tests__/audit-ingest.test.js +0 -473
- package/dist/__tests__/audit-ingest.test.js.map +0 -1
- package/dist/__tests__/audit-memory-ingest.test.d.ts +0 -12
- package/dist/__tests__/audit-memory-ingest.test.d.ts.map +0 -1
- package/dist/__tests__/audit-memory-ingest.test.js +0 -135
- package/dist/__tests__/audit-memory-ingest.test.js.map +0 -1
- package/dist/__tests__/audit-property.test.d.ts +0 -2
- package/dist/__tests__/audit-property.test.d.ts.map +0 -1
- package/dist/__tests__/audit-property.test.js +0 -771
- package/dist/__tests__/audit-property.test.js.map +0 -1
- package/dist/__tests__/audit-real-fixtures.test.d.ts +0 -2
- package/dist/__tests__/audit-real-fixtures.test.d.ts.map +0 -1
- package/dist/__tests__/audit-real-fixtures.test.js +0 -132
- package/dist/__tests__/audit-real-fixtures.test.js.map +0 -1
- package/dist/__tests__/audit-real-live.test.d.ts +0 -2
- package/dist/__tests__/audit-real-live.test.d.ts.map +0 -1
- package/dist/__tests__/audit-real-live.test.js +0 -107
- package/dist/__tests__/audit-real-live.test.js.map +0 -1
- package/dist/__tests__/audit-reconstruct.test.d.ts +0 -2
- package/dist/__tests__/audit-reconstruct.test.d.ts.map +0 -1
- package/dist/__tests__/audit-reconstruct.test.js +0 -287
- package/dist/__tests__/audit-reconstruct.test.js.map +0 -1
- package/dist/__tests__/audit-report.test.d.ts +0 -2
- package/dist/__tests__/audit-report.test.d.ts.map +0 -1
- package/dist/__tests__/audit-report.test.js +0 -186
- package/dist/__tests__/audit-report.test.js.map +0 -1
- package/dist/__tests__/audit-roundtrip.test.d.ts +0 -2
- package/dist/__tests__/audit-roundtrip.test.d.ts.map +0 -1
- package/dist/__tests__/audit-roundtrip.test.js +0 -368
- package/dist/__tests__/audit-roundtrip.test.js.map +0 -1
- package/dist/__tests__/audit-temporal.test.d.ts +0 -2
- package/dist/__tests__/audit-temporal.test.d.ts.map +0 -1
- package/dist/__tests__/audit-temporal.test.js +0 -364
- package/dist/__tests__/audit-temporal.test.js.map +0 -1
- package/dist/__tests__/audit-tiers.test.d.ts +0 -2
- package/dist/__tests__/audit-tiers.test.d.ts.map +0 -1
- package/dist/__tests__/audit-tiers.test.js +0 -282
- package/dist/__tests__/audit-tiers.test.js.map +0 -1
- package/dist/__tests__/audit-witness-real.test.d.ts +0 -19
- package/dist/__tests__/audit-witness-real.test.d.ts.map +0 -1
- package/dist/__tests__/audit-witness-real.test.js +0 -82
- package/dist/__tests__/audit-witness-real.test.js.map +0 -1
- package/dist/__tests__/audit-witness.test.d.ts +0 -2
- package/dist/__tests__/audit-witness.test.d.ts.map +0 -1
- package/dist/__tests__/audit-witness.test.js +0 -308
- package/dist/__tests__/audit-witness.test.js.map +0 -1
- package/dist/__tests__/canonical.test.d.ts +0 -2
- package/dist/__tests__/canonical.test.d.ts.map +0 -1
- package/dist/__tests__/canonical.test.js +0 -162
- package/dist/__tests__/canonical.test.js.map +0 -1
- package/dist/__tests__/chain-hash-anchor.test.d.ts +0 -22
- package/dist/__tests__/chain-hash-anchor.test.d.ts.map +0 -1
- package/dist/__tests__/chain-hash-anchor.test.js +0 -55
- package/dist/__tests__/chain-hash-anchor.test.js.map +0 -1
- package/dist/__tests__/commit-service.integration.test.d.ts +0 -2
- package/dist/__tests__/commit-service.integration.test.d.ts.map +0 -1
- package/dist/__tests__/commit-service.integration.test.js +0 -95
- package/dist/__tests__/commit-service.integration.test.js.map +0 -1
- package/dist/__tests__/constructor.test.d.ts +0 -2
- package/dist/__tests__/constructor.test.d.ts.map +0 -1
- package/dist/__tests__/constructor.test.js +0 -267
- package/dist/__tests__/constructor.test.js.map +0 -1
- package/dist/__tests__/declared-proof-fixture.d.ts +0 -66
- package/dist/__tests__/declared-proof-fixture.d.ts.map +0 -1
- package/dist/__tests__/declared-proof-fixture.js +0 -66
- package/dist/__tests__/declared-proof-fixture.js.map +0 -1
- package/dist/__tests__/fuse-inline.test.d.ts +0 -2
- package/dist/__tests__/fuse-inline.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-inline.test.js +0 -181
- package/dist/__tests__/fuse-inline.test.js.map +0 -1
- package/dist/__tests__/fuse-placement.test.d.ts +0 -2
- package/dist/__tests__/fuse-placement.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-placement.test.js +0 -31
- package/dist/__tests__/fuse-placement.test.js.map +0 -1
- package/dist/__tests__/fuse-roundtrip.test.d.ts +0 -2
- package/dist/__tests__/fuse-roundtrip.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-roundtrip.test.js +0 -241
- package/dist/__tests__/fuse-roundtrip.test.js.map +0 -1
- package/dist/__tests__/fuse-sdk.test.d.ts +0 -2
- package/dist/__tests__/fuse-sdk.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-sdk.test.js +0 -117
- package/dist/__tests__/fuse-sdk.test.js.map +0 -1
- package/dist/__tests__/fuse-set-sdk.test.d.ts +0 -2
- package/dist/__tests__/fuse-set-sdk.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-set-sdk.test.js +0 -721
- package/dist/__tests__/fuse-set-sdk.test.js.map +0 -1
- package/dist/__tests__/fuse-set.test.d.ts +0 -2
- package/dist/__tests__/fuse-set.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-set.test.js +0 -889
- package/dist/__tests__/fuse-set.test.js.map +0 -1
- package/dist/__tests__/fuse-set2.test.d.ts +0 -2
- package/dist/__tests__/fuse-set2.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-set2.test.js +0 -294
- package/dist/__tests__/fuse-set2.test.js.map +0 -1
- package/dist/__tests__/fuse-vectors.test.d.ts +0 -2
- package/dist/__tests__/fuse-vectors.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-vectors.test.js +0 -175
- package/dist/__tests__/fuse-vectors.test.js.map +0 -1
- package/dist/__tests__/fuse-verify.test.d.ts +0 -2
- package/dist/__tests__/fuse-verify.test.d.ts.map +0 -1
- package/dist/__tests__/fuse-verify.test.js +0 -250
- package/dist/__tests__/fuse-verify.test.js.map +0 -1
- package/dist/__tests__/hello-world.test.d.ts +0 -2
- package/dist/__tests__/hello-world.test.d.ts.map +0 -1
- package/dist/__tests__/hello-world.test.js +0 -9
- package/dist/__tests__/hello-world.test.js.map +0 -1
- package/dist/__tests__/mock-proof-fixture.d.ts +0 -15
- package/dist/__tests__/mock-proof-fixture.d.ts.map +0 -1
- package/dist/__tests__/mock-proof-fixture.js +0 -34
- package/dist/__tests__/mock-proof-fixture.js.map +0 -1
- package/dist/__tests__/policy-enforcement.test.d.ts +0 -2
- package/dist/__tests__/policy-enforcement.test.d.ts.map +0 -1
- package/dist/__tests__/policy-enforcement.test.js +0 -188
- package/dist/__tests__/policy-enforcement.test.js.map +0 -1
- package/dist/__tests__/proof-hash-regression.test.d.ts +0 -2
- package/dist/__tests__/proof-hash-regression.test.d.ts.map +0 -1
- package/dist/__tests__/proof-hash-regression.test.js +0 -95
- package/dist/__tests__/proof-hash-regression.test.js.map +0 -1
- package/dist/__tests__/proof-hash.test.d.ts +0 -2
- package/dist/__tests__/proof-hash.test.d.ts.map +0 -1
- package/dist/__tests__/proof-hash.test.js +0 -116
- package/dist/__tests__/proof-hash.test.js.map +0 -1
- package/dist/__tests__/proof-integrity.test.d.ts +0 -2
- package/dist/__tests__/proof-integrity.test.d.ts.map +0 -1
- package/dist/__tests__/proof-integrity.test.js +0 -454
- package/dist/__tests__/proof-integrity.test.js.map +0 -1
- package/dist/__tests__/realistic-proof-fixture.d.ts +0 -56
- package/dist/__tests__/realistic-proof-fixture.d.ts.map +0 -1
- package/dist/__tests__/realistic-proof-fixture.js +0 -57
- package/dist/__tests__/realistic-proof-fixture.js.map +0 -1
- package/dist/__tests__/run.test.d.ts +0 -2
- package/dist/__tests__/run.test.d.ts.map +0 -1
- package/dist/__tests__/run.test.js +0 -178
- package/dist/__tests__/run.test.js.map +0 -1
- package/dist/__tests__/verifier.test.d.ts +0 -2
- package/dist/__tests__/verifier.test.d.ts.map +0 -1
- package/dist/__tests__/verifier.test.js +0 -531
- package/dist/__tests__/verifier.test.js.map +0 -1
- package/dist/canonical.d.ts +0 -54
- package/dist/canonical.d.ts.map +0 -1
- package/dist/canonical.js +0 -119
- package/dist/canonical.js.map +0 -1
- package/dist/proof-hash.d.ts +0 -9
- package/dist/proof-hash.d.ts.map +0 -1
- package/dist/proof-hash.js +0 -75
- package/dist/proof-hash.js.map +0 -1
- package/dist/types.d.ts +0 -705
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/verifier.d.ts +0 -27
- package/dist/verifier.d.ts.map +0 -1
- package/dist/verifier.js +0 -844
- package/dist/verifier.js.map +0 -1
- package/src/__tests__/audit-anchors.test.ts +0 -188
- package/src/__tests__/audit-anomalies.test.ts +0 -815
- package/src/__tests__/audit-attestation.test.ts +0 -529
- package/src/__tests__/audit-bench-smoke.test.ts +0 -108
- package/src/__tests__/audit-boundary.test.ts +0 -96
- package/src/__tests__/audit-cli.test.ts +0 -288
- package/src/__tests__/audit-dependencies.test.ts +0 -141
- package/src/__tests__/audit-fixtures.ts +0 -736
- package/src/__tests__/audit-ingest.test.ts +0 -575
- package/src/__tests__/audit-memory-ingest.test.ts +0 -156
- package/src/__tests__/audit-property.test.ts +0 -892
- package/src/__tests__/audit-real-fixtures.test.ts +0 -153
- package/src/__tests__/audit-real-live.test.ts +0 -128
- package/src/__tests__/audit-reconstruct.test.ts +0 -353
- package/src/__tests__/audit-report.test.ts +0 -222
- package/src/__tests__/audit-roundtrip.test.ts +0 -464
- package/src/__tests__/audit-temporal.test.ts +0 -446
- package/src/__tests__/audit-tiers.test.ts +0 -343
- package/src/__tests__/audit-witness-real.test.ts +0 -92
- package/src/__tests__/audit-witness.test.ts +0 -345
- package/src/__tests__/canonical.test.ts +0 -253
- package/src/__tests__/chain-hash-anchor.test.ts +0 -67
- package/src/__tests__/commit-service.integration.test.ts +0 -117
- package/src/__tests__/constructor.test.ts +0 -340
- package/src/__tests__/declared-proof-fixture.ts +0 -65
- package/src/__tests__/fuse-inline.test.ts +0 -211
- package/src/__tests__/fuse-placement.test.ts +0 -32
- package/src/__tests__/fuse-roundtrip.test.ts +0 -243
- package/src/__tests__/fuse-sdk.test.ts +0 -142
- package/src/__tests__/fuse-set-sdk.test.ts +0 -852
- package/src/__tests__/fuse-set.test.ts +0 -1027
- package/src/__tests__/fuse-set2.test.ts +0 -343
- package/src/__tests__/fuse-vectors.test.ts +0 -218
- package/src/__tests__/fuse-verify.test.ts +0 -278
- package/src/__tests__/hello-world.test.ts +0 -10
- package/src/__tests__/mock-proof-fixture.ts +0 -36
- package/src/__tests__/policy-enforcement.test.ts +0 -226
- package/src/__tests__/proof-hash-regression.test.ts +0 -107
- package/src/__tests__/proof-hash.test.ts +0 -129
- package/src/__tests__/proof-integrity.test.ts +0 -576
- package/src/__tests__/real-fixtures/anchor-after-112762.json +0 -47
- package/src/__tests__/real-fixtures/anchor-with-ethereum-112758.json +0 -47
- package/src/__tests__/real-fixtures/live-proof-0.json +0 -42
- package/src/__tests__/real-fixtures/live-proof-1.json +0 -43
- package/src/__tests__/real-fixtures/live-proof-2.json +0 -43
- package/src/__tests__/real-fixtures/successor-112760.json +0 -38
- package/src/__tests__/real-fixtures/witness-25525146.json +0 -6
- package/src/__tests__/real-fixtures/witness-25525147.json +0 -6
- package/src/__tests__/realistic-proof-fixture.ts +0 -57
- package/src/__tests__/verifier.test.ts +0 -624
package/dist/canonical.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Mike Argento. All rights reserved. See LICENSE.
|
|
2
|
-
/**
|
|
3
|
-
* bitgraph-core canonical serialization
|
|
4
|
-
*
|
|
5
|
-
* Produces a deterministic, UTF-8 encoded JSON byte sequence from an
|
|
6
|
-
* arbitrary JavaScript value. The output is used as the signing input
|
|
7
|
-
* for BitGraphProof signatures and must be reproduced identically by any
|
|
8
|
-
* verifier regardless of platform or runtime.
|
|
9
|
-
*
|
|
10
|
-
* Algorithm:
|
|
11
|
-
* 1. Recursively sort object keys lexicographically (Unicode code-point order)
|
|
12
|
-
* 2. Serialize with JSON.stringify (no whitespace)
|
|
13
|
-
* 3. Encode the resulting string as UTF-8
|
|
14
|
-
*
|
|
15
|
-
* Constraints satisfied:
|
|
16
|
-
* - Deterministic key ordering
|
|
17
|
-
* - No whitespace variance
|
|
18
|
-
* - Stable numeric formatting (JSON.stringify uses shortest representation)
|
|
19
|
-
* - UTF-8 output (TextEncoder default)
|
|
20
|
-
* - Rejects undefined, functions, and symbols, which have no JSON repr
|
|
21
|
-
*
|
|
22
|
-
* Limitations:
|
|
23
|
-
* - BigInt is not serializable via JSON.stringify; callers must convert
|
|
24
|
-
* to string before passing (consistent with the `counter` field type).
|
|
25
|
-
* - NaN and Infinity serialize as `null` in JSON; callers must validate
|
|
26
|
-
* numeric fields upstream.
|
|
27
|
-
* - Object prototype chains are not walked; only own enumerable keys.
|
|
28
|
-
*
|
|
29
|
-
* This module has zero dependencies on other bitgraph-core modules so that it
|
|
30
|
-
* can be used standalone for testing and external verification tooling.
|
|
31
|
-
*/
|
|
32
|
-
// ---------------------------------------------------------------------------
|
|
33
|
-
// Public API
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
/**
|
|
36
|
-
* Serialize `obj` to canonical JSON and return UTF-8 encoded bytes.
|
|
37
|
-
*
|
|
38
|
-
* Throws if `obj` contains values that cannot survive a JSON round-trip
|
|
39
|
-
* without information loss (undefined top-level, functions, symbols, BigInt).
|
|
40
|
-
*/
|
|
41
|
-
export function canonicalize(obj) {
|
|
42
|
-
const json = canonicalizeToString(obj);
|
|
43
|
-
return new TextEncoder().encode(json);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Serialize `obj` to a canonical JSON string.
|
|
47
|
-
* Exposed for debugging and test assertions.
|
|
48
|
-
*/
|
|
49
|
-
export function canonicalizeToString(obj) {
|
|
50
|
-
return JSON.stringify(sortedReplacer(obj));
|
|
51
|
-
}
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
// Internal helpers
|
|
54
|
-
// ---------------------------------------------------------------------------
|
|
55
|
-
/**
|
|
56
|
-
* Recursively produce a value suitable for JSON.stringify that has its
|
|
57
|
-
* object keys sorted lexicographically at every level of nesting.
|
|
58
|
-
*
|
|
59
|
-
* Arrays preserve element order (ordering arrays would change semantics).
|
|
60
|
-
* Primitives are returned as-is.
|
|
61
|
-
*/
|
|
62
|
-
function sortedReplacer(value) {
|
|
63
|
-
if (value === null || typeof value !== "object") {
|
|
64
|
-
// Primitive or null: no key ordering needed.
|
|
65
|
-
// Reject types that serialize to undefined in JSON.
|
|
66
|
-
if (typeof value === "undefined") {
|
|
67
|
-
throw new TypeError("bitgraph-core/canonical: undefined values are not serializable to canonical JSON");
|
|
68
|
-
}
|
|
69
|
-
if (typeof value === "function" || typeof value === "symbol") {
|
|
70
|
-
throw new TypeError(`bitgraph-core/canonical: ${typeof value} values are not serializable to canonical JSON`);
|
|
71
|
-
}
|
|
72
|
-
if (typeof value === "bigint") {
|
|
73
|
-
throw new TypeError("bitgraph-core/canonical: BigInt values are not serializable to canonical JSON; " +
|
|
74
|
-
"convert to string (decimal) before canonicalizing");
|
|
75
|
-
}
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
if (Array.isArray(value)) {
|
|
79
|
-
// Recurse into elements; preserve order.
|
|
80
|
-
return value.map(sortedReplacer);
|
|
81
|
-
}
|
|
82
|
-
// Plain object: sort own enumerable string keys and recurse.
|
|
83
|
-
const sorted = {};
|
|
84
|
-
for (const key of Object.keys(value).sort()) {
|
|
85
|
-
const child = value[key];
|
|
86
|
-
// Skip undefined values (JSON.stringify would omit them anyway,
|
|
87
|
-
// but we skip explicitly to avoid surprising iteration behavior).
|
|
88
|
-
if (typeof child === "undefined") {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
sorted[key] = sortedReplacer(child);
|
|
92
|
-
}
|
|
93
|
-
return sorted;
|
|
94
|
-
}
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// Utility: constant-time Uint8Array equality
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
/**
|
|
99
|
-
* Compare two Uint8Arrays in constant time.
|
|
100
|
-
*
|
|
101
|
-
* Returns true iff `a` and `b` have the same length and identical contents.
|
|
102
|
-
* Resistance against timing side-channels is important when comparing
|
|
103
|
-
* digests and signatures in the verifier.
|
|
104
|
-
*
|
|
105
|
-
* Note: JavaScript runtimes may still optimize this; a native binding would
|
|
106
|
-
* provide stronger guarantees. For v0.1 this is a reasonable best-effort.
|
|
107
|
-
*/
|
|
108
|
-
export function constantTimeEqual(a, b) {
|
|
109
|
-
if (a.length !== b.length) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
let diff = 0;
|
|
113
|
-
for (let i = 0; i < a.length; i++) {
|
|
114
|
-
// biome-ignore: non-null assertion safe because lengths are equal
|
|
115
|
-
diff |= a[i] ^ b[i];
|
|
116
|
-
}
|
|
117
|
-
return diff === 0;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=canonical.js.map
|
package/dist/canonical.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"canonical.js","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,YAAY,C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C,CAAC,GAAG,CAAC,CAAC;QACtD,gEAAgE;QAChE,kEAAkE;QAClE,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;YACjC,SAAS;QACX,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,8EAA8E;AAC9E,6CAA6C;AAC7C,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAa,EAAE,CAAa;IAC5D,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,kEAAkE;QAClE,IAAI,IAAK,CAAC,CAAC,CAAC,CAAY,GAAI,CAAC,CAAC,CAAC,CAAY,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/proof-hash.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { BitGraphProof } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Compute the canonical hash of a BitGraph proof's signed body.
|
|
4
|
-
*
|
|
5
|
-
* @param proof - The full BitGraphProof object (or equivalent Record)
|
|
6
|
-
* @returns Base64-standard encoded SHA-256 hash
|
|
7
|
-
*/
|
|
8
|
-
export declare function computeProofHash(proof: BitGraphProof | Record<string, unknown>): string;
|
|
9
|
-
//# sourceMappingURL=proof-hash.d.ts.map
|
package/dist/proof-hash.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proof-hash.d.ts","sourceRoot":"","sources":["../src/proof-hash.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAqCvF"}
|
package/dist/proof-hash.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Mike Argento. All rights reserved. See LICENSE.
|
|
2
|
-
/**
|
|
3
|
-
* bitgraph-core proof hash
|
|
4
|
-
*
|
|
5
|
-
* Canonical, deterministic proof hash computation.
|
|
6
|
-
*
|
|
7
|
-
* The proof hash covers the SIGNED BODY — the fields that are
|
|
8
|
-
* cryptographically signed by the enclave. This matches what the
|
|
9
|
-
* Ed25519 signature covers, making the hash verifiable.
|
|
10
|
-
*
|
|
11
|
-
* Signed body fields:
|
|
12
|
-
* - version, artifact, commit
|
|
13
|
-
* - publicKeyB64 (from signer)
|
|
14
|
-
* - enforcement, measurement (from environment)
|
|
15
|
-
* - attribution (if present)
|
|
16
|
-
* - attestationFormat (if attestation present)
|
|
17
|
-
*
|
|
18
|
-
* This hash is used for:
|
|
19
|
-
* - prevB64 chain linking
|
|
20
|
-
* - S3 ledger key generation
|
|
21
|
-
* - Ethereum anchor binding
|
|
22
|
-
* - Proof deduplication and verification
|
|
23
|
-
*
|
|
24
|
-
* Algorithm:
|
|
25
|
-
* 1. Extract signed body fields
|
|
26
|
-
* 2. canonicalize(signedBody) — recursive key sort, compact JSON, UTF-8
|
|
27
|
-
* 3. SHA-256 of canonical bytes
|
|
28
|
-
* 4. Base64-standard encode (RFC 4648 §4)
|
|
29
|
-
*
|
|
30
|
-
* IMPORTANT: All call sites MUST use this function. Do NOT compute
|
|
31
|
-
* proof hashes ad-hoc with JSON.stringify or Object.keys().sort().
|
|
32
|
-
* Non-recursive key sorting diverges on nested objects.
|
|
33
|
-
*/
|
|
34
|
-
import { canonicalize } from "./canonical.js";
|
|
35
|
-
import { sha256 } from "@noble/hashes/sha256";
|
|
36
|
-
/**
|
|
37
|
-
* Compute the canonical hash of a BitGraph proof's signed body.
|
|
38
|
-
*
|
|
39
|
-
* @param proof - The full BitGraphProof object (or equivalent Record)
|
|
40
|
-
* @returns Base64-standard encoded SHA-256 hash
|
|
41
|
-
*/
|
|
42
|
-
export function computeProofHash(proof) {
|
|
43
|
-
const p = proof;
|
|
44
|
-
const signer = p.signer;
|
|
45
|
-
const env = p.environment;
|
|
46
|
-
const signedBody = {
|
|
47
|
-
version: p.version,
|
|
48
|
-
artifact: p.artifact,
|
|
49
|
-
commit: p.commit,
|
|
50
|
-
publicKeyB64: signer?.publicKeyB64,
|
|
51
|
-
enforcement: env?.enforcement,
|
|
52
|
-
measurement: env?.measurement,
|
|
53
|
-
};
|
|
54
|
-
// Include attribution if present
|
|
55
|
-
if (p.attribution) {
|
|
56
|
-
signedBody.attribution = p.attribution;
|
|
57
|
-
}
|
|
58
|
-
// Include attestation format if present
|
|
59
|
-
if (env?.attestation) {
|
|
60
|
-
signedBody.attestationFormat = env.attestation.format;
|
|
61
|
-
}
|
|
62
|
-
const bytes = canonicalize(signedBody);
|
|
63
|
-
const hash = sha256(bytes);
|
|
64
|
-
// Base64 encode (works in both Node.js and browser)
|
|
65
|
-
if (typeof Buffer !== "undefined") {
|
|
66
|
-
return Buffer.from(hash).toString("base64");
|
|
67
|
-
}
|
|
68
|
-
// Browser fallback
|
|
69
|
-
let binary = "";
|
|
70
|
-
for (let i = 0; i < hash.length; i++) {
|
|
71
|
-
binary += String.fromCharCode(hash[i]);
|
|
72
|
-
}
|
|
73
|
-
return btoa(binary);
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=proof-hash.js.map
|
package/dist/proof-hash.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proof-hash.js","sourceRoot":"","sources":["../src/proof-hash.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;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