@alephium/ledger-app 0.1.5 → 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,8 +52,8 @@ 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");
55
+ if (keyType === 'bip340-schnorr') {
56
+ throw Error('BIP340-Schnorr is not supported yet');
57
57
  }
58
58
  const p1 = targetGroup === undefined ? 0x00 : exports.GROUP_NUM;
59
59
  const p2 = targetGroup === undefined ? 0x00 : targetGroup;
@@ -84,7 +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
- expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet');
87
+ await expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet');
88
88
  });
89
89
  await transport.close();
90
90
  });
@@ -105,4 +105,19 @@ describe('sdk', () => {
105
105
  await transport.close();
106
106
  expect((0, web3_1.transactionVerifySignature)(hash.toString('hex'), account.publicKey, signature)).toBe(true);
107
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);
108
123
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/ledger-app",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "license": "GPL",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "exports": {
package/src/index.ts CHANGED
@@ -34,8 +34,8 @@ 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")
37
+ if (keyType === 'bip340-schnorr') {
38
+ throw Error('BIP340-Schnorr is not supported yet')
39
39
  }
40
40
 
41
41
  const p1 = targetGroup === undefined ? 0x00 : GROUP_NUM
@@ -65,7 +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
- expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet')
68
+ await expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet')
69
69
  })
70
70
  await transport.close()
71
71
  })
@@ -90,4 +90,22 @@ describe('sdk', () => {
90
90
 
91
91
  expect(transactionVerifySignature(hash.toString('hex'), account.publicKey, signature)).toBe(true)
92
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)
93
111
  })