@cello-protocol/protocol-types 0.0.66 → 0.0.68
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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/structure1.d.ts +92 -3
- package/dist/structure1.d.ts.map +1 -1
- package/dist/structure1.js +158 -13
- package/dist/structure1.js.map +1 -1
- package/package.json +2 -2
- package/test/vectors/structure1-v2-canonical.json +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export { SUBMISSION_DOMAIN, buildSubmissionTbs, encodeSubmission, decodeSubmissi
|
|
|
5
5
|
export type { SubmissionBody, SubmissionOp, SignedSubmission } from "./submission.js";
|
|
6
6
|
export type { MessageEnvelope, MessageEnvelopeV1, EnvelopeError, BuildResult, BuildResultV1, ValidateResult, ValidateResultV1, DeserializeResult, DeserializeResultV1, } from "./types.js";
|
|
7
7
|
export { MAX_CONTENT_BYTES } from "./limits.js";
|
|
8
|
-
export { encodeStructure1, STRUCTURE1_VERSION } from "./structure1.js";
|
|
8
|
+
export { encodeStructure1, decodeStructure1, STRUCTURE1_VERSION, STRUCTURE1_VERSION_V2, LAST_SEEN_HASH_BYTES, STRUCTURE1_DECODE_REASONS, } from "./structure1.js";
|
|
9
|
+
export type { Structure1Fields, Structure1DecodeResult, Structure1DecodeReason, } from "./structure1.js";
|
|
9
10
|
export type { ScanResultSentinel, Structure2, BuildStructure2Result } from "./structure2.js";
|
|
10
11
|
export { SCAN_RESULT_SENTINEL, buildStructure2, encodeStructure2, encodeScanResultSentinel, verifyStructure2Signature, } from "./structure2.js";
|
|
11
12
|
export { computeGenesisPrevRoot, encodeSealPayload, decodeSealPayload, buildSessionEstablishmentTbs, buildSealTbs, SEAL_RECEIPT_DISCLAIMER } from "./session.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAKnD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEtF,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAKnD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEtF,YAAY,EAC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AChC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,mCAAmC,EACnC,4BAA4B,EAC5B,6BAA6B,EAC7B,kCAAkC,GACnC,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { TRUST_SIGNAL_DOMAIN, encodeTrustSignalEnvelope, decodeTrustSignalEnvelo
|
|
|
8
8
|
// local copy on each side is how two implementations drift into disagreeing (M10B-D28).
|
|
9
9
|
export { SUBMISSION_DOMAIN, buildSubmissionTbs, encodeSubmission, decodeSubmission, submissionId, } from "./submission.js";
|
|
10
10
|
export { MAX_CONTENT_BYTES } from "./limits.js";
|
|
11
|
-
export { encodeStructure1, STRUCTURE1_VERSION } from "./structure1.js";
|
|
11
|
+
export { encodeStructure1, decodeStructure1, STRUCTURE1_VERSION, STRUCTURE1_VERSION_V2, LAST_SEEN_HASH_BYTES, STRUCTURE1_DECODE_REASONS, } from "./structure1.js";
|
|
12
12
|
export { SCAN_RESULT_SENTINEL, buildStructure2, encodeStructure2, encodeScanResultSentinel, verifyStructure2Signature, } from "./structure2.js";
|
|
13
13
|
export { computeGenesisPrevRoot, encodeSealPayload, decodeSealPayload, buildSessionEstablishmentTbs, buildSealTbs, SEAL_RECEIPT_DISCLAIMER } from "./session.js";
|
|
14
14
|
export { MAX_PSEUDONYM_LABEL_BYTES, ML_DSA_PUBKEY_BYTES, ML_DSA_SIGNATURE_BYTES, buildPseudonymBinding, verifyPseudonymBinding, verifyEndorsement, verifyAttestation, validateConnectionPackage, encodeConnectionPackage, decodeConnectionPackage, } from "./connection-package.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,8FAA8F;AAC9F,wFAAwF;AACxF,2BAA2B;AAC3B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAO3B,+FAA+F;AAC/F,qGAAqG;AACrG,wFAAwF;AACxF,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAezB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,8FAA8F;AAC9F,wFAAwF;AACxF,2BAA2B;AAC3B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAO3B,+FAA+F;AAC/F,qGAAqG;AACrG,wFAAwF;AACxF,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAezB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,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B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mCAAmC,EACnC,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,mCAAmC,EACnC,4BAA4B,EAC5B,6BAA6B,EAC7B,kCAAkC,GACnC,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,kCAAkC,CAAC"}
|
package/dist/structure1.d.ts
CHANGED
|
@@ -1,10 +1,87 @@
|
|
|
1
1
|
/** The Structure 1 version tag. Bound as the FIRST field, so a v1 claim can never read as a v2 one. */
|
|
2
2
|
export declare const STRUCTURE1_VERSION = 1;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* v2 — `last_seen_hash` APPENDED at index 6 (`DOD-M15-WITHHOLD-SEAL-1`).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* `last_seen_seq` is a NUMBER, so "I saw position 7" attests to a POSITION and never to CONTENT.
|
|
7
|
+
* `last_seen_hash` binds the acknowledgement to what was actually received. It ADDS: `last_seen_seq`
|
|
8
|
+
* stays and keeps doing ordering and dedup work.
|
|
9
|
+
*/
|
|
10
|
+
export declare const STRUCTURE1_VERSION_V2 = 2;
|
|
11
|
+
/** `last_seen_hash` is a SHA-256 root — always exactly 32 bytes, never a prefix and never empty. */
|
|
12
|
+
export declare const LAST_SEEN_HASH_BYTES = 32;
|
|
13
|
+
/**
|
|
14
|
+
* ⚠️ INDEX 6 IS ALREADY SPOKEN FOR, WHICH IS WHY THE VERSION DECIDES AND NOT THE LENGTH.
|
|
15
|
+
*
|
|
16
|
+
* `DOD-M15-SUBMIT-ID-1` widened the relay to accept a SIX OR SEVEN field Structure 1, reserving
|
|
17
|
+
* index 6 for a sender-minted submission id, and shipped that tolerance ahead of any emitter. So a
|
|
18
|
+
* seven-field array has two possible meanings and `arr.length` cannot tell them apart:
|
|
19
|
+
*
|
|
20
|
+
* length 7 && version 1 ⇒ the pre-existing submission-id layout (index 6 is NOT an ack hash)
|
|
21
|
+
* length 7 && version 2 ⇒ the ack-hash layout
|
|
22
|
+
* anything else ⇒ refused BY NAME, never coerced
|
|
23
|
+
*
|
|
24
|
+
* A reader that silently admits an unrecognised length is not tolerant, it is fail-open: it would
|
|
25
|
+
* verify a signature over bytes whose meaning is not agreed.
|
|
26
|
+
*/
|
|
27
|
+
export declare const STRUCTURE1_DECODE_REASONS: {
|
|
28
|
+
/** The bytes are not CBOR at all. */
|
|
29
|
+
readonly NOT_CBOR: "structure1_not_cbor";
|
|
30
|
+
/** Valid CBOR, but not the positional array every Structure 1 is. */
|
|
31
|
+
readonly NOT_ARRAY: "structure1_not_array";
|
|
32
|
+
/** A (version, length) pair this build cannot name — including a v2 that omits `last_seen_hash`. */
|
|
33
|
+
readonly UNKNOWN_LAYOUT: "structure1_unknown_layout";
|
|
34
|
+
/** A field at one of the unchanged indices 1–5 is the wrong type or the wrong width. */
|
|
35
|
+
readonly FIELD_MALFORMED: "structure1_field_malformed";
|
|
36
|
+
/** A v2 carried `last_seen_hash`, and it was not 32 bytes. Present-but-wrong, never dropped. */
|
|
37
|
+
readonly LAST_SEEN_HASH_MALFORMED: "structure1_last_seen_hash_malformed";
|
|
38
|
+
};
|
|
39
|
+
export type Structure1DecodeReason = (typeof STRUCTURE1_DECODE_REASONS)[keyof typeof STRUCTURE1_DECODE_REASONS];
|
|
40
|
+
export interface Structure1Fields {
|
|
41
|
+
version: number;
|
|
42
|
+
contentHash: Uint8Array;
|
|
43
|
+
senderPubkey: Uint8Array;
|
|
44
|
+
sessionId: Uint8Array;
|
|
45
|
+
lastSeenSeq: number;
|
|
46
|
+
/**
|
|
47
|
+
* `number` for a legacy float64 leaf, `bigint` for the canonical uint64 form. Never re-encoded on
|
|
48
|
+
* a verification path — the signature is over the bytes as received, so both are carried as read.
|
|
49
|
+
*/
|
|
50
|
+
timestamp: number | bigint;
|
|
51
|
+
/**
|
|
52
|
+
* The 32 bytes on a v2 claim; `null` on any v1 claim, INCLUDING a v1 seven-array whose index 6 is
|
|
53
|
+
* a submission id. `null` means "this layout carries no ack hash", never "the hash was missing" —
|
|
54
|
+
* a v2 that omits the field is refused as UNKNOWN_LAYOUT and never reaches here.
|
|
55
|
+
*/
|
|
56
|
+
lastSeenHash: Uint8Array | null;
|
|
57
|
+
}
|
|
58
|
+
export type Structure1DecodeResult = {
|
|
59
|
+
ok: true;
|
|
60
|
+
fields: Structure1Fields;
|
|
61
|
+
} | {
|
|
62
|
+
ok: false;
|
|
63
|
+
reason: Structure1DecodeReason;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Canonical Structure 1 bytes.
|
|
67
|
+
*
|
|
68
|
+
* v1: [1, content_hash(32), sender_pubkey(32), session_id(16), last_seen_seq, timestamp]
|
|
69
|
+
* v2: [2, content_hash(32), sender_pubkey(32), session_id(16), last_seen_seq, timestamp,
|
|
70
|
+
* last_seen_hash(32)]
|
|
71
|
+
*
|
|
72
|
+
* `lastSeenHash` ABSENT ⇒ v1, six fields, byte-identical to the pinned v1 vector. PRESENT ⇒ v2.
|
|
73
|
+
* The version tag is what disambiguates, so the two can never be confused by a reader.
|
|
74
|
+
*
|
|
75
|
+
* ⚠️ `last_seen_hash` IS A VALUE, NEVER AN ABSENCE. The first message of a session has seen nothing,
|
|
76
|
+
* and that case is a defined 32-byte value: `computeGenesisPrevRoot` for the session — the agreed
|
|
77
|
+
* starting point of this two-party chain. Not 32 zero bytes, which would be a constant identical
|
|
78
|
+
* across every session and therefore presentable for any of them; and not a shorter array, which is
|
|
79
|
+
* refused. A caller that has no hash to send sends v1, and a v1 claim makes no content assertion at
|
|
80
|
+
* all — which is honest — rather than an empty one that reads as satisfied.
|
|
81
|
+
*
|
|
82
|
+
* A timestamp above 2^32-1 is encoded as a CBOR bigint — a plain number encodes as a float64, and
|
|
83
|
+
* two implementations that disagree about which one they emit produce different signed bytes for
|
|
84
|
+
* the same value. Same promotion as `buildSessionEstablishmentTbs`.
|
|
8
85
|
*/
|
|
9
86
|
export declare function encodeStructure1(fields: {
|
|
10
87
|
contentHash: Uint8Array;
|
|
@@ -12,5 +89,17 @@ export declare function encodeStructure1(fields: {
|
|
|
12
89
|
sessionId: Uint8Array;
|
|
13
90
|
lastSeenSeq: number;
|
|
14
91
|
timestamp: number;
|
|
92
|
+
lastSeenHash?: Uint8Array;
|
|
15
93
|
}): Uint8Array;
|
|
94
|
+
/**
|
|
95
|
+
* Read a Structure 1 claim, branching on the VERSION at index 0 — never on the array length (see
|
|
96
|
+
* `STRUCTURE1_DECODE_REASONS` for why the two are not interchangeable).
|
|
97
|
+
*
|
|
98
|
+
* Exported because the readers across both repos each hand-rolled their own positional
|
|
99
|
+
* destructuring, and the next layout change should not have to find them again.
|
|
100
|
+
*
|
|
101
|
+
* Never throws: these bytes arrive off a wire, and a decode failure is a named refusal to report,
|
|
102
|
+
* not an exception escaping into a stream handler.
|
|
103
|
+
*/
|
|
104
|
+
export declare function decodeStructure1(cbor: Uint8Array): Structure1DecodeResult;
|
|
16
105
|
//# sourceMappingURL=structure1.d.ts.map
|
package/dist/structure1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure1.d.ts","sourceRoot":"","sources":["../src/structure1.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"structure1.d.ts","sourceRoot":"","sources":["../src/structure1.ts"],"names":[],"mappings":"AAeA,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,oGAAoG;AACpG,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB;IACpC,qCAAqC;;IAErC,qEAAqE;;IAErE,oGAAoG;;IAEpG,wFAAwF;;IAExF,gGAAgG;;CAExF,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,OAAO,yBAAyB,CAAC,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B;;;;OAIG;IACH,YAAY,EAAE,UAAU,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,MAAM,sBAAsB,GAC9B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GACtC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,UAAU,CAAC;CAC3B,GAAG,UAAU,CAyBb;AASD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,sBAAsB,CAiEzE"}
|
package/dist/structure1.js
CHANGED
|
@@ -1,33 +1,178 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Structure 1 — the sender's signed ordering claim, canonical CBOR.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* THE ONE BUILDER AND THE ONE READER. The daemon kept a second, positional `encodeStructure1` in
|
|
5
|
+
* `session-relay-client.ts` until 020-ACKHASH; the two were maintained separately and only a
|
|
6
|
+
* convention kept them equal. It had already broken — the copy emitted a timestamp above 2^32-1 as
|
|
7
|
+
* a CBOR float64 where this one promotes to uint64 — so the vector below was pinning bytes
|
|
8
|
+
* production never emitted. Import this; never write a third.
|
|
9
9
|
*
|
|
10
10
|
* Field order is LOAD-BEARING: it is signed over. Reorder a field and signatures produced by any
|
|
11
|
-
* other implementation stop verifying against ours.
|
|
11
|
+
* other implementation stop verifying against ours. `structure1-canonical.json` and
|
|
12
|
+
* `structure1-v2-canonical.json` pin the resulting bytes for each version.
|
|
12
13
|
*/
|
|
13
|
-
import { encodeCbor } from "./cbor.js";
|
|
14
|
+
import { encodeCbor, decodeCbor } from "./cbor.js";
|
|
14
15
|
/** The Structure 1 version tag. Bound as the FIRST field, so a v1 claim can never read as a v2 one. */
|
|
15
16
|
export const STRUCTURE1_VERSION = 1;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* v2 — `last_seen_hash` APPENDED at index 6 (`DOD-M15-WITHHOLD-SEAL-1`).
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* `last_seen_seq` is a NUMBER, so "I saw position 7" attests to a POSITION and never to CONTENT.
|
|
21
|
+
* `last_seen_hash` binds the acknowledgement to what was actually received. It ADDS: `last_seen_seq`
|
|
22
|
+
* stays and keeps doing ordering and dedup work.
|
|
23
|
+
*/
|
|
24
|
+
export const STRUCTURE1_VERSION_V2 = 2;
|
|
25
|
+
/** `last_seen_hash` is a SHA-256 root — always exactly 32 bytes, never a prefix and never empty. */
|
|
26
|
+
export const LAST_SEEN_HASH_BYTES = 32;
|
|
27
|
+
/**
|
|
28
|
+
* ⚠️ INDEX 6 IS ALREADY SPOKEN FOR, WHICH IS WHY THE VERSION DECIDES AND NOT THE LENGTH.
|
|
29
|
+
*
|
|
30
|
+
* `DOD-M15-SUBMIT-ID-1` widened the relay to accept a SIX OR SEVEN field Structure 1, reserving
|
|
31
|
+
* index 6 for a sender-minted submission id, and shipped that tolerance ahead of any emitter. So a
|
|
32
|
+
* seven-field array has two possible meanings and `arr.length` cannot tell them apart:
|
|
33
|
+
*
|
|
34
|
+
* length 7 && version 1 ⇒ the pre-existing submission-id layout (index 6 is NOT an ack hash)
|
|
35
|
+
* length 7 && version 2 ⇒ the ack-hash layout
|
|
36
|
+
* anything else ⇒ refused BY NAME, never coerced
|
|
37
|
+
*
|
|
38
|
+
* A reader that silently admits an unrecognised length is not tolerant, it is fail-open: it would
|
|
39
|
+
* verify a signature over bytes whose meaning is not agreed.
|
|
40
|
+
*/
|
|
41
|
+
export const STRUCTURE1_DECODE_REASONS = {
|
|
42
|
+
/** The bytes are not CBOR at all. */
|
|
43
|
+
NOT_CBOR: "structure1_not_cbor",
|
|
44
|
+
/** Valid CBOR, but not the positional array every Structure 1 is. */
|
|
45
|
+
NOT_ARRAY: "structure1_not_array",
|
|
46
|
+
/** A (version, length) pair this build cannot name — including a v2 that omits `last_seen_hash`. */
|
|
47
|
+
UNKNOWN_LAYOUT: "structure1_unknown_layout",
|
|
48
|
+
/** A field at one of the unchanged indices 1–5 is the wrong type or the wrong width. */
|
|
49
|
+
FIELD_MALFORMED: "structure1_field_malformed",
|
|
50
|
+
/** A v2 carried `last_seen_hash`, and it was not 32 bytes. Present-but-wrong, never dropped. */
|
|
51
|
+
LAST_SEEN_HASH_MALFORMED: "structure1_last_seen_hash_malformed",
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Canonical Structure 1 bytes.
|
|
55
|
+
*
|
|
56
|
+
* v1: [1, content_hash(32), sender_pubkey(32), session_id(16), last_seen_seq, timestamp]
|
|
57
|
+
* v2: [2, content_hash(32), sender_pubkey(32), session_id(16), last_seen_seq, timestamp,
|
|
58
|
+
* last_seen_hash(32)]
|
|
59
|
+
*
|
|
60
|
+
* `lastSeenHash` ABSENT ⇒ v1, six fields, byte-identical to the pinned v1 vector. PRESENT ⇒ v2.
|
|
61
|
+
* The version tag is what disambiguates, so the two can never be confused by a reader.
|
|
62
|
+
*
|
|
63
|
+
* ⚠️ `last_seen_hash` IS A VALUE, NEVER AN ABSENCE. The first message of a session has seen nothing,
|
|
64
|
+
* and that case is a defined 32-byte value: `computeGenesisPrevRoot` for the session — the agreed
|
|
65
|
+
* starting point of this two-party chain. Not 32 zero bytes, which would be a constant identical
|
|
66
|
+
* across every session and therefore presentable for any of them; and not a shorter array, which is
|
|
67
|
+
* refused. A caller that has no hash to send sends v1, and a v1 claim makes no content assertion at
|
|
68
|
+
* all — which is honest — rather than an empty one that reads as satisfied.
|
|
69
|
+
*
|
|
70
|
+
* A timestamp above 2^32-1 is encoded as a CBOR bigint — a plain number encodes as a float64, and
|
|
71
|
+
* two implementations that disagree about which one they emit produce different signed bytes for
|
|
72
|
+
* the same value. Same promotion as `buildSessionEstablishmentTbs`.
|
|
21
73
|
*/
|
|
22
74
|
export function encodeStructure1(fields) {
|
|
23
75
|
const ts = fields.timestamp > 0xffffffff ? BigInt(fields.timestamp) : fields.timestamp;
|
|
24
|
-
|
|
25
|
-
STRUCTURE1_VERSION,
|
|
76
|
+
const head = [
|
|
26
77
|
fields.contentHash,
|
|
27
78
|
fields.senderPubkey,
|
|
28
79
|
fields.sessionId,
|
|
29
80
|
fields.lastSeenSeq,
|
|
30
81
|
ts,
|
|
31
|
-
]
|
|
82
|
+
];
|
|
83
|
+
// Branch on the VALUE, not on `"lastSeenHash" in fields`: an explicit `undefined` must encode as
|
|
84
|
+
// v1, not as a seven-field array whose index 6 is CBOR undefined — a v2 claim with no hash in it.
|
|
85
|
+
if (fields.lastSeenHash === undefined) {
|
|
86
|
+
return encodeCbor([STRUCTURE1_VERSION, ...head]);
|
|
87
|
+
}
|
|
88
|
+
if (fields.lastSeenHash.length !== LAST_SEEN_HASH_BYTES) {
|
|
89
|
+
// Thrown, not silently downgraded to v1. A caller that meant to acknowledge content and cannot
|
|
90
|
+
// must find out here, at the last point before these bytes are signed — a signature over a v2
|
|
91
|
+
// nobody accepts is worse than a refusal, and a silent drop to v1 is the downgrade this layout
|
|
92
|
+
// exists to close.
|
|
93
|
+
throw new Error(`structure1: last_seen_hash must be ${LAST_SEEN_HASH_BYTES} bytes, got ${fields.lastSeenHash.length}`);
|
|
94
|
+
}
|
|
95
|
+
return encodeCbor([STRUCTURE1_VERSION_V2, ...head, fields.lastSeenHash]);
|
|
96
|
+
}
|
|
97
|
+
/** Bytes at `i` of exactly `len`, tolerating a Buffer from a decoder that produced one. */
|
|
98
|
+
function bytesAt(arr, i, len) {
|
|
99
|
+
const v = arr[i];
|
|
100
|
+
const b = v instanceof Uint8Array ? v : Buffer.isBuffer(v) ? new Uint8Array(v) : null;
|
|
101
|
+
return b !== null && b.length === len ? b : null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Read a Structure 1 claim, branching on the VERSION at index 0 — never on the array length (see
|
|
105
|
+
* `STRUCTURE1_DECODE_REASONS` for why the two are not interchangeable).
|
|
106
|
+
*
|
|
107
|
+
* Exported because the readers across both repos each hand-rolled their own positional
|
|
108
|
+
* destructuring, and the next layout change should not have to find them again.
|
|
109
|
+
*
|
|
110
|
+
* Never throws: these bytes arrive off a wire, and a decode failure is a named refusal to report,
|
|
111
|
+
* not an exception escaping into a stream handler.
|
|
112
|
+
*/
|
|
113
|
+
export function decodeStructure1(cbor) {
|
|
114
|
+
let arr;
|
|
115
|
+
try {
|
|
116
|
+
arr = decodeCbor(cbor);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return { ok: false, reason: STRUCTURE1_DECODE_REASONS.NOT_CBOR };
|
|
120
|
+
}
|
|
121
|
+
if (!Array.isArray(arr))
|
|
122
|
+
return { ok: false, reason: STRUCTURE1_DECODE_REASONS.NOT_ARRAY };
|
|
123
|
+
const version = arr[0];
|
|
124
|
+
const isV1 = version === STRUCTURE1_VERSION && (arr.length === 6 || arr.length === 7);
|
|
125
|
+
const isV2 = version === STRUCTURE1_VERSION_V2 && arr.length === 7;
|
|
126
|
+
if (!isV1 && !isV2)
|
|
127
|
+
return { ok: false, reason: STRUCTURE1_DECODE_REASONS.UNKNOWN_LAYOUT };
|
|
128
|
+
const contentHash = bytesAt(arr, 1, 32);
|
|
129
|
+
const senderPubkey = bytesAt(arr, 2, 32);
|
|
130
|
+
/**
|
|
131
|
+
* SESSION ID: THE WIDTH IS NOT CHECKED HERE, AND THAT IS DELIBERATE.
|
|
132
|
+
*
|
|
133
|
+
* The wire contract is 16 bytes, and it is enforced where peer-supplied bytes arrive — the relay's
|
|
134
|
+
* and the directory's own decoders each refuse anything else, and both keep doing so. This decoder
|
|
135
|
+
* also reads leaves THIS daemon just produced, and it must not newly refuse a leaf it accepted
|
|
136
|
+
* before: no client-side reader ever checked this width, and requiring it here would turn a
|
|
137
|
+
* layout reader into a second, quieter place that can reject a session.
|
|
138
|
+
*
|
|
139
|
+
* Each consumer is safe for one of two reasons, and it is worth naming both rather than claiming
|
|
140
|
+
* the stronger one for all of them. `seal-frontier-verify` COMPARES the value against an expected
|
|
141
|
+
* session id, so a wrong width fails exactly as a wrong value does. `#captureReceipt`
|
|
142
|
+
* (`session-relay-client.ts`) does NOT compare it — it hexes the value straight into the
|
|
143
|
+
* `relay_ack_receipts` primary key — and is safe instead because those bytes are
|
|
144
|
+
* `#pendingStructure1`, which this daemon produced and signed moments earlier.
|
|
145
|
+
*
|
|
146
|
+
* An earlier version of this comment said every consumer compares it. That was false for
|
|
147
|
+
* `#captureReceipt`, and a comment asserting a safety property the code does not have is how
|
|
148
|
+
* defects survive review in this repo — so it is corrected here rather than deleted.
|
|
149
|
+
*/
|
|
150
|
+
const sessionId = arr[3] instanceof Uint8Array
|
|
151
|
+
? arr[3]
|
|
152
|
+
: Buffer.isBuffer(arr[3]) ? new Uint8Array(arr[3]) : null;
|
|
153
|
+
const lastSeenSeq = arr[4];
|
|
154
|
+
const timestamp = arr[5];
|
|
155
|
+
if (contentHash === null || senderPubkey === null || sessionId === null) {
|
|
156
|
+
return { ok: false, reason: STRUCTURE1_DECODE_REASONS.FIELD_MALFORMED };
|
|
157
|
+
}
|
|
158
|
+
if (typeof lastSeenSeq !== "number") {
|
|
159
|
+
return { ok: false, reason: STRUCTURE1_DECODE_REASONS.FIELD_MALFORMED };
|
|
160
|
+
}
|
|
161
|
+
if (typeof timestamp !== "number" && typeof timestamp !== "bigint") {
|
|
162
|
+
return { ok: false, reason: STRUCTURE1_DECODE_REASONS.FIELD_MALFORMED };
|
|
163
|
+
}
|
|
164
|
+
// A v1 seven-array's index 6 is a SUBMISSION ID and is not read here — it is the relay's concern,
|
|
165
|
+
// and reading it as an ack hash is exactly the confusion the version tag prevents.
|
|
166
|
+
let lastSeenHash = null;
|
|
167
|
+
if (isV2) {
|
|
168
|
+
lastSeenHash = bytesAt(arr, 6, LAST_SEEN_HASH_BYTES);
|
|
169
|
+
if (lastSeenHash === null) {
|
|
170
|
+
return { ok: false, reason: STRUCTURE1_DECODE_REASONS.LAST_SEEN_HASH_MALFORMED };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
ok: true,
|
|
175
|
+
fields: { version, contentHash, senderPubkey, sessionId, lastSeenSeq, timestamp, lastSeenHash },
|
|
176
|
+
};
|
|
32
177
|
}
|
|
33
178
|
//# sourceMappingURL=structure1.js.map
|
package/dist/structure1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure1.js","sourceRoot":"","sources":["../src/structure1.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"structure1.js","sourceRoot":"","sources":["../src/structure1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,uGAAuG;AACvG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,oGAAoG;AACpG,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,qCAAqC;IACrC,QAAQ,EAAE,qBAAqB;IAC/B,qEAAqE;IACrE,SAAS,EAAE,sBAAsB;IACjC,oGAAoG;IACpG,cAAc,EAAE,2BAA2B;IAC3C,wFAAwF;IACxF,eAAe,EAAE,4BAA4B;IAC7C,gGAAgG;IAChG,wBAAwB,EAAE,qCAAqC;CACvD,CAAC;AA4BX;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAOhC;IACC,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,C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.68",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"cbor-x": "^1.6.4",
|
|
29
|
-
"@cello-protocol/crypto": "0.0.
|
|
29
|
+
"@cello-protocol/crypto": "0.0.64"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@claude-flow/testing": "3.0.0-alpha.6",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "020-ACKHASH: Structure 1 v2 canonical CBOR fixture — last_seen_hash appended at index 6. RFC 8949 §4.2.1.",
|
|
3
|
+
"_note": "Canonical CBOR of the 7-element positional TBS array for protocol_version=2. Inputs 1-5 are byte-for-byte the ones in structure1-canonical.json, so the two files together prove the field is APPENDED and no existing index moved: strip the leading '8702' and the trailing 32-byte hash from this hex and the remainder is the v1 hex after its leading '8601'.",
|
|
4
|
+
"inputs": {
|
|
5
|
+
"protocol_version": 2,
|
|
6
|
+
"content_hash_hex": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
|
7
|
+
"sender_pubkey_hex": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
|
|
8
|
+
"session_id_hex": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
9
|
+
"last_seen_seq": 3,
|
|
10
|
+
"timestamp": 1700000000000,
|
|
11
|
+
"last_seen_hash_hex": "a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7"
|
|
12
|
+
},
|
|
13
|
+
"expected_cbor_hex": "87025820cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc5820dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd50eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee031b0000018bcfe568005820a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7"
|
|
14
|
+
}
|