@alephium/ledger-app 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.js CHANGED
@@ -52,6 +52,9 @@ class AlephiumApp {
52
52
  if ((targetGroup ?? 0) >= exports.GROUP_NUM) {
53
53
  throw Error(`Invalid targetGroup: ${targetGroup}`);
54
54
  }
55
+ if (keyType === 'bip340-schnorr') {
56
+ throw Error('BIP340-Schnorr is not supported yet');
57
+ }
55
58
  const p1 = targetGroup === undefined ? 0x00 : exports.GROUP_NUM;
56
59
  const p2 = targetGroup === undefined ? 0x00 : targetGroup;
57
60
  const response = await this.transport.send(exports.CLA, INS.GET_PUBLIC_KEY, p1, p2, serde.serializePath(startPath));
@@ -84,10 +84,7 @@ describe('sdk', () => {
84
84
  const transport = await hw_transport_node_speculos_1.default.open({ apduPort });
85
85
  const app = new src_1.default(transport);
86
86
  Array(src_1.GROUP_NUM).forEach(async (_, group) => {
87
- const [account, hdIndex] = await app.getAccount(path, group, 'bip340-schnorr');
88
- expect(hdIndex >= pathIndex).toBe(true);
89
- expect((0, web3_1.groupOfAddress)(account.address)).toBe(group);
90
- expect(account.keyType).toBe('bip340-schnorr');
87
+ await expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet');
91
88
  });
92
89
  await transport.close();
93
90
  });
@@ -108,4 +105,19 @@ describe('sdk', () => {
108
105
  await transport.close();
109
106
  expect((0, web3_1.transactionVerifySignature)(hash.toString('hex'), account.publicKey, signature)).toBe(true);
110
107
  }, 10000);
108
+ it('should reject signing', async () => {
109
+ const transport = await hw_transport_node_speculos_1.default.open({ apduPort });
110
+ const app = new src_1.default(transport);
111
+ const [account] = await app.getAccount(path);
112
+ console.log(account);
113
+ const hash = Buffer.from(blakejs_1.default.blake2b(Buffer.from([0, 1, 2, 3, 4]), undefined, 32));
114
+ setTimeout(async () => {
115
+ await pressButton('both'); // review message
116
+ await pressButton('both'); // done review
117
+ await pressButton('left'); // select signing
118
+ await pressButton('both'); // done selection
119
+ }, 1000);
120
+ await expect(app.signHash(path, hash)).rejects.toThrow();
121
+ await transport.close();
122
+ }, 10000);
111
123
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/ledger-app",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "license": "GPL",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "exports": {
@@ -13,7 +13,7 @@
13
13
  "lint": "eslint . --ext ts",
14
14
  "lint:fix": "eslint . --fix --ext ts",
15
15
  "test": "jest -i --config ./jest-config.json",
16
- "publish": "npm run build && npm publish --access public"
16
+ "pub": "npm run build && npm publish --access public"
17
17
  },
18
18
  "prettier": {
19
19
  "printWidth": 120,
package/src/index.ts CHANGED
@@ -34,6 +34,10 @@ export default class AlephiumApp {
34
34
  throw Error(`Invalid targetGroup: ${targetGroup}`)
35
35
  }
36
36
 
37
+ if (keyType === 'bip340-schnorr') {
38
+ throw Error('BIP340-Schnorr is not supported yet')
39
+ }
40
+
37
41
  const p1 = targetGroup === undefined ? 0x00 : GROUP_NUM
38
42
  const p2 = targetGroup === undefined ? 0x00 : targetGroup
39
43
  const response = await this.transport.send(CLA, INS.GET_PUBLIC_KEY, p1, p2, serde.serializePath(startPath))
@@ -65,10 +65,7 @@ describe('sdk', () => {
65
65
  const transport = await SpeculosTransport.open({ apduPort })
66
66
  const app = new AlephiumApp(transport)
67
67
  Array(GROUP_NUM).forEach(async (_, group) => {
68
- const [account, hdIndex] = await app.getAccount(path, group, 'bip340-schnorr')
69
- expect(hdIndex >= pathIndex).toBe(true)
70
- expect(groupOfAddress(account.address)).toBe(group)
71
- expect(account.keyType).toBe('bip340-schnorr')
68
+ await expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet')
72
69
  })
73
70
  await transport.close()
74
71
  })
@@ -93,4 +90,22 @@ describe('sdk', () => {
93
90
 
94
91
  expect(transactionVerifySignature(hash.toString('hex'), account.publicKey, signature)).toBe(true)
95
92
  }, 10000)
93
+
94
+ it('should reject signing', async () => {
95
+ const transport = await SpeculosTransport.open({ apduPort })
96
+ const app = new AlephiumApp(transport)
97
+
98
+ const [account] = await app.getAccount(path)
99
+ console.log(account)
100
+
101
+ const hash = Buffer.from(blake.blake2b(Buffer.from([0, 1, 2, 3, 4]), undefined, 32))
102
+ setTimeout(async () => {
103
+ await pressButton('both') // review message
104
+ await pressButton('both') // done review
105
+ await pressButton('left') // select signing
106
+ await pressButton('both') // done selection
107
+ }, 1000)
108
+ await expect(app.signHash(path, hash)).rejects.toThrow()
109
+ await transport.close()
110
+ }, 10000)
96
111
  })