@totemsdk/core 1.0.9 → 1.0.10
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 +21 -0
- package/README.md +5 -5
- package/dist/Streamable.js +54 -31
- package/dist/adapters/index.js +18 -8
- package/dist/adapters/types.js +19 -8
- package/dist/binio.js +5 -1
- package/dist/bip39.js +24 -14
- package/dist/derive.js +11 -7
- package/dist/index.js +130 -22
- package/dist/javaStreamables.js +49 -30
- package/dist/lease/LeaseMonitor.js +7 -3
- package/dist/lease/LeaseStore.js +7 -3
- package/dist/lease/WatermarkStore.js +7 -3
- package/dist/lease/index.js +13 -4
- package/dist/lease-client.js +8 -3
- package/dist/minima32.js +22 -13
- package/dist/minimaWireSerializer.js +20 -14
- package/dist/mmr.js +35 -23
- package/dist/mx.js +10 -1
- package/dist/params.js +9 -5
- package/dist/script.js +12 -7
- package/dist/scripts/contract-helpers.js +37 -26
- package/dist/scripts/dapp-types.js +11 -6
- package/dist/scripts/index.js +38 -4
- package/dist/scripts/types.js +26 -12
- package/dist/scripts/witness-serializer.js +48 -30
- package/dist/transaction.js +55 -46
- package/dist/treekey.js +74 -58
- package/dist/tx/TransactionLifecycle.js +11 -5
- package/dist/tx/TransactionReceiptStore.js +7 -3
- package/dist/tx/TransactionService.js +14 -10
- package/dist/tx/index.js +11 -3
- package/dist/tx/types.js +2 -1
- package/dist/util.js +5 -1
- package/dist/utils.js +12 -5
- package/dist/verify.js +36 -25
- package/dist/version.js +5 -2
- package/dist/wots.js +94 -64
- package/package.json +31 -6
- package/src/Streamable.d.ts +0 -268
- package/src/Streamable.js +0 -416
- package/src/Streamable.ts +0 -567
- package/src/__tests__/Streamable.parity.test.ts +0 -422
- package/src/__tests__/perAddressDerivation.parity.test.ts +0 -152
- package/src/__tests__/roottree-prepare.test.ts +0 -101
- package/src/__tests__/wots-parity.test.ts +0 -289
- package/src/adapters/index.d.ts +0 -190
- package/src/adapters/index.js +0 -117
- package/src/adapters/index.ts +0 -301
- package/src/adapters/types.ts +0 -235
- package/src/addr.oracle.test.ts +0 -25
- package/src/address.test.ts +0 -55
- package/src/binio.ts +0 -21
- package/src/bip39.d.ts +0 -91
- package/src/bip39.js +0 -427
- package/src/bip39.ts +0 -432
- package/src/derive.d.ts +0 -2
- package/src/derive.js +0 -13
- package/src/derive.ts +0 -11
- package/src/index.d.ts +0 -26
- package/src/index.js +0 -128
- package/src/index.test.ts +0 -5
- package/src/index.ts +0 -221
- package/src/javaStreamables.d.ts +0 -233
- package/src/javaStreamables.js +0 -332
- package/src/javaStreamables.ts +0 -403
- package/src/lease/LeaseMonitor.d.ts +0 -44
- package/src/lease/LeaseMonitor.js +0 -111
- package/src/lease/LeaseMonitor.ts +0 -157
- package/src/lease/LeaseStore.d.ts +0 -57
- package/src/lease/LeaseStore.js +0 -148
- package/src/lease/LeaseStore.ts +0 -203
- package/src/lease/WatermarkStore.d.ts +0 -61
- package/src/lease/WatermarkStore.js +0 -206
- package/src/lease/WatermarkStore.ts +0 -270
- package/src/lease/index.d.ts +0 -14
- package/src/lease/index.js +0 -22
- package/src/lease/index.ts +0 -41
- package/src/lease-client.d.ts +0 -31
- package/src/lease-client.js +0 -44
- package/src/lease-client.ts +0 -69
- package/src/minima32.d.ts +0 -10
- package/src/minima32.js +0 -113
- package/src/minima32.test.ts +0 -11
- package/src/minima32.ts +0 -127
- package/src/minimaWireSerializer.d.ts +0 -189
- package/src/minimaWireSerializer.js +0 -311
- package/src/minimaWireSerializer.test.ts +0 -466
- package/src/minimaWireSerializer.ts +0 -117
- package/src/mmr.d.ts +0 -157
- package/src/mmr.js +0 -340
- package/src/mmr.oracle.test.ts +0 -28
- package/src/mmr.ts +0 -429
- package/src/mx.test.ts +0 -25
- package/src/mx.ts +0 -1
- package/src/params.d.ts +0 -29
- package/src/params.d.ts.map +0 -1
- package/src/params.js +0 -20
- package/src/params.js.map +0 -1
- package/src/params.ts +0 -44
- package/src/script.d.ts +0 -7
- package/src/script.js +0 -27
- package/src/script.ts +0 -24
- package/src/scripts/contract-helpers.ts +0 -609
- package/src/scripts/dapp-types.ts +0 -240
- package/src/scripts/index.ts +0 -22
- package/src/scripts/types.d.ts +0 -81
- package/src/scripts/types.js +0 -145
- package/src/scripts/types.ts +0 -247
- package/src/scripts/witness-serializer.ts +0 -384
- package/src/transaction.ts +0 -430
- package/src/treekey.d.ts +0 -383
- package/src/treekey.js +0 -774
- package/src/treekey.parity.test.ts +0 -459
- package/src/treekey.ts +0 -975
- package/src/tx/TransactionLifecycle.d.ts +0 -55
- package/src/tx/TransactionLifecycle.js +0 -188
- package/src/tx/TransactionLifecycle.ts +0 -280
- package/src/tx/TransactionReceiptStore.d.ts +0 -36
- package/src/tx/TransactionReceiptStore.js +0 -89
- package/src/tx/TransactionReceiptStore.ts +0 -112
- package/src/tx/TransactionService.d.ts +0 -31
- package/src/tx/TransactionService.js +0 -140
- package/src/tx/TransactionService.ts +0 -252
- package/src/tx/index.d.ts +0 -13
- package/src/tx/index.js +0 -20
- package/src/tx/index.ts +0 -44
- package/src/tx/types.d.ts +0 -80
- package/src/tx/types.js +0 -6
- package/src/tx/types.ts +0 -130
- package/src/util.d.ts +0 -1
- package/src/util.js +0 -5
- package/src/util.ts +0 -1
- package/src/utils.d.ts +0 -8
- package/src/utils.js +0 -42
- package/src/utils.ts +0 -38
- package/src/verify.ts +0 -210
- package/src/version.ts +0 -13
- package/src/wots.d.ts +0 -224
- package/src/wots.d.ts.map +0 -1
- package/src/wots.js +0 -565
- package/src/wots.js.map +0 -1
- package/src/wots.ts +0 -651
- package/test-vectors.json +0 -45
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Minima Wire Format Serializer
|
|
4
|
-
*
|
|
5
|
-
* Byte-exact serialization matching Minima's Java Signature.java and SignatureProof.java
|
|
6
|
-
*
|
|
7
|
-
* Wire Format Reference:
|
|
8
|
-
*
|
|
9
|
-
* Signature.writeDataStream():
|
|
10
|
-
* 1. MiniNumber - count of SignatureProofs
|
|
11
|
-
* 2. For each SignatureProof.writeDataStream()
|
|
12
|
-
*
|
|
13
|
-
* SignatureProof.writeDataStream():
|
|
14
|
-
* 1. MiniData (publicKey) - 4-byte big-endian length + bytes
|
|
15
|
-
* 2. MiniData (signature) - 4-byte big-endian length + bytes
|
|
16
|
-
* 3. MMRProof.writeDataStream()
|
|
17
|
-
*
|
|
18
|
-
* MMRProof.writeDataStream():
|
|
19
|
-
* 1. MiniNumber (blockTime)
|
|
20
|
-
* 2. MiniNumber (chain length)
|
|
21
|
-
* 3. For each chunk:
|
|
22
|
-
* - MiniByte (isLeft) - 1 byte (0 or 1)
|
|
23
|
-
* - MMRData.writeDataStream():
|
|
24
|
-
* - hash (4-byte length prefix + 32 bytes via writeHashToStream)
|
|
25
|
-
* - value (MiniNumber)
|
|
26
|
-
*
|
|
27
|
-
* CRITICAL (2026-01): Java's writeHashToStream uses writeInt (4-byte prefix),
|
|
28
|
-
* identical to writeDataStream. See MiniData.java lines 282-289.
|
|
29
|
-
*/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.serializeMiniNumber = serializeMiniNumber;
|
|
32
|
-
exports.serializeMiniData = serializeMiniData;
|
|
33
|
-
exports.writeHashToStream = writeHashToStream;
|
|
34
|
-
exports.serializeMMRData = serializeMMRData;
|
|
35
|
-
exports.serializeMMRProof = serializeMMRProof;
|
|
36
|
-
exports.serializeSignatureProof = serializeSignatureProof;
|
|
37
|
-
exports.serializeSignature = serializeSignature;
|
|
38
|
-
exports.fromHex = fromHex;
|
|
39
|
-
exports.toHex = toHex;
|
|
40
|
-
exports.serializeHierarchicalWitness = serializeHierarchicalWitness;
|
|
41
|
-
exports.serializeHierarchicalWitnessToHex = serializeHierarchicalWitnessToHex;
|
|
42
|
-
function concat(...parts) {
|
|
43
|
-
const total = parts.reduce((n, p) => n + p.length, 0);
|
|
44
|
-
const out = new Uint8Array(total);
|
|
45
|
-
let off = 0;
|
|
46
|
-
for (const p of parts) {
|
|
47
|
-
out.set(p, off);
|
|
48
|
-
off += p.length;
|
|
49
|
-
}
|
|
50
|
-
return out;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Serialize MiniNumber matching Java MiniNumber.writeDataStream()
|
|
54
|
-
* Format: [scale: 1 byte] [length: 1 byte] [data: N bytes]
|
|
55
|
-
*
|
|
56
|
-
* Scale is always 0 for integers (no decimal places)
|
|
57
|
-
* Length is 1 byte (NOT 4 bytes like MiniData)
|
|
58
|
-
*/
|
|
59
|
-
function serializeMiniNumber(value) {
|
|
60
|
-
const scale = 0;
|
|
61
|
-
if (value === 0n) {
|
|
62
|
-
return new Uint8Array([scale, 1, 0x00]);
|
|
63
|
-
}
|
|
64
|
-
if (value < 0n) {
|
|
65
|
-
throw new Error(`Negative values not supported: ${value}`);
|
|
66
|
-
}
|
|
67
|
-
let hex = value.toString(16);
|
|
68
|
-
if (hex.length % 2 !== 0)
|
|
69
|
-
hex = '0' + hex;
|
|
70
|
-
const dataBytes = new Uint8Array(hex.length / 2);
|
|
71
|
-
for (let i = 0; i < dataBytes.length; i++) {
|
|
72
|
-
dataBytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
73
|
-
}
|
|
74
|
-
let finalBytes = dataBytes;
|
|
75
|
-
if (dataBytes.length > 0 && (dataBytes[0] & 0x80) !== 0) {
|
|
76
|
-
finalBytes = new Uint8Array(dataBytes.length + 1);
|
|
77
|
-
finalBytes[0] = 0x00;
|
|
78
|
-
finalBytes.set(dataBytes, 1);
|
|
79
|
-
}
|
|
80
|
-
const result = new Uint8Array(1 + 1 + finalBytes.length);
|
|
81
|
-
result[0] = scale;
|
|
82
|
-
result[1] = finalBytes.length;
|
|
83
|
-
result.set(finalBytes, 2);
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Serialize MiniData matching Java MiniData.writeDataStream()
|
|
88
|
-
* Format: [4-byte big-endian length] [data bytes]
|
|
89
|
-
*/
|
|
90
|
-
function serializeMiniData(data) {
|
|
91
|
-
const length = data.length;
|
|
92
|
-
const result = new Uint8Array(4 + length);
|
|
93
|
-
result[0] = (length >> 24) & 0xff;
|
|
94
|
-
result[1] = (length >> 16) & 0xff;
|
|
95
|
-
result[2] = (length >> 8) & 0xff;
|
|
96
|
-
result[3] = length & 0xff;
|
|
97
|
-
result.set(data, 4);
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Write hash with 4-byte length prefix matching Java MiniData.writeHashToStream()
|
|
102
|
-
*
|
|
103
|
-
* From MiniData.java writeHashToStream (lines 282-289):
|
|
104
|
-
* zOut.writeInt(mData.length); // 4-byte big-endian int
|
|
105
|
-
* zOut.write(mData); // raw bytes
|
|
106
|
-
*
|
|
107
|
-
* CRITICAL: Java uses writeInt (4 bytes), same as writeDataStream!
|
|
108
|
-
* The only difference is a max length check of 64 bytes (MINIMA_MAX_HASH_LENGTH).
|
|
109
|
-
*
|
|
110
|
-
* Used by MMRData.writeDataStream() for the hash field.
|
|
111
|
-
*/
|
|
112
|
-
function writeHashToStream(hash) {
|
|
113
|
-
if (hash.length > 64) {
|
|
114
|
-
throw new Error(`Hash too long for writeHashToStream: ${hash.length} bytes (max 64)`);
|
|
115
|
-
}
|
|
116
|
-
const result = new Uint8Array(4 + hash.length);
|
|
117
|
-
result[0] = (hash.length >> 24) & 0xff;
|
|
118
|
-
result[1] = (hash.length >> 16) & 0xff;
|
|
119
|
-
result[2] = (hash.length >> 8) & 0xff;
|
|
120
|
-
result[3] = hash.length & 0xff;
|
|
121
|
-
result.set(hash, 4);
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Serialize MMRData matching Java MMRData.writeDataStream()
|
|
126
|
-
*
|
|
127
|
-
* CRITICAL FIX (2026-01): Analysis of coinexport output shows MMRData uses
|
|
128
|
-
* MiniData format (4-byte length prefix + 32 bytes) for the hash field,
|
|
129
|
-
* NOT raw 32 bytes. This matches what Minima's node produces.
|
|
130
|
-
*
|
|
131
|
-
* Format:
|
|
132
|
-
* - hash (MiniData: 4-byte length + 32 bytes)
|
|
133
|
-
* - value (MiniNumber)
|
|
134
|
-
*/
|
|
135
|
-
function serializeMMRData(mmrData) {
|
|
136
|
-
return concat(serializeMiniData(mmrData.data), // MiniData format with 4-byte length prefix
|
|
137
|
-
serializeMiniNumber(mmrData.value));
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Serialize MMRProof matching Java MMRProof.writeDataStream()
|
|
141
|
-
*
|
|
142
|
-
* Format:
|
|
143
|
-
* 1. MiniNumber (blockTime) - always 0 for TreeKey proofs
|
|
144
|
-
* 2. MiniNumber (chain length)
|
|
145
|
-
* 3. For each chunk:
|
|
146
|
-
* - MiniByte (isLeft) - 1 byte
|
|
147
|
-
* - MMRData (hash + value)
|
|
148
|
-
*/
|
|
149
|
-
function serializeMMRProof(proof, blockTime = 0n) {
|
|
150
|
-
const parts = [];
|
|
151
|
-
parts.push(serializeMiniNumber(blockTime));
|
|
152
|
-
parts.push(serializeMiniNumber(BigInt(proof.chunks.length)));
|
|
153
|
-
for (const chunk of proof.chunks) {
|
|
154
|
-
parts.push(new Uint8Array([chunk.isLeft ? 1 : 0]));
|
|
155
|
-
parts.push(serializeMMRData(chunk.mmrData));
|
|
156
|
-
}
|
|
157
|
-
return concat(...parts);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Serialize SignatureProof matching Java SignatureProof.writeDataStream()
|
|
161
|
-
*
|
|
162
|
-
* Format:
|
|
163
|
-
* 1. MiniData (publicKey) - 4-byte length + bytes
|
|
164
|
-
* 2. MiniData (signature) - 4-byte length + bytes
|
|
165
|
-
* 3. MMRProof.writeDataStream()
|
|
166
|
-
*/
|
|
167
|
-
function serializeSignatureProof(sigProof) {
|
|
168
|
-
return concat(serializeMiniData(sigProof.publicKey), serializeMiniData(sigProof.signature), serializeMMRProof(sigProof.proof));
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Serialize Signature matching Java Signature.writeDataStream()
|
|
172
|
-
*
|
|
173
|
-
* Format:
|
|
174
|
-
* 1. MiniNumber - count of SignatureProofs
|
|
175
|
-
* 2. For each SignatureProof.writeDataStream()
|
|
176
|
-
*
|
|
177
|
-
* From Signature.java:
|
|
178
|
-
* MiniNumber.WriteToStream(zOut, mSignatures.size());
|
|
179
|
-
* for(SignatureProof sig : mSignatures) {
|
|
180
|
-
* sig.writeDataStream(zOut);
|
|
181
|
-
* }
|
|
182
|
-
*/
|
|
183
|
-
function serializeSignature(signature) {
|
|
184
|
-
const parts = [];
|
|
185
|
-
parts.push(serializeMiniNumber(BigInt(signature.proofs.length)));
|
|
186
|
-
for (const proof of signature.proofs) {
|
|
187
|
-
parts.push(serializeSignatureProof(proof));
|
|
188
|
-
}
|
|
189
|
-
return concat(...parts);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Convert hex string to bytes
|
|
193
|
-
*/
|
|
194
|
-
function fromHex(hex) {
|
|
195
|
-
const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
196
|
-
if (cleanHex.length % 2 !== 0) {
|
|
197
|
-
throw new Error('Invalid hex string length');
|
|
198
|
-
}
|
|
199
|
-
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
200
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
201
|
-
bytes[i] = parseInt(cleanHex.slice(i * 2, i * 2 + 2), 16);
|
|
202
|
-
}
|
|
203
|
-
return bytes;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Convert bytes to hex string with 0x prefix
|
|
207
|
-
*/
|
|
208
|
-
function toHex(bytes) {
|
|
209
|
-
return '0x' + Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* @deprecated Deserialize MMRProof from bytes - unused, kept for reference only
|
|
213
|
-
*
|
|
214
|
-
* This was used in the double-serialization path which has been removed.
|
|
215
|
-
* The correct approach is to pass pre-serialized bytes through directly.
|
|
216
|
-
*
|
|
217
|
-
* CRITICAL: Java MMRData.readDataStream uses mData.readHashFromStream() which reads
|
|
218
|
-
* a 4-byte big-endian length prefix followed by the hash bytes.
|
|
219
|
-
*/
|
|
220
|
-
function deserializeMMRProofFromBytes(data) {
|
|
221
|
-
let offset = 0;
|
|
222
|
-
const { value: blockTime, bytesRead: btRead } = readMiniNumber(data, offset);
|
|
223
|
-
offset += btRead;
|
|
224
|
-
const { value: numChunks, bytesRead: ncRead } = readMiniNumber(data, offset);
|
|
225
|
-
offset += ncRead;
|
|
226
|
-
const chunks = [];
|
|
227
|
-
for (let i = 0; i < Number(numChunks); i++) {
|
|
228
|
-
const isLeft = data[offset] === 1;
|
|
229
|
-
offset += 1;
|
|
230
|
-
// Read 4-byte big-endian length prefix for hash (writeHashToStream format)
|
|
231
|
-
const hashLength = (data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | data[offset + 3];
|
|
232
|
-
offset += 4;
|
|
233
|
-
const hashData = data.slice(offset, offset + hashLength);
|
|
234
|
-
offset += hashLength;
|
|
235
|
-
const { value: chunkValue, bytesRead: cvRead } = readMiniNumber(data, offset);
|
|
236
|
-
offset += cvRead;
|
|
237
|
-
chunks.push({ isLeft, mmrData: { data: hashData, value: chunkValue } });
|
|
238
|
-
}
|
|
239
|
-
return { chunks };
|
|
240
|
-
}
|
|
241
|
-
function readMiniNumber(data, offset) {
|
|
242
|
-
const scale = data[offset];
|
|
243
|
-
const length = data[offset + 1];
|
|
244
|
-
if (length === 0) {
|
|
245
|
-
return { value: 0n, bytesRead: 2 };
|
|
246
|
-
}
|
|
247
|
-
const dataBytes = data.slice(offset + 2, offset + 2 + length);
|
|
248
|
-
let value = 0n;
|
|
249
|
-
for (const b of dataBytes) {
|
|
250
|
-
value = (value << 8n) | BigInt(b);
|
|
251
|
-
}
|
|
252
|
-
return { value, bytesRead: 2 + length };
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Serialize a SignatureProof from pre-serialized byte arrays
|
|
256
|
-
*
|
|
257
|
-
* This avoids double-serialization by passing MMR proof bytes through directly.
|
|
258
|
-
* Format matches SignatureProof.writeDataStream():
|
|
259
|
-
* 1. MiniData (publicKey) - 4-byte length + bytes
|
|
260
|
-
* 2. MiniData (signature) - 4-byte length + bytes
|
|
261
|
-
* 3. MMRProof bytes (pre-serialized)
|
|
262
|
-
*/
|
|
263
|
-
function serializeSignatureProofFromBytes(publicKey, signature, mmrProofBytes) {
|
|
264
|
-
return concat(serializeMiniData(publicKey), serializeMiniData(signature), mmrProofBytes // Already serialized - pass through directly
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Serialize hierarchical witness bundle to Minima wire format
|
|
269
|
-
*
|
|
270
|
-
* This converts the HierarchicalWitnessBundle (with hex strings) to
|
|
271
|
-
* the proper Witness signature format matching Witness.java → Signature.java hierarchy.
|
|
272
|
-
*
|
|
273
|
-
* CRITICAL FIX (2026-01): Must use double-nesting to match Java format:
|
|
274
|
-
* - Witness.writeDataStream writes: [signatureCount][Signature[0].writeDataStream()]...
|
|
275
|
-
* - Signature.writeDataStream writes: [proofCount][SignatureProof[0]]...
|
|
276
|
-
*
|
|
277
|
-
* So the final format is:
|
|
278
|
-
* [1] = signatureCount (we have 1 Signature object in Witness)
|
|
279
|
-
* [N] = proofCount inside that Signature (2 for address-based TreeKey)
|
|
280
|
-
* [SignatureProof[0]]
|
|
281
|
-
* [SignatureProof[1]]
|
|
282
|
-
*
|
|
283
|
-
* IMPORTANT: Uses pre-serialized MMR proof bytes directly to avoid
|
|
284
|
-
* double-serialization (deserialize then re-serialize).
|
|
285
|
-
*/
|
|
286
|
-
function serializeHierarchicalWitness(bundle) {
|
|
287
|
-
const parts = [];
|
|
288
|
-
// Witness.signatureCount (MiniNumber) - 1 Signature object containing N proofs
|
|
289
|
-
parts.push(serializeMiniNumber(1n));
|
|
290
|
-
// Signature.proofCount (MiniNumber) - N SignatureProofs inside the Signature
|
|
291
|
-
parts.push(serializeMiniNumber(BigInt(bundle.proofs.length)));
|
|
292
|
-
for (const proofHex of bundle.proofs) {
|
|
293
|
-
const publicKey = fromHex(proofHex.leafPubkey);
|
|
294
|
-
const signature = fromHex(proofHex.signature);
|
|
295
|
-
const mmrProofBytes = fromHex(proofHex.mmrProof); // Already serialized
|
|
296
|
-
// Serialize SignatureProof with pre-serialized MMR bytes
|
|
297
|
-
parts.push(serializeSignatureProofFromBytes(publicKey, signature, mmrProofBytes));
|
|
298
|
-
}
|
|
299
|
-
return concat(...parts);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* @deprecated (2026-01) This function's output is NOT used in the main Totem transaction flow.
|
|
303
|
-
* MinimaTransactionBuilder.serializeWitness in the extension handles actual witness serialization.
|
|
304
|
-
* Kept for API compatibility and potential future direct SDK usage.
|
|
305
|
-
*
|
|
306
|
-
* Serialize hierarchical witness bundle to hex string for transport
|
|
307
|
-
*/
|
|
308
|
-
function serializeHierarchicalWitnessToHex(bundle) {
|
|
309
|
-
const bytes = serializeHierarchicalWitness(bundle);
|
|
310
|
-
return toHex(bytes);
|
|
311
|
-
}
|