@ledgerhq/hw-app-canton 0.6.0 → 0.7.0-nightly.1

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @ledgerhq/hw-app-canton@0.6.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-canton
2
+ > @ledgerhq/hw-app-canton@0.7.0-nightly.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-canton
3
3
  > tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ledgerhq/hw-app-canton
2
2
 
3
+ ## 0.7.0-nightly.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#12405](https://github.com/LedgerHQ/ledger-live/pull/12405) [`0a5188a`](https://github.com/LedgerHQ/ledger-live/commit/0a5188aecac545b677cd5d4e8256bbb97081d269) Thanks [@ishaba](https://github.com/ishaba)! - add challenge support for canton onboarding request
8
+
9
+ ## 0.7.0-nightly.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#12173](https://github.com/LedgerHQ/ledger-live/pull/12173) [`f4965d6`](https://github.com/LedgerHQ/ledger-live/commit/f4965d6dfc64949b0afa765cc9e4b24324b5df1d) Thanks [@ishaba](https://github.com/ishaba)! - add canton full transaction signing support
14
+
3
15
  ## 0.6.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -55,12 +55,13 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
55
55
 
56
56
  #### signTransaction
57
57
 
58
- Sign a Canton transaction.
58
+ Sign a Canton transaction
59
+ using the appropriate signing method based on transaction type.
59
60
 
60
61
  ##### Parameters
61
62
 
62
63
  * `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP-32 format
63
- * `txHash` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the transaction hash to sign
64
+ * `data` **(CantonPreparedTransaction | CantonUntypedVersionedMessage | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))** either prepared transaction components, untyped versioned message, or txHash string (backwards compatibility)
64
65
 
65
66
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<CantonSignature>** the signature
66
67
 
package/lib/Canton.d.ts CHANGED
@@ -7,7 +7,20 @@ export type CantonAddress = {
7
7
  address: string;
8
8
  path: string;
9
9
  };
10
- export type CantonSignature = string;
10
+ export type CantonSignature = {
11
+ signature: string;
12
+ applicationSignature?: string;
13
+ };
14
+ export type CantonPreparedTransaction = {
15
+ damlTransaction: Uint8Array;
16
+ nodes: Uint8Array[];
17
+ metadata: Uint8Array;
18
+ inputContracts: Uint8Array[];
19
+ };
20
+ export type CantonUntypedVersionedMessage = {
21
+ transactions: string[];
22
+ challenge?: string;
23
+ };
11
24
  /**
12
25
  * Canton BOLOS API
13
26
  */
@@ -23,29 +36,65 @@ export default class Canton {
23
36
  */
24
37
  getAddress(path: string, display?: boolean): Promise<CantonAddress>;
25
38
  /**
26
- * Sign a Canton transaction.
39
+ * Sign a Canton transaction
40
+ * using the appropriate signing method based on transaction type.
27
41
  *
28
42
  * @param path a path in BIP-32 format
29
- * @param txHash the transaction hash to sign
43
+ * @param data either prepared transaction components, untyped versioned message, or txHash string (backwards compatibility)
30
44
  * @return the signature
31
45
  */
32
- signTransaction(path: string, txHash: string): Promise<CantonSignature>;
46
+ signTransaction(path: string, data: CantonPreparedTransaction | CantonUntypedVersionedMessage | string): Promise<CantonSignature>;
47
+ /**
48
+ * Sign a transaction hash (backwards compatibility)
49
+ * @private
50
+ */
51
+ private signTxHash;
52
+ /**
53
+ * Sign a prepared Canton transaction
54
+ * @private
55
+ */
56
+ private signPreparedTransaction;
57
+ /**
58
+ * Sign topology transactions for Canton onboarding
59
+ * @private
60
+ */
61
+ private signUntypedVersionedMessage;
33
62
  /**
34
63
  * Get the app configuration.
35
64
  * @return the app configuration including version
36
65
  */
37
66
  getAppConfiguration(): Promise<AppConfig>;
38
67
  /**
39
- * Converts 65-byte Canton format to 64-byte Ed25519:
40
- * [40][64_bytes_signature][00] (132 hex chars)
68
+ * Validate Uint8Array with descriptive error message
69
+ * @private
70
+ */
71
+ private validateUint8Array;
72
+ /**
73
+ * Unified chunking strategy for sending data to device
74
+ * @private
75
+ */
76
+ private sendChunkedData;
77
+ /**
78
+ * Create optimized chunks from payload
79
+ * @private
80
+ */
81
+ private createChunks;
82
+ /**
83
+ * Parse signature response - handles both TLV format (onboarding) and single signatures
84
+ * @private
85
+ */
86
+ private parseSignatureResponse;
87
+ /**
88
+ * Check transport response for errors and throw appropriate exceptions
41
89
  * @private
42
90
  */
43
- private cleanSignatureFormat;
91
+ private checkTransportResponse;
44
92
  /**
45
- * Helper method to handle transport response and check for errors
93
+ * Extract response data from transport response
94
+ * APDU responses have format: [data][status_code(2_bytes)]
46
95
  * @private
47
96
  */
48
- private handleTransportResponse;
97
+ private extractResponseData;
49
98
  /**
50
99
  * Serialize a BIP path to a data buffer for Canton BOLOS
51
100
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"Canton.d.ts","sourceRoot":"","sources":["../src/Canton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAiCpD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS,EAAE,WAAW,SAAgC;IAU7E;;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E,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS,EAAE,WAAW,SAAgC;IAU7E;;;;;;OAMG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAoBhF;;;;;;;OAOG;IACG,eAAe,CACnB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,yBAAyB,GAAG,6BAA6B,GAAG,MAAM,GACvE,OAAO,CAAC,eAAe,CAAC;IAa3B;;;OAGG;YACW,UAAU;IA+BxB;;;OAGG;YACW,uBAAuB;IA4ErC;;;OAGG;YACW,2BAA2B;IA4EzC;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC;IAkB/C;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;;OAGG;YACW,eAAe;IAmC7B;;;OAGG;IACH,OAAO,CAAC,YAAY;IAkBpB;;;OAGG;IAEH,OAAO,CAAC,sBAAsB;IAkC9B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAQ9B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAU1B;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAwBpC;;;OAGG;IACH,OAAO,CAAC,cAAc;CAOvB"}
package/lib/Canton.js CHANGED
@@ -8,13 +8,11 @@ const bip32_path_1 = __importDefault(require("bip32-path"));
8
8
  const CLA = 0xe0;
9
9
  const P1_NON_CONFIRM = 0x00;
10
10
  const P1_CONFIRM = 0x01;
11
- // P2 indicating no information.
11
+ const P1_SIGN_UNTYPED_VERSIONED_MESSAGE = 0x01;
12
+ const P1_SIGN_PREPARED_TRANSACTION = 0x02;
12
13
  const P2_NONE = 0x00;
13
- // P2 indicating first APDU in a large request.
14
14
  const P2_FIRST = 0x01;
15
- // P2 indicating that this is not the last APDU in a large request.
16
15
  const P2_MORE = 0x02;
17
- // P2 indicating that this is the last APDU of a message in a multi message request.
18
16
  const P2_MSG_END = 0x04;
19
17
  const INS = {
20
18
  GET_VERSION: 0x03,
@@ -28,6 +26,7 @@ const STATUS = {
28
26
  };
29
27
  const ED25519_SIGNATURE_HEX_LENGTH = 128; // hex characters (64 bytes)
30
28
  const CANTON_SIGNATURE_HEX_LENGTH = 132; // hex characters (66 bytes with framing)
29
+ const MAX_APDU_DATA_LENGTH = 255;
31
30
  /**
32
31
  * Canton BOLOS API
33
32
  */
@@ -49,7 +48,8 @@ class Canton {
49
48
  const serializedPath = this.serializePath(bipPath);
50
49
  const p1 = display ? P1_CONFIRM : P1_NON_CONFIRM;
51
50
  const response = await this.transport.send(CLA, INS.GET_ADDR, p1, P2_NONE, serializedPath);
52
- const responseData = this.handleTransportResponse(response, "address");
51
+ this.checkTransportResponse(response);
52
+ const responseData = this.extractResponseData(response);
53
53
  const { publicKey } = this.extractPublicKeyAndChainCode(responseData);
54
54
  const address = "canton_" + this.publicKeyToAddress(publicKey);
55
55
  return {
@@ -59,23 +59,153 @@ class Canton {
59
59
  };
60
60
  }
61
61
  /**
62
- * Sign a Canton transaction.
62
+ * Sign a Canton transaction
63
+ * using the appropriate signing method based on transaction type.
63
64
  *
64
65
  * @param path a path in BIP-32 format
65
- * @param txHash the transaction hash to sign
66
+ * @param data either prepared transaction components, untyped versioned message, or txHash string (backwards compatibility)
66
67
  * @return the signature
67
68
  */
68
- async signTransaction(path, txHash) {
69
+ async signTransaction(path, data) {
70
+ // Backwards compatibility: handle txHash string format
71
+ if (typeof data === "string") {
72
+ return this.signTxHash(path, data);
73
+ }
74
+ if ("damlTransaction" in data) {
75
+ return this.signPreparedTransaction(path, data);
76
+ }
77
+ else {
78
+ return this.signUntypedVersionedMessage(path, data);
79
+ }
80
+ }
81
+ /**
82
+ * Sign a transaction hash (backwards compatibility)
83
+ * @private
84
+ */
85
+ async signTxHash(path, txHash) {
86
+ // 1. Send the derivation path
87
+ const bipPath = bip32_path_1.default.fromString(path).toPathArray();
88
+ const serializedPath = this.serializePath(bipPath);
89
+ const pathResponse = await this.transport.send(CLA, INS.SIGN, P1_SIGN_UNTYPED_VERSIONED_MESSAGE, P2_FIRST | P2_MORE, serializedPath);
90
+ this.checkTransportResponse(pathResponse);
91
+ // 2. Send the transaction hash as a single transaction
92
+ const transactionBuffer = Buffer.from(txHash, "hex");
93
+ const response = await this.transport.send(CLA, INS.SIGN, P1_SIGN_UNTYPED_VERSIONED_MESSAGE, P2_MSG_END, transactionBuffer);
94
+ this.checkTransportResponse(response);
95
+ const responseData = this.extractResponseData(response);
96
+ return this.parseSignatureResponse(responseData);
97
+ }
98
+ /**
99
+ * Sign a prepared Canton transaction
100
+ * @private
101
+ */
102
+ async signPreparedTransaction(path, components) {
103
+ let responseData = null;
69
104
  // 1. Send the derivation path
70
105
  const bipPath = bip32_path_1.default.fromString(path).toPathArray();
71
106
  const serializedPath = this.serializePath(bipPath);
72
- const pathResponse = await this.transport.send(CLA, INS.SIGN, P1_NON_CONFIRM, P2_FIRST | P2_MORE, serializedPath);
73
- this.handleTransportResponse(pathResponse, "transaction");
74
- // 2. Send the transaction hash
75
- const response = await this.transport.send(CLA, INS.SIGN, P1_NON_CONFIRM, P2_MSG_END, Buffer.from(txHash, "hex"));
76
- const responseData = this.handleTransportResponse(response, "transaction");
77
- const rawSignature = responseData.toString("hex");
78
- return this.cleanSignatureFormat(rawSignature);
107
+ const pathResponse = await this.transport.send(CLA, INS.SIGN, P1_SIGN_PREPARED_TRANSACTION, P2_FIRST | P2_MORE, serializedPath);
108
+ this.checkTransportResponse(pathResponse);
109
+ // 2. Send the DAML transaction
110
+ await this.sendChunkedData({
111
+ ins: INS.SIGN,
112
+ p1: P1_SIGN_PREPARED_TRANSACTION,
113
+ payload: Buffer.from(components.damlTransaction),
114
+ isFinal: false,
115
+ });
116
+ // 3. Send each node
117
+ for (const [i, node] of components.nodes.entries()) {
118
+ this.validateUint8Array(node, `Node at index ${i}`);
119
+ await this.sendChunkedData({
120
+ ins: INS.SIGN,
121
+ p1: P1_SIGN_PREPARED_TRANSACTION,
122
+ payload: Buffer.from(node),
123
+ isFinal: false,
124
+ });
125
+ }
126
+ // 4. Send the metadata
127
+ const isFinal = components.inputContracts.length === 0;
128
+ const result = await this.sendChunkedData({
129
+ ins: INS.SIGN,
130
+ p1: P1_SIGN_PREPARED_TRANSACTION,
131
+ payload: Buffer.from(components.metadata),
132
+ isFinal,
133
+ });
134
+ if (isFinal) {
135
+ responseData = result;
136
+ }
137
+ // 5. Send each input contract - last one should return data
138
+ for (const [i, inputContract] of components.inputContracts.entries()) {
139
+ this.validateUint8Array(inputContract, `Input contract at index ${i}`);
140
+ const isFinal = i === components.inputContracts.length - 1;
141
+ const result = await this.sendChunkedData({
142
+ ins: INS.SIGN,
143
+ p1: P1_SIGN_PREPARED_TRANSACTION,
144
+ payload: Buffer.from(inputContract),
145
+ isFinal,
146
+ });
147
+ if (isFinal) {
148
+ responseData = result;
149
+ }
150
+ }
151
+ if (!responseData) {
152
+ throw new Error("No response data received from device");
153
+ }
154
+ return this.parseSignatureResponse(responseData);
155
+ }
156
+ /**
157
+ * Sign topology transactions for Canton onboarding
158
+ * @private
159
+ */
160
+ async signUntypedVersionedMessage(path, data) {
161
+ const { transactions, challenge } = data;
162
+ if (!transactions || transactions.length === 0) {
163
+ throw new TypeError("At least one transaction is required");
164
+ }
165
+ // 1. Send the derivation path with optional challenge
166
+ const bipPath = bip32_path_1.default.fromString(path).toPathArray();
167
+ const serializedPath = this.serializePath(bipPath);
168
+ let pathData = serializedPath;
169
+ if (challenge) {
170
+ const challengeBuffer = Buffer.from(challenge, "hex");
171
+ pathData = Buffer.concat([serializedPath, challengeBuffer]);
172
+ }
173
+ const pathResponse = await this.transport.send(CLA, INS.SIGN, P1_SIGN_UNTYPED_VERSIONED_MESSAGE, P2_FIRST | P2_MORE, pathData);
174
+ this.checkTransportResponse(pathResponse);
175
+ // 2. Send each transaction using chunking for large data
176
+ for (const [i, transaction] of transactions.entries()) {
177
+ if (!transaction) {
178
+ throw new TypeError(`Transaction at index ${i} is undefined or null`);
179
+ }
180
+ const transactionBuffer = Buffer.from(transaction, "hex");
181
+ const isLastTransaction = i === transactions.length - 1;
182
+ if (transactionBuffer.length <= MAX_APDU_DATA_LENGTH) {
183
+ // Small transaction - send directly
184
+ const p2 = isLastTransaction ? P2_MSG_END : P2_MORE | P2_MSG_END;
185
+ const response = await this.transport.send(CLA, INS.SIGN, P1_SIGN_UNTYPED_VERSIONED_MESSAGE, p2, transactionBuffer);
186
+ if (isLastTransaction) {
187
+ this.checkTransportResponse(response);
188
+ const responseData = this.extractResponseData(response);
189
+ return this.parseSignatureResponse(responseData, challenge);
190
+ }
191
+ else {
192
+ this.checkTransportResponse(response);
193
+ }
194
+ }
195
+ else {
196
+ // Large transaction - use chunking
197
+ const responseData = await this.sendChunkedData({
198
+ ins: INS.SIGN,
199
+ p1: P1_SIGN_UNTYPED_VERSIONED_MESSAGE,
200
+ payload: transactionBuffer,
201
+ isFinal: isLastTransaction,
202
+ });
203
+ if (isLastTransaction && responseData) {
204
+ return this.parseSignatureResponse(responseData, challenge);
205
+ }
206
+ }
207
+ }
208
+ throw new TypeError("No transactions provided");
79
209
  }
80
210
  /**
81
211
  * Get the app configuration.
@@ -83,46 +213,114 @@ class Canton {
83
213
  */
84
214
  async getAppConfiguration() {
85
215
  const response = await this.transport.send(CLA, INS.GET_VERSION, P1_NON_CONFIRM, P2_NONE, Buffer.alloc(0));
86
- const responseData = this.handleTransportResponse(response, "version");
216
+ this.checkTransportResponse(response);
217
+ const responseData = this.extractResponseData(response);
87
218
  const { major, minor, patch } = this.extractVersion(responseData);
88
219
  return {
89
220
  version: `${major}.${minor}.${patch}`,
90
221
  };
91
222
  }
92
223
  /**
93
- * Converts 65-byte Canton format to 64-byte Ed25519:
94
- * [40][64_bytes_signature][00] (132 hex chars)
224
+ * Validate Uint8Array with descriptive error message
225
+ * @private
226
+ */
227
+ validateUint8Array(value, context) {
228
+ if (!value) {
229
+ throw new TypeError(`${context} is undefined or null`);
230
+ }
231
+ if (!(value instanceof Uint8Array)) {
232
+ throw new TypeError(`${context} is not a Uint8Array: ${typeof value}`);
233
+ }
234
+ }
235
+ /**
236
+ * Unified chunking strategy for sending data to device
95
237
  * @private
96
238
  */
97
- cleanSignatureFormat(signature) {
239
+ async sendChunkedData({ ins, p1, payload, isFinal = false, }) {
240
+ const chunks = this.createChunks(payload);
241
+ let responseData = null;
242
+ for (let i = 0; i < chunks.length; i++) {
243
+ const isLastChunk = i === chunks.length - 1;
244
+ let p2 = P2_MORE;
245
+ if (isLastChunk) {
246
+ p2 = isFinal ? P2_MSG_END : P2_MORE | P2_MSG_END;
247
+ }
248
+ const response = await this.transport.send(CLA, ins, p1, p2, chunks[i]);
249
+ if (isFinal && isLastChunk) {
250
+ this.checkTransportResponse(response);
251
+ responseData = this.extractResponseData(response);
252
+ }
253
+ else {
254
+ this.checkTransportResponse(response);
255
+ }
256
+ }
257
+ return responseData;
258
+ }
259
+ /**
260
+ * Create optimized chunks from payload
261
+ * @private
262
+ */
263
+ createChunks(payload) {
264
+ if (payload.length <= MAX_APDU_DATA_LENGTH) {
265
+ return [payload];
266
+ }
267
+ const totalChunks = Math.ceil(payload.length / MAX_APDU_DATA_LENGTH);
268
+ const chunks = new Array(totalChunks);
269
+ let offset = 0;
270
+ for (let i = 0; i < totalChunks; i++) {
271
+ const chunkSize = Math.min(MAX_APDU_DATA_LENGTH, payload.length - offset);
272
+ chunks[i] = payload.slice(offset, offset + chunkSize);
273
+ offset += chunkSize;
274
+ }
275
+ return chunks;
276
+ }
277
+ /**
278
+ * Parse signature response - handles both TLV format (onboarding) and single signatures
279
+ * @private
280
+ */
281
+ parseSignatureResponse(response, challenge) {
282
+ // Handle TLV (Type-Length-Value) format: [40][64B main][00][40][64B challenge] = 262 hex chars (131 bytes)
283
+ if (response.length === 131 &&
284
+ response.readUInt8(0) === 0x40 &&
285
+ response.readUInt8(65) === 0x00 &&
286
+ response.readUInt8(66) === 0x40) {
287
+ const signature = response.slice(1, 65).toString("hex");
288
+ const applicationSignature = response.slice(67, 131).toString("hex");
289
+ return {
290
+ signature,
291
+ ...(challenge && { applicationSignature }),
292
+ };
293
+ }
294
+ // Handle single signature formats
295
+ const signature = response.toString("hex");
296
+ // Pure 64-byte Ed25519 signature = 128 hex chars (64 bytes)
98
297
  if (signature.length === ED25519_SIGNATURE_HEX_LENGTH) {
99
- return signature;
298
+ return { signature };
100
299
  }
300
+ // Canton-framed signature: [40][64B Ed25519 sig][00] = 132 hex chars (65 bytes)
101
301
  if (signature.length === CANTON_SIGNATURE_HEX_LENGTH) {
102
302
  const cleanedSignature = signature.slice(2, -2);
103
- return cleanedSignature;
303
+ return { signature: cleanedSignature };
104
304
  }
105
- console.warn(`[Canton]: Unknown signature format (${signature.length} chars)`);
106
- return signature;
305
+ return { signature };
107
306
  }
108
307
  /**
109
- * Helper method to handle transport response and check for errors
308
+ * Check transport response for errors and throw appropriate exceptions
110
309
  * @private
111
310
  */
112
- handleTransportResponse(response, errorType) {
311
+ checkTransportResponse(response) {
113
312
  const statusCode = response.readUInt16BE(response.length - 2);
114
- const responseData = response.slice(0, response.length - 2);
115
- if (statusCode === STATUS.USER_CANCEL) {
116
- switch (errorType) {
117
- case "address":
118
- throw new errors_1.UserRefusedAddress();
119
- case "transaction":
120
- throw new errors_1.UserRefusedOnDevice();
121
- default:
122
- throw new Error();
123
- }
313
+ if (statusCode !== STATUS.OK) {
314
+ throw new errors_1.TransportStatusError(statusCode);
124
315
  }
125
- return responseData;
316
+ }
317
+ /**
318
+ * Extract response data from transport response
319
+ * APDU responses have format: [data][status_code(2_bytes)]
320
+ * @private
321
+ */
322
+ extractResponseData(response) {
323
+ return response.slice(0, -2);
126
324
  }
127
325
  /**
128
326
  * Serialize a BIP path to a data buffer for Canton BOLOS
@@ -177,9 +375,9 @@ class Canton {
177
375
  */
178
376
  extractVersion(data) {
179
377
  return {
180
- major: parseInt(data.subarray(0, 1).toString("hex"), 16),
181
- minor: parseInt(data.subarray(1, 2).toString("hex"), 16),
182
- patch: parseInt(data.subarray(2, 3).toString("hex"), 16),
378
+ major: Number.parseInt(data.subarray(0, 1).toString("hex"), 16),
379
+ minor: Number.parseInt(data.subarray(1, 2).toString("hex"), 16),
380
+ patch: Number.parseInt(data.subarray(2, 3).toString("hex"), 16),
183
381
  };
184
382
  }
185
383
  }
package/lib/Canton.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Canton.js","sourceRoot":"","sources":["../src/Canton.ts"],"names":[],"mappings":";;;;;AACA,6CAA2E;AAC3E,4DAAiC;AAEjC,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,gCAAgC;AAChC,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,+CAA+C;AAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,mEAAmE;AACnE,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,oFAAoF;AACpF,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAM,GAAG,GAAG;IACV,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,EAAE,EAAE,MAAM;IACV,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAM,4BAA4B,GAAG,GAAG,CAAC,CAAC,4BAA4B;AACtE,MAAM,2BAA2B,GAAG,GAAG,CAAC,CAAC,yCAAyC;AAclF;;GAEG;AACH,MAAqB,MAAM;IACzB,SAAS,CAAY;IAErB,YAAY,SAAoB,EAAE,WAAW,GAAG,6BAA6B;QAC3E,IAAI,CAAC,SAAS,GAAG,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GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,IAAI,CAAC,CAAC;QAEZ,qBAAqB;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC;QAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IACrF,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,IAAY;QACjC,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YAC/D,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YAC/D,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;SAChE,CAAC;IACJ,CAAC;CACF;AApeD,yBAoeC"}
@@ -7,7 +7,20 @@ export type CantonAddress = {
7
7
  address: string;
8
8
  path: string;
9
9
  };
10
- export type CantonSignature = string;
10
+ export type CantonSignature = {
11
+ signature: string;
12
+ applicationSignature?: string;
13
+ };
14
+ export type CantonPreparedTransaction = {
15
+ damlTransaction: Uint8Array;
16
+ nodes: Uint8Array[];
17
+ metadata: Uint8Array;
18
+ inputContracts: Uint8Array[];
19
+ };
20
+ export type CantonUntypedVersionedMessage = {
21
+ transactions: string[];
22
+ challenge?: string;
23
+ };
11
24
  /**
12
25
  * Canton BOLOS API
13
26
  */
@@ -23,29 +36,65 @@ export default class Canton {
23
36
  */
24
37
  getAddress(path: string, display?: boolean): Promise<CantonAddress>;
25
38
  /**
26
- * Sign a Canton transaction.
39
+ * Sign a Canton transaction
40
+ * using the appropriate signing method based on transaction type.
27
41
  *
28
42
  * @param path a path in BIP-32 format
29
- * @param txHash the transaction hash to sign
43
+ * @param data either prepared transaction components, untyped versioned message, or txHash string (backwards compatibility)
30
44
  * @return the signature
31
45
  */
32
- signTransaction(path: string, txHash: string): Promise<CantonSignature>;
46
+ signTransaction(path: string, data: CantonPreparedTransaction | CantonUntypedVersionedMessage | string): Promise<CantonSignature>;
47
+ /**
48
+ * Sign a transaction hash (backwards compatibility)
49
+ * @private
50
+ */
51
+ private signTxHash;
52
+ /**
53
+ * Sign a prepared Canton transaction
54
+ * @private
55
+ */
56
+ private signPreparedTransaction;
57
+ /**
58
+ * Sign topology transactions for Canton onboarding
59
+ * @private
60
+ */
61
+ private signUntypedVersionedMessage;
33
62
  /**
34
63
  * Get the app configuration.
35
64
  * @return the app configuration including version
36
65
  */
37
66
  getAppConfiguration(): Promise<AppConfig>;
38
67
  /**
39
- * Converts 65-byte Canton format to 64-byte Ed25519:
40
- * [40][64_bytes_signature][00] (132 hex chars)
68
+ * Validate Uint8Array with descriptive error message
69
+ * @private
70
+ */
71
+ private validateUint8Array;
72
+ /**
73
+ * Unified chunking strategy for sending data to device
74
+ * @private
75
+ */
76
+ private sendChunkedData;
77
+ /**
78
+ * Create optimized chunks from payload
79
+ * @private
80
+ */
81
+ private createChunks;
82
+ /**
83
+ * Parse signature response - handles both TLV format (onboarding) and single signatures
84
+ * @private
85
+ */
86
+ private parseSignatureResponse;
87
+ /**
88
+ * Check transport response for errors and throw appropriate exceptions
41
89
  * @private
42
90
  */
43
- private cleanSignatureFormat;
91
+ private checkTransportResponse;
44
92
  /**
45
- * Helper method to handle transport response and check for errors
93
+ * Extract response data from transport response
94
+ * APDU responses have format: [data][status_code(2_bytes)]
46
95
  * @private
47
96
  */
48
- private handleTransportResponse;
97
+ private extractResponseData;
49
98
  /**
50
99
  * Serialize a BIP path to a data buffer for Canton BOLOS
51
100
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"Canton.d.ts","sourceRoot":"","sources":["../src/Canton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAiCpD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS,EAAE,WAAW,SAAgC;IAU7E;;;;;;OAMG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBhF;;;;;;OAMG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA8B7E;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC;IAiB/C;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAqB/B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAU1B;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAwBpC;;;OAGG;IACH,OAAO,CAAC,cAAc;CAOvB"}
1
+ {"version":3,"file":"Canton.d.ts","sourceRoot":"","sources":["../src/Canton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAgCpD,MAAM,MA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