@mcsherrylabs/evolver-client 0.8.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/LICENSE +202 -0
- package/README.md +42 -0
- package/dist/api.d.ts +172 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +508 -0
- package/dist/api.js.map +1 -0
- package/dist/bodies.d.ts +86 -0
- package/dist/bodies.d.ts.map +1 -0
- package/dist/bodies.js +145 -0
- package/dist/bodies.js.map +1 -0
- package/dist/crypto/auth.d.ts +25 -0
- package/dist/crypto/auth.d.ts.map +1 -0
- package/dist/crypto/auth.js +71 -0
- package/dist/crypto/auth.js.map +1 -0
- package/dist/crypto/canonical.d.ts +21 -0
- package/dist/crypto/canonical.d.ts.map +1 -0
- package/dist/crypto/canonical.js +68 -0
- package/dist/crypto/canonical.js.map +1 -0
- package/dist/crypto/group.d.ts +29 -0
- package/dist/crypto/group.d.ts.map +1 -0
- package/dist/crypto/group.js +107 -0
- package/dist/crypto/group.js.map +1 -0
- package/dist/crypto/hash.d.ts +7 -0
- package/dist/crypto/hash.d.ts.map +1 -0
- package/dist/crypto/hash.js +34 -0
- package/dist/crypto/hash.js.map +1 -0
- package/dist/crypto/stream.d.ts +27 -0
- package/dist/crypto/stream.d.ts.map +1 -0
- package/dist/crypto/stream.js +186 -0
- package/dist/crypto/stream.js.map +1 -0
- package/dist/envelope.d.ts +28 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +68 -0
- package/dist/envelope.js.map +1 -0
- package/dist/generated/codecs.d.ts +145 -0
- package/dist/generated/codecs.d.ts.map +1 -0
- package/dist/generated/codecs.js +240 -0
- package/dist/generated/codecs.js.map +1 -0
- package/dist/identity.d.ts +17 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +52 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/signers.d.ts +52 -0
- package/dist/signers.d.ts.map +1 -0
- package/dist/signers.js +75 -0
- package/dist/signers.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +44 -0
- package/dist/types.js.map +1 -0
- package/dist/wire.d.ts +13 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +71 -0
- package/dist/wire.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Attachment envelope v2 — segmented AEAD (STREAM-style AES-256-GCM).
|
|
2
|
+
// Normative format: specs/143-content-streaming/contracts/attachment-envelope-v2.md.
|
|
3
|
+
//
|
|
4
|
+
// blob := header(16) ‖ noncePrefix(7) ‖ segment*
|
|
5
|
+
// header := "EVAT2" ‖ 0x02 ‖ segBytes u32BE ‖ zeros(6)
|
|
6
|
+
// seg[i] := AES-256-GCM(key, iv(i), aad = header‖noncePrefix, P[i]) ‖ tag(16)
|
|
7
|
+
// iv(i) := noncePrefix ‖ i u32BE ‖ lastFlag(0x00|0x01)
|
|
8
|
+
//
|
|
9
|
+
// Both transforms buffer at most one segment (+tag) — memory is size-independent.
|
|
10
|
+
// Decrypt emits ONLY tag-verified segments; ordering, truncation, duplication and
|
|
11
|
+
// parameter tampering all surface as stream errors (the IV/AAD schedule binds them).
|
|
12
|
+
const MAGIC = new Uint8Array([0x45, 0x56, 0x41, 0x54, 0x32]); // "EVAT2"
|
|
13
|
+
const VERSION = 0x02;
|
|
14
|
+
const HEADER_LEN = 16;
|
|
15
|
+
const PREFIX_LEN = 7;
|
|
16
|
+
const TAG_LEN = 16;
|
|
17
|
+
export const SEG_BYTES = 1_048_576;
|
|
18
|
+
/** Exact ciphertext length for a known plaintext length. */
|
|
19
|
+
export function ctSize(plaintextBytes) {
|
|
20
|
+
const segs = Math.max(1, Math.ceil(plaintextBytes / SEG_BYTES));
|
|
21
|
+
return HEADER_LEN + PREFIX_LEN + plaintextBytes + TAG_LEN * segs;
|
|
22
|
+
}
|
|
23
|
+
function buildHeader(segBytes) {
|
|
24
|
+
const h = new Uint8Array(HEADER_LEN);
|
|
25
|
+
h.set(MAGIC, 0);
|
|
26
|
+
h[5] = VERSION;
|
|
27
|
+
new DataView(h.buffer).setUint32(6, segBytes);
|
|
28
|
+
return h; // bytes 10..15 stay zero (reserved)
|
|
29
|
+
}
|
|
30
|
+
function iv(prefix, index, last) {
|
|
31
|
+
if (index > 0xffffffff)
|
|
32
|
+
throw new Error("attachment too large (segment index overflow)");
|
|
33
|
+
const v = new Uint8Array(12);
|
|
34
|
+
v.set(prefix, 0);
|
|
35
|
+
new DataView(v.buffer).setUint32(PREFIX_LEN, index);
|
|
36
|
+
v[11] = last ? 0x01 : 0x00;
|
|
37
|
+
return v;
|
|
38
|
+
}
|
|
39
|
+
/** Bounded byte accumulator: holds pending input, releases exact-sized slices. */
|
|
40
|
+
class Pending {
|
|
41
|
+
chunks = [];
|
|
42
|
+
len = 0;
|
|
43
|
+
get length() { return this.len; }
|
|
44
|
+
push(c) { if (c.length) {
|
|
45
|
+
this.chunks.push(c);
|
|
46
|
+
this.len += c.length;
|
|
47
|
+
} }
|
|
48
|
+
/** Remove and return exactly n bytes (caller checks length ≥ n). */
|
|
49
|
+
take(n) {
|
|
50
|
+
const out = new Uint8Array(n);
|
|
51
|
+
let o = 0;
|
|
52
|
+
while (o < n) {
|
|
53
|
+
const head = this.chunks[0];
|
|
54
|
+
const want = n - o;
|
|
55
|
+
if (head.length <= want) {
|
|
56
|
+
out.set(head, o);
|
|
57
|
+
o += head.length;
|
|
58
|
+
this.chunks.shift();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
out.set(head.subarray(0, want), o);
|
|
62
|
+
this.chunks[0] = head.subarray(want);
|
|
63
|
+
o += want;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.len -= n;
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function importGcm(key, usage) {
|
|
71
|
+
if (key.length !== 32)
|
|
72
|
+
throw new Error("content key must be 32 bytes");
|
|
73
|
+
return crypto.subtle.importKey("raw", key, "AES-GCM", false, [usage]);
|
|
74
|
+
}
|
|
75
|
+
/** Plaintext → v2 envelope. Buffers ≤ one segment.
|
|
76
|
+
*
|
|
77
|
+
* `noncePrefix` is injectable so format vectors are reproducible. IV uniqueness
|
|
78
|
+
* rests on (key, prefix) being used for exactly ONE file: reusing a key across
|
|
79
|
+
* files REQUIRES a distinct random prefix per file, and reusing a prefix
|
|
80
|
+
* REQUIRES a fresh key. Breaking that reuses an IV under one key, which forfeits
|
|
81
|
+
* both confidentiality and authenticity for every affected segment. The default
|
|
82
|
+
* (random prefix, and a fresh per-attachment key from the caller) satisfies it
|
|
83
|
+
* structurally — pass this only where both halves are known-fresh. */
|
|
84
|
+
export function encryptStream(key, opts) {
|
|
85
|
+
const prefix = opts?.noncePrefix ?? crypto.getRandomValues(new Uint8Array(PREFIX_LEN));
|
|
86
|
+
if (prefix.length !== PREFIX_LEN)
|
|
87
|
+
throw new Error("noncePrefix must be 7 bytes");
|
|
88
|
+
const header = buildHeader(SEG_BYTES);
|
|
89
|
+
const aad = new Uint8Array(HEADER_LEN + PREFIX_LEN);
|
|
90
|
+
aad.set(header, 0);
|
|
91
|
+
aad.set(prefix, HEADER_LEN);
|
|
92
|
+
let ck;
|
|
93
|
+
let index = 0;
|
|
94
|
+
let headerSent = false;
|
|
95
|
+
const pending = new Pending();
|
|
96
|
+
const seal = async (pt, last, ctrl) => {
|
|
97
|
+
const ct = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-GCM", iv: iv(prefix, index, last), additionalData: aad }, ck, pt));
|
|
98
|
+
if (!headerSent) {
|
|
99
|
+
ctrl.enqueue(aad.slice());
|
|
100
|
+
headerSent = true;
|
|
101
|
+
}
|
|
102
|
+
ctrl.enqueue(ct);
|
|
103
|
+
index++;
|
|
104
|
+
};
|
|
105
|
+
const transform = new TransformStream({
|
|
106
|
+
async start() { ck = await importGcm(key, "encrypt"); },
|
|
107
|
+
async transform(chunk, ctrl) {
|
|
108
|
+
pending.push(chunk);
|
|
109
|
+
// retain ≥ one full segment so lastFlag is only ever decided at flush
|
|
110
|
+
while (pending.length > SEG_BYTES)
|
|
111
|
+
await seal(pending.take(SEG_BYTES), false, ctrl);
|
|
112
|
+
},
|
|
113
|
+
async flush(ctrl) {
|
|
114
|
+
await seal(pending.take(pending.length), true, ctrl); // 0..SEG bytes; empty file = one empty last segment
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
return { transform };
|
|
118
|
+
}
|
|
119
|
+
/** v2 envelope → plaintext. Errors on ANY decrypt-obligation violation; only
|
|
120
|
+
* verified segments are emitted. rangeMode: the stream carries header+prefix
|
|
121
|
+
* followed by segments starting at firstSegIndex; ONLY the terminal-flag
|
|
122
|
+
* obligation is relaxed (an interior range cannot observe finality). */
|
|
123
|
+
export function decryptStream(key, opts) {
|
|
124
|
+
let ck;
|
|
125
|
+
let aad = null;
|
|
126
|
+
let prefix = new Uint8Array(0);
|
|
127
|
+
let segBytes = 0;
|
|
128
|
+
let index = opts?.rangeMode ? opts.rangeMode.firstSegIndex : 0;
|
|
129
|
+
const pending = new Pending();
|
|
130
|
+
const open = async (blob, last) => {
|
|
131
|
+
const pt = await crypto.subtle.decrypt({ name: "AES-GCM", iv: iv(prefix, index, last), additionalData: aad }, ck, blob)
|
|
132
|
+
.catch(() => { throw new Error("attachment failed integrity check"); });
|
|
133
|
+
index++;
|
|
134
|
+
return new Uint8Array(pt);
|
|
135
|
+
};
|
|
136
|
+
const parseHeaderIfReady = () => {
|
|
137
|
+
if (aad !== null || pending.length < HEADER_LEN + PREFIX_LEN)
|
|
138
|
+
return;
|
|
139
|
+
const hp = pending.take(HEADER_LEN + PREFIX_LEN);
|
|
140
|
+
if (!MAGIC.every((b, i) => hp[i] === b))
|
|
141
|
+
throw new Error("unsupported attachment (old format)");
|
|
142
|
+
if (hp[5] !== VERSION)
|
|
143
|
+
throw new Error("unsupported attachment (old format)");
|
|
144
|
+
segBytes = new DataView(hp.buffer, hp.byteOffset + 6, 4).getUint32(0);
|
|
145
|
+
// the header is peer-authored: a segment is the decrypt buffer bound, so an
|
|
146
|
+
// announced segBytes beyond 8× the producer's size is refused outright
|
|
147
|
+
if (segBytes < 1 || segBytes > 8 * SEG_BYTES)
|
|
148
|
+
throw new Error("attachment failed integrity check");
|
|
149
|
+
prefix = hp.subarray(HEADER_LEN);
|
|
150
|
+
aad = hp;
|
|
151
|
+
};
|
|
152
|
+
return new TransformStream({
|
|
153
|
+
async start() { ck = await importGcm(key, "decrypt"); },
|
|
154
|
+
async transform(chunk, ctrl) {
|
|
155
|
+
pending.push(chunk);
|
|
156
|
+
parseHeaderIfReady();
|
|
157
|
+
if (aad === null)
|
|
158
|
+
return;
|
|
159
|
+
// a full segment followed by more bytes is necessarily non-last
|
|
160
|
+
while (pending.length > segBytes + TAG_LEN)
|
|
161
|
+
ctrl.enqueue(await open(pending.take(segBytes + TAG_LEN), false));
|
|
162
|
+
},
|
|
163
|
+
async flush(ctrl) {
|
|
164
|
+
parseHeaderIfReady();
|
|
165
|
+
if (aad === null)
|
|
166
|
+
throw new Error("attachment failed integrity check"); // shorter than header+prefix
|
|
167
|
+
if (pending.length < TAG_LEN)
|
|
168
|
+
throw new Error("attachment failed integrity check"); // truncated mid-segment
|
|
169
|
+
const tail = pending.take(pending.length);
|
|
170
|
+
if (opts?.rangeMode) {
|
|
171
|
+
// interior ranges end on a non-last segment; ranges reaching the true
|
|
172
|
+
// tail end on the lastFlag one — accept either, tags still authenticate
|
|
173
|
+
try {
|
|
174
|
+
ctrl.enqueue(await open(tail, false));
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
ctrl.enqueue(await open(tail, true));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
ctrl.enqueue(await open(tail, true)); // exactly one terminal segment, nothing after it
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/crypto/stream.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,qFAAqF;AACrF,EAAE;AACF,qDAAqD;AACrD,yDAAyD;AACzD,gFAAgF;AAChF,0DAA0D;AAC1D,EAAE;AACF,kFAAkF;AAClF,kFAAkF;AAClF,qFAAqF;AAErF,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU;AACxE,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,4DAA4D;AAC5D,MAAM,UAAU,MAAM,CAAC,cAAsB;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC;IAChE,OAAO,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,GAAG,IAAI,CAAC;AACnE,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;IACnC,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IACf,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9C,OAAO,CAAC,CAAC,C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QAChH,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,IAAI;YACd,kBAAkB,EAAE,CAAC;YACrB,IAAI,GAAG,KAAK,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC,CAAC,6BAA6B;YACrG,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC,CAAC,wBAAwB;YAC5G,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC1C,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;gBACpB,sEAAsE;gBACtE,wEAAwE;gBACxE,IAAI,CAAC;oBAAC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;gBAAC,CAAC;gBAC9C,MAAM,CAAC;oBAAC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBAAC,CAAC;YACjD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,iDAAiD;YACzF,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Signer, Auth } from "./types.js";
|
|
2
|
+
/** The unified txId for a tx (== the digest its auths sign).
|
|
3
|
+
*
|
|
4
|
+
* The body-FULL form: the description's body slot takes the 085 fold, so the caller hands over
|
|
5
|
+
* the body and the generated encoder hashes it. (The id-only form folds `verbatim` and a tx
|
|
6
|
+
* carrying neither folds `empty` — the node produces the same digest for all three.) */
|
|
7
|
+
export declare function txId(ledgerId: string, senderNodeId: string, ttlRound: number | bigint, body: Uint8Array, maxToll?: number | bigint): Uint8Array;
|
|
8
|
+
export declare function txIdHex(ledgerId: string, senderNodeId: string, ttlRound: number | bigint, body: Uint8Array, maxToll?: number | bigint): string;
|
|
9
|
+
export declare function encodeSignedTx(args: {
|
|
10
|
+
ledgerId: string;
|
|
11
|
+
senderNodeId: string;
|
|
12
|
+
body: Uint8Array;
|
|
13
|
+
ttlRound: number | bigint;
|
|
14
|
+
auths: Auth[];
|
|
15
|
+
maxToll?: number | bigint;
|
|
16
|
+
}): Uint8Array;
|
|
17
|
+
/** Build a fully-signed SignedTx: compute the digest, have each signer sign it, encode.
|
|
18
|
+
* 153 — `maxToll` (the signed toll ceiling) is optional; 0/omitted means the tx consents to no
|
|
19
|
+
* toll. It is BOTH folded into the digest the signers cover AND carried on the wire (field 6). */
|
|
20
|
+
export declare function buildSignedTx(args: {
|
|
21
|
+
ledgerId: string;
|
|
22
|
+
senderNodeId: string;
|
|
23
|
+
body: Uint8Array;
|
|
24
|
+
ttlRound: number | bigint;
|
|
25
|
+
signers: Signer[];
|
|
26
|
+
maxToll?: number | bigint;
|
|
27
|
+
}): Uint8Array;
|
|
28
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;yFAIyF;AACzF,wBAAgB,IAAI,CAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,MAAM,GAAG,MAAW,GAC5B,UAAU,CAQZ;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,MAAM,GAAG,MAAW,GAC5B,MAAM,CAER;AASD,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GAAG,UAAU,CAWb;AAED;;mGAEmG;AACnG,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GAAG,UAAU,CAiBb"}
|
package/dist/envelope.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The SignedTx envelope + the single tx-signing recipe.
|
|
2
|
+
//
|
|
3
|
+
// ⚠️ 149 — THE RECIPE IS NO LONGER WRITTEN HERE. `TX_AUTH_DST` and the hand-composed
|
|
4
|
+
// `signingDigest` (a length-prefix-by-length-prefix twin of the node's `AuthBodySignable`) are
|
|
5
|
+
// GONE; `authBody` in ./generated/codecs is emitted from the node's own description, so there is
|
|
6
|
+
// no second statement of this format to keep in step. This header used to restate the recipe too,
|
|
7
|
+
// which is why it is not restated now: consult the description, or the generated file.
|
|
8
|
+
//
|
|
9
|
+
// What remains here is TRANSPORT (the proto3 SignedTx/TxAuth encoders) and the two compositions
|
|
10
|
+
// over the digest — `txId` and `buildSignedTx` — which decide WHICH body slot applies, a choice
|
|
11
|
+
// no schema can carry (`Branch.select` is a Scala function).
|
|
12
|
+
//
|
|
13
|
+
// The digest binds ledger_id, sender, the TTL deadline and the body — but NOT
|
|
14
|
+
// the auths — so co-signed (multi-auth) txs all sign the same target, and the
|
|
15
|
+
// digest doubles as the representation-independent txId (085).
|
|
16
|
+
import { fString, fBytes, fMessage, fVarint, concat } from "./wire.js";
|
|
17
|
+
import { bytesToHex } from "./crypto/hash.js";
|
|
18
|
+
import { authBody } from "./generated/codecs.js";
|
|
19
|
+
/** The unified txId for a tx (== the digest its auths sign).
|
|
20
|
+
*
|
|
21
|
+
* The body-FULL form: the description's body slot takes the 085 fold, so the caller hands over
|
|
22
|
+
* the body and the generated encoder hashes it. (The id-only form folds `verbatim` and a tx
|
|
23
|
+
* carrying neither folds `empty` — the node produces the same digest for all three.) */
|
|
24
|
+
export function txId(ledgerId, senderNodeId, ttlRound, body, maxToll = 0n) {
|
|
25
|
+
return authBody({
|
|
26
|
+
ledgerId,
|
|
27
|
+
senderNodeId,
|
|
28
|
+
ttlRound: BigInt(ttlRound),
|
|
29
|
+
maxToll: BigInt(maxToll),
|
|
30
|
+
bodySlot: { fold: "sha256Of", bytes: body },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function txIdHex(ledgerId, senderNodeId, ttlRound, body, maxToll = 0n) {
|
|
34
|
+
return bytesToHex(txId(ledgerId, senderNodeId, ttlRound, body, maxToll));
|
|
35
|
+
}
|
|
36
|
+
// TxAuth: 1 key_type | 2 key_label | 3 signature | 4 node_id
|
|
37
|
+
function encodeTxAuth(a) {
|
|
38
|
+
return concat(fString(1, a.keyType), fString(2, a.keyLabel), fBytes(3, a.signature), fString(4, a.nodeId));
|
|
39
|
+
}
|
|
40
|
+
// SignedTx: 1 ledger_id | 2 sender_node_id | 3 tx (Tx) | 4 auths (repeated) | 5 ttl_round | 6 max_toll
|
|
41
|
+
// Tx.content oneof: 1 tx_body (bytes)
|
|
42
|
+
export function encodeSignedTx(args) {
|
|
43
|
+
const tx = concat(fBytes(1, args.body)); // Tx{ tx_body = 1 }
|
|
44
|
+
const maxToll = args.maxToll ?? 0n;
|
|
45
|
+
return concat(fString(1, args.ledgerId), fString(2, args.senderNodeId), fMessage(3, tx), ...args.auths.map((a) => fMessage(4, encodeTxAuth(a))), fVarint(5, args.ttlRound), ...(BigInt(maxToll) !== 0n ? [fVarint(6, maxToll)] : []));
|
|
46
|
+
}
|
|
47
|
+
/** Build a fully-signed SignedTx: compute the digest, have each signer sign it, encode.
|
|
48
|
+
* 153 — `maxToll` (the signed toll ceiling) is optional; 0/omitted means the tx consents to no
|
|
49
|
+
* toll. It is BOTH folded into the digest the signers cover AND carried on the wire (field 6). */
|
|
50
|
+
export function buildSignedTx(args) {
|
|
51
|
+
const maxToll = args.maxToll ?? 0n;
|
|
52
|
+
const digest = txId(args.ledgerId, args.senderNodeId, args.ttlRound, args.body, maxToll);
|
|
53
|
+
const auths = args.signers.map((s) => ({
|
|
54
|
+
keyType: s.keyType,
|
|
55
|
+
keyLabel: s.keyLabel,
|
|
56
|
+
nodeId: s.nodeId,
|
|
57
|
+
signature: s.sign(digest),
|
|
58
|
+
}));
|
|
59
|
+
return encodeSignedTx({
|
|
60
|
+
ledgerId: args.ledgerId,
|
|
61
|
+
senderNodeId: args.senderNodeId,
|
|
62
|
+
body: args.body,
|
|
63
|
+
ttlRound: args.ttlRound,
|
|
64
|
+
auths,
|
|
65
|
+
maxToll,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,qFAAqF;AACrF,+FAA+F;AAC/F,iGAAiG;AACjG,kGAAkG;AAClG,uFAAuF;AACvF,EAAE;AACF,gGAAgG;AAChG,gGAAgG;AAChG,6DAA6D;AAC7D,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,+DAA+D;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC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IAAI,CAAC,QAAQ;QACvB,KAAK;QACL,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/** The bytes are folded with SHA-256 into this field's slot. */
|
|
2
|
+
export interface Sha256OfFold {
|
|
3
|
+
readonly fold: "sha256Of";
|
|
4
|
+
readonly bytes: Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
/** The bytes occupy the slot as they stand. */
|
|
7
|
+
export interface VerbatimFold {
|
|
8
|
+
readonly fold: "verbatim";
|
|
9
|
+
readonly bytes: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
/** The explicit empty case — written as length 0, NEVER omitted (rule 3). */
|
|
12
|
+
export interface EmptyFold {
|
|
13
|
+
readonly fold: "empty";
|
|
14
|
+
}
|
|
15
|
+
export type FoldChoice = Sha256OfFold | VerbatimFold | EmptyFold;
|
|
16
|
+
/** One field of a described message, as data. Mirrors contracts/schema-export.md. */
|
|
17
|
+
export interface CodecFieldSchema {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly kind: string;
|
|
20
|
+
readonly elements?: readonly {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly kind: string;
|
|
23
|
+
}[];
|
|
24
|
+
readonly derivation: string | {
|
|
25
|
+
readonly oneOf: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface CodecSchema {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly tag: string;
|
|
31
|
+
readonly output: "digest" | "material";
|
|
32
|
+
readonly fields: readonly CodecFieldSchema[];
|
|
33
|
+
}
|
|
34
|
+
export interface AuthBodyFields {
|
|
35
|
+
readonly ledgerId: string;
|
|
36
|
+
readonly senderNodeId: string;
|
|
37
|
+
readonly ttlRound: bigint;
|
|
38
|
+
readonly maxToll: bigint;
|
|
39
|
+
readonly bodySlot: Sha256OfFold | VerbatimFold | EmptyFold;
|
|
40
|
+
}
|
|
41
|
+
/** `ce.evolver/153/tx-auth/v2` — digest. */
|
|
42
|
+
export declare function authBody(f: AuthBodyFields): Uint8Array;
|
|
43
|
+
export interface AuthsDigestAuthsElement {
|
|
44
|
+
readonly nodeId: string;
|
|
45
|
+
readonly keyType: string;
|
|
46
|
+
readonly keyLabel: string;
|
|
47
|
+
readonly purpose: number;
|
|
48
|
+
readonly signature: Uint8Array;
|
|
49
|
+
}
|
|
50
|
+
export interface AuthsDigestFields {
|
|
51
|
+
readonly auths: readonly AuthsDigestAuthsElement[];
|
|
52
|
+
}
|
|
53
|
+
/** `ce.evolver/148/auths-digest/v1` — digest. */
|
|
54
|
+
export declare function authsDigest(f: AuthsDigestFields): Uint8Array;
|
|
55
|
+
export interface VoteFields {
|
|
56
|
+
readonly roundNum: number;
|
|
57
|
+
readonly blockId: Uint8Array;
|
|
58
|
+
}
|
|
59
|
+
/** `ce.evolver/148/vote/v1` — material (signed as-is, NOT hashed). */
|
|
60
|
+
export declare function vote(f: VoteFields): Uint8Array;
|
|
61
|
+
export interface NewViewFields {
|
|
62
|
+
readonly roundNum: number;
|
|
63
|
+
readonly highQcBlockId: Uint8Array;
|
|
64
|
+
readonly highQcRoundNum: number;
|
|
65
|
+
}
|
|
66
|
+
/** `ce.evolver/148/new-view/v1` — material (signed as-is, NOT hashed). */
|
|
67
|
+
export declare function newView(f: NewViewFields): Uint8Array;
|
|
68
|
+
export interface P2pSignableFields {
|
|
69
|
+
readonly sender: string;
|
|
70
|
+
readonly keyType: string;
|
|
71
|
+
readonly keyLabel: string;
|
|
72
|
+
readonly recipient: string;
|
|
73
|
+
readonly channel: string;
|
|
74
|
+
readonly timestamp: bigint;
|
|
75
|
+
readonly nonce: Uint8Array;
|
|
76
|
+
readonly payload: Uint8Array;
|
|
77
|
+
}
|
|
78
|
+
/** `ce.evolver/145/p2p-msg/v1` — digest. */
|
|
79
|
+
export declare function p2pSignable(f: P2pSignableFields): Uint8Array;
|
|
80
|
+
export interface PopCreateIdentityKeysElement {
|
|
81
|
+
readonly keyType: string;
|
|
82
|
+
readonly publicKey: Uint8Array;
|
|
83
|
+
readonly keyLabel: string;
|
|
84
|
+
}
|
|
85
|
+
export interface PopCreateIdentityFields {
|
|
86
|
+
readonly nodeId: string;
|
|
87
|
+
readonly initialCredit: bigint;
|
|
88
|
+
readonly keys: readonly PopCreateIdentityKeysElement[];
|
|
89
|
+
}
|
|
90
|
+
/** `ce.evolver/148/pop-create-identity/v1` — digest. */
|
|
91
|
+
export declare function popCreateIdentity(f: PopCreateIdentityFields): Uint8Array;
|
|
92
|
+
export interface PopAddKeyFields {
|
|
93
|
+
readonly publicKey: Uint8Array;
|
|
94
|
+
readonly keyType: string;
|
|
95
|
+
readonly keyLabel: string;
|
|
96
|
+
}
|
|
97
|
+
/** `ce.evolver/148/pop-add-key/v1` — digest. */
|
|
98
|
+
export declare function popAddKey(f: PopAddKeyFields): Uint8Array;
|
|
99
|
+
export interface PopReplaceKeyFields {
|
|
100
|
+
readonly publicKey: Uint8Array;
|
|
101
|
+
readonly keyType: string;
|
|
102
|
+
readonly keyLabel: string;
|
|
103
|
+
}
|
|
104
|
+
/** `ce.evolver/148/pop-replace-key/v1` — digest. */
|
|
105
|
+
export declare function popReplaceKey(f: PopReplaceKeyFields): Uint8Array;
|
|
106
|
+
export interface ProposalIdAdmissionFields {
|
|
107
|
+
readonly candidateNodeId: string;
|
|
108
|
+
readonly startBlockHeight: number;
|
|
109
|
+
readonly proposerNodeId: string;
|
|
110
|
+
readonly donatedStake: number;
|
|
111
|
+
}
|
|
112
|
+
/** `ce.evolver/149/proposal-id-admission/v1` — digest. */
|
|
113
|
+
export declare function proposalIdAdmission(f: ProposalIdAdmissionFields): Uint8Array;
|
|
114
|
+
export interface ProposalIdRemovalFields {
|
|
115
|
+
readonly targetNodeId: string;
|
|
116
|
+
readonly removalBlockHeight: number;
|
|
117
|
+
readonly proposerNodeId: string;
|
|
118
|
+
}
|
|
119
|
+
/** `ce.evolver/149/proposal-id-removal/v1` — digest. */
|
|
120
|
+
export declare function proposalIdRemoval(f: ProposalIdRemovalFields): Uint8Array;
|
|
121
|
+
export interface BlockIdFields {
|
|
122
|
+
readonly roundNum: number;
|
|
123
|
+
readonly parentId: Uint8Array;
|
|
124
|
+
readonly merkleRoot: Uint8Array;
|
|
125
|
+
readonly parentQcSigners: Uint8Array;
|
|
126
|
+
}
|
|
127
|
+
/** `ce.evolver/148/block-id/v1` — digest. */
|
|
128
|
+
export declare function blockId(f: BlockIdFields): Uint8Array;
|
|
129
|
+
export interface ListTxIdTxIdsElement {
|
|
130
|
+
readonly txId: Uint8Array;
|
|
131
|
+
}
|
|
132
|
+
export interface ListTxIdFields {
|
|
133
|
+
readonly txIds: readonly ListTxIdTxIdsElement[];
|
|
134
|
+
}
|
|
135
|
+
/** `ce.evolver/149/list-tx-id/v1` — digest. */
|
|
136
|
+
export declare function listTxId(f: ListTxIdFields): Uint8Array;
|
|
137
|
+
export interface ListContextFields {
|
|
138
|
+
readonly listTxId: Uint8Array;
|
|
139
|
+
readonly txId: Uint8Array;
|
|
140
|
+
}
|
|
141
|
+
/** `ce.evolver/149/list-context/v1` — digest. */
|
|
142
|
+
export declare function listContext(f: ListContextFields): Uint8Array;
|
|
143
|
+
export declare const CODECS: readonly CodecSchema[];
|
|
144
|
+
export declare const ENCODERS: Readonly<Record<string, (row: any) => Uint8Array>>;
|
|
145
|
+
//# sourceMappingURL=codecs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../src/generated/codecs.ts"],"names":[],"mappings":"AAqBA,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED,6EA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