@ledgerhq/hw-app-canton 0.2.0-nightly.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/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +5 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE.txt +21 -0
- package/README.md +76 -0
- package/__tests__/Canton.test.ts +122 -0
- package/jest.config.ts +24 -0
- package/lib/Canton.d.ts +48 -0
- package/lib/Canton.d.ts.map +1 -0
- package/lib/Canton.js +125 -0
- package/lib/Canton.js.map +1 -0
- package/lib/MockDevice.d.ts +24 -0
- package/lib/MockDevice.d.ts.map +1 -0
- package/lib/MockDevice.js +141 -0
- package/lib/MockDevice.js.map +1 -0
- package/lib-es/Canton.d.ts +48 -0
- package/lib-es/Canton.d.ts.map +1 -0
- package/lib-es/Canton.js +119 -0
- package/lib-es/Canton.js.map +1 -0
- package/lib-es/MockDevice.d.ts +24 -0
- package/lib-es/MockDevice.d.ts.map +1 -0
- package/lib-es/MockDevice.js +137 -0
- package/lib-es/MockDevice.js.map +1 -0
- package/package.json +57 -0
- package/src/Canton.ts +153 -0
- package/src/MockDevice.ts +170 -0
- package/tsconfig.json +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @ledgerhq/hw-app-canton
|
|
2
|
+
|
|
3
|
+
## 0.2.0-nightly.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#11200](https://github.com/LedgerHQ/ledger-live/pull/11200) [`6398e5f`](https://github.com/LedgerHQ/ledger-live/commit/6398e5f90bd6ca5c1c4d850da731d4e7f020ea3a) Thanks [@ishaba](https://github.com/ishaba)! - Canton signer init
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#11216](https://github.com/LedgerHQ/ledger-live/pull/11216) [`4d14752`](https://github.com/LedgerHQ/ledger-live/commit/4d14752360435f27f07768302a715cd2f39f59ac) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Fix CI checks issue
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`6398e5f`](https://github.com/LedgerHQ/ledger-live/commit/6398e5f90bd6ca5c1c4d850da731d4e7f020ea3a)]:
|
|
14
|
+
- @ledgerhq/coin-canton@0.2.0-nightly.2
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present Ledger https://www.ledger.com/
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<img src="https://user-images.githubusercontent.com/4631227/191834116-59cf590e-25cc-4956-ae5c-812ea464f324.png" height="100" />
|
|
2
|
+
|
|
3
|
+
[GitHub](https://github.com/LedgerHQ/ledger-live/),
|
|
4
|
+
[Ledger Devs Discord](https://developers.ledger.com/discord-pro),
|
|
5
|
+
[Developer Portal](https://developers.ledger.com/)
|
|
6
|
+
|
|
7
|
+
## @ledgerhq/hw-app-canton
|
|
8
|
+
|
|
9
|
+
Ledger Hardware Wallet Canton JavaScript bindings.
|
|
10
|
+
|
|
11
|
+
***
|
|
12
|
+
|
|
13
|
+
## Are you adding Ledger support to your software wallet?
|
|
14
|
+
|
|
15
|
+
You may be using this package to communicate with the Canton Nano App.
|
|
16
|
+
|
|
17
|
+
For a smooth and quick integration:
|
|
18
|
+
|
|
19
|
+
* See the developers’ documentation on the [Developer Portal](https://developers.ledger.com/docs/transport/overview/) and
|
|
20
|
+
* Go on [Discord](https://developers.ledger.com/discord-pro/) to chat with developer support and the developer community.
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
25
|
+
|
|
26
|
+
#### Table of Contents
|
|
27
|
+
|
|
28
|
+
* [Canton](#canton)
|
|
29
|
+
* [Parameters](#parameters)
|
|
30
|
+
* [getAddress](#getaddress)
|
|
31
|
+
* [Parameters](#parameters-1)
|
|
32
|
+
* [signTransaction](#signtransaction)
|
|
33
|
+
* [Parameters](#parameters-2)
|
|
34
|
+
* [getAppConfiguration](#getappconfiguration)
|
|
35
|
+
* [MockCantonDevice](#mockcantondevice)
|
|
36
|
+
|
|
37
|
+
### Canton
|
|
38
|
+
|
|
39
|
+
Canton BOLOS API
|
|
40
|
+
|
|
41
|
+
#### Parameters
|
|
42
|
+
|
|
43
|
+
* `transport` **Transport** 
|
|
44
|
+
* `scrambleKey` (optional, default `"canton_default_scramble_key"`)
|
|
45
|
+
|
|
46
|
+
#### getAddress
|
|
47
|
+
|
|
48
|
+
Get a Canton address for a given BIP-32 path.
|
|
49
|
+
|
|
50
|
+
##### Parameters
|
|
51
|
+
|
|
52
|
+
* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP-32 format
|
|
53
|
+
* `display` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** whether to display the address on the device (optional, default `false`)
|
|
54
|
+
|
|
55
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<CantonAddress>** the address and public key
|
|
56
|
+
|
|
57
|
+
#### signTransaction
|
|
58
|
+
|
|
59
|
+
Sign a Canton transaction.
|
|
60
|
+
|
|
61
|
+
##### Parameters
|
|
62
|
+
|
|
63
|
+
* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP-32 format
|
|
64
|
+
* `rawTx` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the raw transaction to sign
|
|
65
|
+
|
|
66
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<CantonSignature>** the signature
|
|
67
|
+
|
|
68
|
+
#### getAppConfiguration
|
|
69
|
+
|
|
70
|
+
Get the app configuration.
|
|
71
|
+
|
|
72
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<AppConfig>** the app configuration including version
|
|
73
|
+
|
|
74
|
+
### MockCantonDevice
|
|
75
|
+
|
|
76
|
+
Mock Canton "@ledgerhq/hw-app-canton" device implementation for development and testing
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { openTransportReplayer, RecordStore } from "@ledgerhq/hw-transport-mocker";
|
|
2
|
+
import Canton from "../src/Canton";
|
|
3
|
+
|
|
4
|
+
describe("Canton", () => {
|
|
5
|
+
describe("decorateAppAPIMethods", () => {
|
|
6
|
+
it("should properly decorate transport methods", async () => {
|
|
7
|
+
const transport = await openTransportReplayer(new RecordStore());
|
|
8
|
+
const canton = new Canton(transport);
|
|
9
|
+
|
|
10
|
+
expect(canton.transport).toBeDefined();
|
|
11
|
+
expect(typeof canton.getAddress).toBe("function");
|
|
12
|
+
expect(typeof canton.signTransaction).toBe("function");
|
|
13
|
+
expect(typeof canton.getAppConfiguration).toBe("function");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe("getAddress", () => {
|
|
18
|
+
it("should get address without display", async () => {
|
|
19
|
+
const transport = await openTransportReplayer(
|
|
20
|
+
RecordStore.fromString(`
|
|
21
|
+
=> e005000015058000002c80001a6f800000008000000080000000
|
|
22
|
+
<= 4d65a10662b9759d62bb59048366705454654cf4f9b4b3525cf314429e46c6919000
|
|
23
|
+
`)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const canton = new Canton(transport);
|
|
27
|
+
const result = await canton.getAddress("44'/6767'/0'/0'/0'");
|
|
28
|
+
|
|
29
|
+
expect(result).toBeDefined();
|
|
30
|
+
expect(result.address).toBeDefined();
|
|
31
|
+
expect(result.publicKey).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should get address with display", async () => {
|
|
35
|
+
const transport = await openTransportReplayer(
|
|
36
|
+
RecordStore.fromString(`
|
|
37
|
+
=> e005010015058000002c80001a6f800000008000000080000000
|
|
38
|
+
<= 4d65a10662b9759d62bb59048366705454654cf4f9b4b3525cf314429e46c6919000
|
|
39
|
+
`)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const canton = new Canton(transport);
|
|
43
|
+
const result = await canton.getAddress("44'/6767'/0'/0'/0'", true);
|
|
44
|
+
|
|
45
|
+
expect(result).toBeDefined();
|
|
46
|
+
expect(result.address).toBeDefined();
|
|
47
|
+
expect(result.publicKey).toBeDefined();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should throw on invalid derivation path", async () => {
|
|
51
|
+
const transport = await openTransportReplayer(new RecordStore());
|
|
52
|
+
const canton = new Canton(transport);
|
|
53
|
+
|
|
54
|
+
return expect(
|
|
55
|
+
canton.getAddress("invalid path")
|
|
56
|
+
).rejects.toThrow();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("should handle various derivation paths", async () => {
|
|
60
|
+
const transport = await openTransportReplayer(
|
|
61
|
+
RecordStore.fromString(`
|
|
62
|
+
=> e005000015058000002c80001a6f800000008000000080000001
|
|
63
|
+
<= 5e66a10773c0860e73bb6015947806555765df5f9b5b4636df4255a57c57d7029000
|
|
64
|
+
`)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const canton = new Canton(transport);
|
|
68
|
+
const result = await canton.getAddress("44'/6767'/0'/0'/1'");
|
|
69
|
+
|
|
70
|
+
expect(result).toBeDefined();
|
|
71
|
+
expect(result.address).toBeDefined();
|
|
72
|
+
expect(result.publicKey).toBeDefined();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// should handle user refused address
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("signTransaction", () => {
|
|
79
|
+
// should sign transaction
|
|
80
|
+
|
|
81
|
+
// should handle large transaction payloads
|
|
82
|
+
|
|
83
|
+
// should handle empty transaction
|
|
84
|
+
|
|
85
|
+
// should request blind signature when required
|
|
86
|
+
|
|
87
|
+
it("should handle user refused transaction", async () => {
|
|
88
|
+
const transport = await openTransportReplayer(
|
|
89
|
+
RecordStore.fromString(`
|
|
90
|
+
=> e006010015058000002c80001a6f800000008000000080000000
|
|
91
|
+
<= 6985
|
|
92
|
+
`)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const canton = new Canton(transport);
|
|
96
|
+
|
|
97
|
+
return expect(
|
|
98
|
+
canton.signTransaction("44'/6767'/0'/0'/0'", "test")
|
|
99
|
+
).rejects.toThrow();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe("getAppConfiguration", () => {
|
|
104
|
+
it("should get app configuration", async () => {
|
|
105
|
+
const transport = await openTransportReplayer(
|
|
106
|
+
RecordStore.fromString(`
|
|
107
|
+
=> e004000000
|
|
108
|
+
<= 00000100069000
|
|
109
|
+
`)
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const canton = new Canton(transport);
|
|
113
|
+
const result = await canton.getAppConfiguration();
|
|
114
|
+
|
|
115
|
+
expect(result).toBeDefined();
|
|
116
|
+
expect(result).toHaveProperty("version");
|
|
117
|
+
expect(typeof result.version).toBe("string");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// should handle configuration error
|
|
121
|
+
});
|
|
122
|
+
});
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import baseConfig from "../../jest.config";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...baseConfig,
|
|
5
|
+
rootDir: __dirname,
|
|
6
|
+
collectCoverageFrom: [
|
|
7
|
+
"src/**/*.ts",
|
|
8
|
+
"!src/**/*.test.{ts,tsx}",
|
|
9
|
+
"!src/**/*.spec.{ts,tsx}",
|
|
10
|
+
"!src/**/__tests__/**",
|
|
11
|
+
"!tests/**",
|
|
12
|
+
],
|
|
13
|
+
coverageReporters: ["json", ["lcov", { projectRoot: "../../../../" }], "json-summary", "text"],
|
|
14
|
+
reporters: [
|
|
15
|
+
"default",
|
|
16
|
+
[
|
|
17
|
+
"jest-sonar",
|
|
18
|
+
{
|
|
19
|
+
outputName: "sonar-executionTests-report.xml",
|
|
20
|
+
reportedFilePath: "absolute",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
],
|
|
24
|
+
};
|
package/lib/Canton.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type Transport from "@ledgerhq/hw-transport";
|
|
2
|
+
import { CantonAddress, CantonSignature } from "@ledgerhq/coin-canton";
|
|
3
|
+
import { MockCantonDevice, AppConfig } from "./MockDevice";
|
|
4
|
+
/**
|
|
5
|
+
* Canton BOLOS API
|
|
6
|
+
*/
|
|
7
|
+
export default class Canton {
|
|
8
|
+
transport: Transport;
|
|
9
|
+
transportMock: MockCantonDevice;
|
|
10
|
+
constructor(transport: Transport, scrambleKey?: string);
|
|
11
|
+
/**
|
|
12
|
+
* Get a Canton address for a given BIP-32 path.
|
|
13
|
+
*
|
|
14
|
+
* @param path a path in BIP-32 format
|
|
15
|
+
* @param display whether to display the address on the device
|
|
16
|
+
* @return the address and public key
|
|
17
|
+
*/
|
|
18
|
+
getAddress(path: string, display?: boolean): Promise<CantonAddress>;
|
|
19
|
+
/**
|
|
20
|
+
* Sign a Canton transaction.
|
|
21
|
+
*
|
|
22
|
+
* @param path a path in BIP-32 format
|
|
23
|
+
* @param rawTx the raw transaction to sign
|
|
24
|
+
* @return the signature
|
|
25
|
+
*/
|
|
26
|
+
signTransaction(path: string, rawTx: string): Promise<CantonSignature>;
|
|
27
|
+
/**
|
|
28
|
+
* Get the app configuration.
|
|
29
|
+
* @return the app configuration including version
|
|
30
|
+
*/
|
|
31
|
+
getAppConfiguration(): Promise<AppConfig>;
|
|
32
|
+
/**
|
|
33
|
+
* Helper method to handle transport response and check for errors
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
private handleTransportResponse;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize a BIP path to a data buffer for Canton BOLOS
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
private serializePath;
|
|
42
|
+
/**
|
|
43
|
+
* Simple deterministic hash function for generating mock addresses
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
private hashString;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=Canton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canton.d.ts","sourceRoot":"","sources":["../src/Canton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAoB3D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,gBAAgB,CAAC;gBAEpB,SAAS,EAAE,SAAS,EAAE,WAAW,SAAgC;IAO7E;;;;;;OAMG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBhF;;;;;;OAMG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAa5E;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC;IAc/C;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAe/B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACH,OAAO,CAAC,UAAU;CASnB"}
|
package/lib/Canton.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
7
|
+
const bip32_path_1 = __importDefault(require("bip32-path"));
|
|
8
|
+
const MockDevice_1 = require("./MockDevice");
|
|
9
|
+
const CLA = 0xe0;
|
|
10
|
+
const P1_NON_CONFIRM = 0x00;
|
|
11
|
+
const P1_CONFIRM = 0x01;
|
|
12
|
+
const P2 = 0x00;
|
|
13
|
+
const INS = {
|
|
14
|
+
GET_VERSION: 0x04,
|
|
15
|
+
GET_ADDR: 0x05,
|
|
16
|
+
SIGN: 0x06,
|
|
17
|
+
};
|
|
18
|
+
const STATUS = {
|
|
19
|
+
OK: 0x9000,
|
|
20
|
+
USER_CANCEL: 0x6985,
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Canton BOLOS API
|
|
24
|
+
*/
|
|
25
|
+
class Canton {
|
|
26
|
+
transport;
|
|
27
|
+
transportMock;
|
|
28
|
+
constructor(transport, scrambleKey = "canton_default_scramble_key") {
|
|
29
|
+
this.transport = transport;
|
|
30
|
+
this.transportMock = new MockDevice_1.MockCantonDevice();
|
|
31
|
+
transport.decorateAppAPIMethods(this, ["getAddress", "signTransaction"], scrambleKey);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get a Canton address for a given BIP-32 path.
|
|
35
|
+
*
|
|
36
|
+
* @param path a path in BIP-32 format
|
|
37
|
+
* @param display whether to display the address on the device
|
|
38
|
+
* @return the address and public key
|
|
39
|
+
*/
|
|
40
|
+
async getAddress(path, display = false) {
|
|
41
|
+
const bipPath = bip32_path_1.default.fromString(path).toPathArray();
|
|
42
|
+
const serializedPath = this.serializePath(bipPath);
|
|
43
|
+
const p1 = display ? P1_CONFIRM : P1_NON_CONFIRM;
|
|
44
|
+
const response = await this.transportMock.send(CLA, INS.GET_ADDR, p1, P2, serializedPath);
|
|
45
|
+
const responseData = this.handleTransportResponse(response, "address");
|
|
46
|
+
// Handle 65-byte uncompressed SECP256R1 public key
|
|
47
|
+
const publicKey = "0x" + responseData.toString("hex");
|
|
48
|
+
const addressHash = this.hashString(publicKey);
|
|
49
|
+
const address = "canton_" + addressHash.substring(0, 36);
|
|
50
|
+
return {
|
|
51
|
+
publicKey,
|
|
52
|
+
address,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sign a Canton transaction.
|
|
57
|
+
*
|
|
58
|
+
* @param path a path in BIP-32 format
|
|
59
|
+
* @param rawTx the raw transaction to sign
|
|
60
|
+
* @return the signature
|
|
61
|
+
*/
|
|
62
|
+
async signTransaction(path, rawTx) {
|
|
63
|
+
const bipPath = bip32_path_1.default.fromString(path).toPathArray();
|
|
64
|
+
const serializedPath = this.serializePath(bipPath);
|
|
65
|
+
const payload = Buffer.concat([serializedPath, Buffer.from(rawTx, "hex")]);
|
|
66
|
+
const response = await this.transportMock.send(CLA, INS.SIGN, P1_CONFIRM, P2, payload);
|
|
67
|
+
const responseData = this.handleTransportResponse(response, "transaction");
|
|
68
|
+
const signature = "0x" + responseData.toString("hex");
|
|
69
|
+
return signature;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get the app configuration.
|
|
73
|
+
* @return the app configuration including version
|
|
74
|
+
*/
|
|
75
|
+
async getAppConfiguration() {
|
|
76
|
+
const [major, minor, patch] = await this.transportMock.send(CLA, INS.GET_VERSION, P1_NON_CONFIRM, P2, Buffer.alloc(0));
|
|
77
|
+
return {
|
|
78
|
+
version: `${major}.${minor}.${patch}`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Helper method to handle transport response and check for errors
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
handleTransportResponse(response, errorType) {
|
|
86
|
+
const statusCode = response.readUInt16BE(response.length - 2);
|
|
87
|
+
const responseData = response.slice(0, response.length - 2);
|
|
88
|
+
if (statusCode === STATUS.USER_CANCEL) {
|
|
89
|
+
if (errorType === "address") {
|
|
90
|
+
throw new errors_1.UserRefusedAddress();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
throw new errors_1.UserRefusedOnDevice();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return responseData;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Serialize a BIP path to a data buffer for Canton BOLOS
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
serializePath(path) {
|
|
103
|
+
const data = Buffer.alloc(1 + path.length * 4);
|
|
104
|
+
data.writeUInt8(path.length, 0); // Write path length as first byte
|
|
105
|
+
path.forEach((segment, index) => {
|
|
106
|
+
data.writeUInt32BE(segment, 1 + index * 4); // Write each segment as 32-bit integer
|
|
107
|
+
});
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Simple deterministic hash function for generating mock addresses
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
hashString(str) {
|
|
115
|
+
let hash = 0;
|
|
116
|
+
for (let i = 0; i < str.length; i++) {
|
|
117
|
+
const char = str.charCodeAt(i);
|
|
118
|
+
hash = (hash << 5) - hash + char;
|
|
119
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
120
|
+
}
|
|
121
|
+
return Math.abs(hash).toString(16);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.default = Canton;
|
|
125
|
+
//# sourceMappingURL=Canton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canton.js","sourceRoot":"","sources":["../src/Canton.ts"],"names":[],"mappings":";;;;;AACA,6CAA2E;AAE3E,4DAAiC;AAEjC,6CAA2D;AAE3D,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAM,EAAE,GAAG,IAAI,CAAC;AAEhB,MAAM,GAAG,GAAG;IACV,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,EAAE,EAAE,MAAM;IACV,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF;;GAEG;AACH,MAAqB,MAAM;IACzB,SAAS,CAAY;IACrB,aAAa,CAAmB;IAEhC,YAAY,SAAoB,EAAE,WAAW,GAAG,6BAA6B;QAC3E,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,IAAI,6BAAgB,EAAE,CAAC;QAE5C,SAAS,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,iBAAiB,CAAC,EAAE,WAAW,CAAC,CAAC;IACxF,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AM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE/C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,kCAAkC;QACnE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;YAC9B,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,uCAAuC;QACrF,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACK,UAAU,CAAC,GAAW;QAC5B,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;YACjC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,4BAA4B;QAClD,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AA5HD,yBA4HC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export type AppConfig = {
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Mock Canton "@ledgerhq/hw-app-canton" device implementation for development and testing
|
|
8
|
+
*/
|
|
9
|
+
export declare class MockCantonDevice {
|
|
10
|
+
private mockAddresses;
|
|
11
|
+
private mockSignatures;
|
|
12
|
+
constructor();
|
|
13
|
+
send(cla: number, ins: number, p1: number, p2: number, data: Buffer): Promise<Buffer>;
|
|
14
|
+
private getAddressResponse;
|
|
15
|
+
private signTransactionResponse;
|
|
16
|
+
private getAppConfigurationResponse;
|
|
17
|
+
private parsePathFromData;
|
|
18
|
+
private simulateDeviceDelay;
|
|
19
|
+
/**
|
|
20
|
+
* Simple deterministic hash function for generating mock data
|
|
21
|
+
*/
|
|
22
|
+
private hashString;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=MockDevice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockDevice.d.ts","sourceRoot":"","sources":["../src/MockDevice.ts"],"names":[],"mappings":";;AAaA,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAsBF;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,cAAc,CAA2C;;IAS3D,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAa7E,kBAAkB;YAiClB,uBAAuB;YA0BvB,2BAA2B;IAYzC,OAAO,CAAC,iBAAiB;YAkBX,mBAAmB;IAIjC;;OAEG;IACH,OAAO,CAAC,UAAU;CASnB"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockCantonDevice = void 0;
|
|
4
|
+
const INS = {
|
|
5
|
+
GET_VERSION: 0x04,
|
|
6
|
+
GET_ADDR: 0x05,
|
|
7
|
+
SIGN: 0x06,
|
|
8
|
+
};
|
|
9
|
+
const STATUS = {
|
|
10
|
+
OK: 0x9000,
|
|
11
|
+
USER_CANCEL: 0x6985,
|
|
12
|
+
};
|
|
13
|
+
// SECP256R1-compatible mock addresses
|
|
14
|
+
const SECP256R1_MOCK_ADDRESSES = {
|
|
15
|
+
"44'/6767'/0'/0'/0'": {
|
|
16
|
+
// Uncompressed SECP256R1 public key (65 bytes: 0x04 + 32-byte X + 32-byte Y)
|
|
17
|
+
publicKey: "0x04" +
|
|
18
|
+
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" +
|
|
19
|
+
"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
|
|
20
|
+
address: "canton_1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z",
|
|
21
|
+
},
|
|
22
|
+
"44'/6767'/0'/0'/1'": {
|
|
23
|
+
// Another valid SECP256R1 public key
|
|
24
|
+
publicKey: "0x04" +
|
|
25
|
+
"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" +
|
|
26
|
+
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd",
|
|
27
|
+
address: "canton_2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Mock Canton "@ledgerhq/hw-app-canton" device implementation for development and testing
|
|
32
|
+
*/
|
|
33
|
+
class MockCantonDevice {
|
|
34
|
+
mockAddresses = new Map();
|
|
35
|
+
mockSignatures = new Map();
|
|
36
|
+
constructor() {
|
|
37
|
+
// Initialize with SECP256R1-compatible addresses
|
|
38
|
+
Object.entries(SECP256R1_MOCK_ADDRESSES).forEach(([path, address]) => {
|
|
39
|
+
this.mockAddresses.set(path, address);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async send(cla, ins, p1, p2, data) {
|
|
43
|
+
switch (ins) {
|
|
44
|
+
case INS.GET_ADDR:
|
|
45
|
+
return this.getAddressResponse(data);
|
|
46
|
+
case INS.SIGN:
|
|
47
|
+
return this.signTransactionResponse(data);
|
|
48
|
+
case INS.GET_VERSION:
|
|
49
|
+
return this.getAppConfigurationResponse();
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Unsupported instruction: ${ins}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async getAddressResponse(data) {
|
|
55
|
+
await this.simulateDeviceDelay();
|
|
56
|
+
// Parse the path from the data
|
|
57
|
+
const pathData = data.slice(1); // Skip length byte
|
|
58
|
+
const path = this.parsePathFromData(pathData);
|
|
59
|
+
const mockAddress = this.mockAddresses.get(path);
|
|
60
|
+
if (!mockAddress) {
|
|
61
|
+
// Generate SECP256R1-compatible mock address
|
|
62
|
+
const pathHash = this.hashString(path);
|
|
63
|
+
const newAddress = {
|
|
64
|
+
// Create valid uncompressed SECP256R1 public key format
|
|
65
|
+
publicKey: "0x04" +
|
|
66
|
+
pathHash.substring(0, 64).padEnd(64, "0") +
|
|
67
|
+
pathHash.substring(64, 128).padEnd(64, "0"),
|
|
68
|
+
address: `canton_${pathHash.substring(0, 36)}`,
|
|
69
|
+
};
|
|
70
|
+
this.mockAddresses.set(path, newAddress);
|
|
71
|
+
}
|
|
72
|
+
const address = this.mockAddresses.get(path);
|
|
73
|
+
// Return 65-byte uncompressed public key (0x04 + 32-byte X + 32-byte Y)
|
|
74
|
+
const publicKeyBytes = Buffer.from(address.publicKey.slice(2), "hex");
|
|
75
|
+
const response = Buffer.alloc(65 + 2);
|
|
76
|
+
publicKeyBytes.copy(response, 0);
|
|
77
|
+
response.writeUInt16BE(STATUS.OK, 65);
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
async signTransactionResponse(data) {
|
|
81
|
+
await this.simulateDeviceDelay();
|
|
82
|
+
// Parse the path and transaction from the data
|
|
83
|
+
const pathData = data.slice(0, 21); // First 21 bytes are path
|
|
84
|
+
const txData = data.slice(21); // Rest is transaction data
|
|
85
|
+
const path = this.parsePathFromData(pathData);
|
|
86
|
+
const signatureKey = `${path}:${txData.toString("hex")}`;
|
|
87
|
+
let signature = this.mockSignatures.get(signatureKey);
|
|
88
|
+
if (!signature) {
|
|
89
|
+
// Generate SECP256R1-compatible mock signature (64 bytes: r + s)
|
|
90
|
+
const combinedHash = this.hashString(signatureKey);
|
|
91
|
+
signature = `0x${combinedHash.substring(0, 64).padEnd(64, "0")}`;
|
|
92
|
+
this.mockSignatures.set(signatureKey, signature);
|
|
93
|
+
}
|
|
94
|
+
// Return 64-byte signature (r + s components)
|
|
95
|
+
const response = Buffer.alloc(64 + 2);
|
|
96
|
+
Buffer.from(signature.slice(2), "hex").copy(response, 0); // Remove '0x' prefix
|
|
97
|
+
response.writeUInt16BE(STATUS.OK, 64);
|
|
98
|
+
return response;
|
|
99
|
+
}
|
|
100
|
+
async getAppConfigurationResponse() {
|
|
101
|
+
await this.simulateDeviceDelay();
|
|
102
|
+
// Create response buffer: version data + status code
|
|
103
|
+
const versionData = Buffer.from([0x00, 0x01, 0x00, 0x06]); // Version 0.1.0
|
|
104
|
+
const response = Buffer.alloc(versionData.length + 2);
|
|
105
|
+
versionData.copy(response, 0);
|
|
106
|
+
response.writeUInt16BE(STATUS.OK, versionData.length);
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
parsePathFromData(data) {
|
|
110
|
+
// Convert the path data back to a BIP32 path string
|
|
111
|
+
const segments = [];
|
|
112
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
113
|
+
const segment = data.readUInt32BE(i);
|
|
114
|
+
segments.push(segment);
|
|
115
|
+
}
|
|
116
|
+
// Convert to BIP32 path string
|
|
117
|
+
const pathParts = segments.map(seg => {
|
|
118
|
+
const isHardened = (seg & 0x80000000) !== 0;
|
|
119
|
+
const value = seg & 0x7fffffff;
|
|
120
|
+
return isHardened ? `${value}'` : `${value}`;
|
|
121
|
+
});
|
|
122
|
+
return pathParts.join("/");
|
|
123
|
+
}
|
|
124
|
+
async simulateDeviceDelay() {
|
|
125
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Simple deterministic hash function for generating mock data
|
|
129
|
+
*/
|
|
130
|
+
hashString(str) {
|
|
131
|
+
let hash = 0;
|
|
132
|
+
for (let i = 0; i < str.length; i++) {
|
|
133
|
+
const char = str.charCodeAt(i);
|
|
134
|
+
hash = (hash << 5) - hash + char;
|
|
135
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
136
|
+
}
|
|
137
|
+
return Math.abs(hash).toString(16);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.MockCantonDevice = MockCantonDevice;
|
|
141
|
+
//# sourceMappingURL=MockDevice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockDevice.js","sourceRoot":"","sources":["../src/MockDevice.ts"],"names":[],"mappings":";;;AAEA,MAAM,GAAG,GAAG;IACV,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,EAAE,EAAE,MAAM;IACV,WAAW,EAAE,MAAM;CACpB,CAAC;AAMF,sCAAsC;AACtC,MAAM,wBAAwB,GAAG;IAC/B,oBAAoB,EAAE;QACpB,6EAA6E;QAC7E,SAAS,EACP,MAAM;YACN,kEAAkE;YAClE,kEAAkE;QACpE,OAAO,EAAE,6DAA6D;KACvE;IACD,oBAAoB,EAAE;QACpB,qCAAqC;QACrC,SAAS,EACP,MAAM;YACN,kEAAkE;YAClE,gEAAgE;QAClE,OAAO,EAAE,6DAA6D;KACvE;CACF,CAAC;AAEF;;GAEG;AACH,MAAa,gBAAgB;IACnB,aAAa,GAA+B,IAAI,GAAG,EAAE,CAAC;IACtD,cAAc,GAAiC,IAAI,GAAG,EAAE,CAAC;IAEjE;QACE,iDAAiD;QACjD,MAAM,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE;YACnE,IAAI,CAAC,aAAa,CAAC,GAAG,CAA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