@ledgerhq/hw-ledger-key-ring-protocol 0.2.1-nightly.1 → 0.2.1-spl-test.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.
Files changed (63) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +3 -10
  3. package/lib/ApduDevice.d.ts.map +1 -1
  4. package/lib/ApduDevice.js +37 -41
  5. package/lib/ApduDevice.js.map +1 -1
  6. package/lib/CommandBlock.d.ts +4 -4
  7. package/lib/CommandBlock.d.ts.map +1 -1
  8. package/lib/CommandBlock.js +18 -35
  9. package/lib/CommandBlock.js.map +1 -1
  10. package/lib/CommandStream.d.ts +1 -1
  11. package/lib/CommandStream.d.ts.map +1 -1
  12. package/lib/CommandStream.js +5 -7
  13. package/lib/CommandStream.js.map +1 -1
  14. package/lib/Crypto.d.ts +11 -11
  15. package/lib/Crypto.d.ts.map +1 -1
  16. package/lib/Device.d.ts +1 -1
  17. package/lib/Device.d.ts.map +1 -1
  18. package/lib/Device.js +28 -36
  19. package/lib/Device.js.map +1 -1
  20. package/lib/NobleCrypto.d.ts +13 -15
  21. package/lib/NobleCrypto.d.ts.map +1 -1
  22. package/lib/NobleCrypto.js +90 -148
  23. package/lib/NobleCrypto.js.map +1 -1
  24. package/lib/StreamTreeCipher.d.ts.map +1 -1
  25. package/lib/StreamTreeCipher.js +32 -36
  26. package/lib/StreamTreeCipher.js.map +1 -1
  27. package/lib/__tests__/codec.js +33 -33
  28. package/lib/__tests__/codec.js.map +1 -1
  29. package/lib-es/ApduDevice.d.ts.map +1 -1
  30. package/lib-es/ApduDevice.js +37 -41
  31. package/lib-es/ApduDevice.js.map +1 -1
  32. package/lib-es/CommandBlock.d.ts +4 -4
  33. package/lib-es/CommandBlock.d.ts.map +1 -1
  34. package/lib-es/CommandBlock.js +18 -35
  35. package/lib-es/CommandBlock.js.map +1 -1
  36. package/lib-es/CommandStream.d.ts +1 -1
  37. package/lib-es/CommandStream.d.ts.map +1 -1
  38. package/lib-es/CommandStream.js +5 -7
  39. package/lib-es/CommandStream.js.map +1 -1
  40. package/lib-es/Crypto.d.ts +11 -11
  41. package/lib-es/Crypto.d.ts.map +1 -1
  42. package/lib-es/Device.d.ts +1 -1
  43. package/lib-es/Device.d.ts.map +1 -1
  44. package/lib-es/Device.js +28 -36
  45. package/lib-es/Device.js.map +1 -1
  46. package/lib-es/NobleCrypto.d.ts +13 -15
  47. package/lib-es/NobleCrypto.d.ts.map +1 -1
  48. package/lib-es/NobleCrypto.js +90 -148
  49. package/lib-es/NobleCrypto.js.map +1 -1
  50. package/lib-es/StreamTreeCipher.d.ts.map +1 -1
  51. package/lib-es/StreamTreeCipher.js +32 -36
  52. package/lib-es/StreamTreeCipher.js.map +1 -1
  53. package/lib-es/__tests__/codec.js +33 -33
  54. package/lib-es/__tests__/codec.js.map +1 -1
  55. package/package.json +2 -2
  56. package/src/ApduDevice.ts +10 -14
  57. package/src/CommandBlock.ts +11 -14
  58. package/src/CommandStream.ts +6 -8
  59. package/src/Crypto.ts +11 -11
  60. package/src/Device.ts +26 -34
  61. package/src/NobleCrypto.ts +20 -59
  62. package/src/StreamTreeCipher.ts +15 -15
  63. package/src/__tests__/codec.ts +32 -32
@@ -13,7 +13,7 @@ import { crypto } from "../Crypto";
13
13
  import { CommandStream } from "..";
14
14
 
15
15
  describe("Encode/Decode command stream tester", () => {
16
- it("should encode and decode a byte", async () => {
16
+ it("should encode and decode a byte", () => {
17
17
  const byte = 42;
18
18
  let buffer = new Uint8Array();
19
19
  buffer = TLV.pushByte(buffer, 42);
@@ -21,7 +21,7 @@ describe("Encode/Decode command stream tester", () => {
21
21
  expect(decoded.value).toBe(byte);
22
22
  });
23
23
 
24
- it("should encode and decode a Int32", async () => {
24
+ it("should encode and decode a Int32", () => {
25
25
  const varint = 0xdeadbeef;
26
26
  let buffer = new Uint8Array();
27
27
  buffer = TLV.pushInt32(buffer, varint);
@@ -29,7 +29,7 @@ describe("Encode/Decode command stream tester", () => {
29
29
  expect(decoded.value).toBe(varint);
30
30
  });
31
31
 
32
- it("should encode and decode a string", async () => {
32
+ it("should encode and decode a string", () => {
33
33
  const str = "Hello World";
34
34
  let buffer = new Uint8Array();
35
35
  buffer = TLV.pushString(buffer, str);
@@ -37,15 +37,15 @@ describe("Encode/Decode command stream tester", () => {
37
37
  expect(decoded.value).toBe(str);
38
38
  });
39
39
 
40
- it("should encode and decode a hash", async () => {
41
- const hash = await crypto.hash(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
40
+ it("should encode and decode a hash", () => {
41
+ const hash = crypto.hash(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
42
42
  let buffer = new Uint8Array();
43
43
  buffer = TLV.pushHash(buffer, hash);
44
44
  const decoded = TLV.readHash(TLV.readTLV(buffer, 0));
45
45
  expect(crypto.to_hex(decoded.value)).toEqual(crypto.to_hex(hash));
46
46
  });
47
47
 
48
- it("should encode and decode bytes", async () => {
48
+ it("should encode and decode bytes", () => {
49
49
  const bytes = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
50
50
  let buffer = new Uint8Array();
51
51
  buffer = TLV.pushBytes(buffer, bytes);
@@ -53,10 +53,10 @@ describe("Encode/Decode command stream tester", () => {
53
53
  expect(decoded.value).toEqual(bytes);
54
54
  });
55
55
 
56
- it("should encode and decode a signature", async () => {
57
- const alice = await crypto.randomKeypair();
58
- const block = await signCommandBlock(
59
- await createCommandBlock(alice.publicKey, []),
56
+ it("should encode and decode a signature", () => {
57
+ const alice = crypto.randomKeypair();
58
+ const block = signCommandBlock(
59
+ createCommandBlock(alice.publicKey, []),
60
60
  alice.publicKey,
61
61
  alice.privateKey,
62
62
  );
@@ -66,28 +66,28 @@ describe("Encode/Decode command stream tester", () => {
66
66
  expect(decoded.value).toEqual(block.signature);
67
67
  });
68
68
 
69
- it("should encode and decode a public key", async () => {
70
- const alice = await crypto.randomKeypair();
69
+ it("should encode and decode a public key", () => {
70
+ const alice = crypto.randomKeypair();
71
71
  let buffer = new Uint8Array();
72
72
  buffer = TLV.pushPublicKey(buffer, alice.publicKey);
73
73
  const decoded = TLV.readPublicKey(TLV.readTLV(buffer, 0));
74
74
  expect(decoded.value).toEqual(alice.publicKey);
75
75
  });
76
76
 
77
- it("should encode and decode a stream. Encoding/Decoding should not alter the stream", async () => {
78
- const alice = await crypto.randomKeypair();
79
- const groupPk = await crypto.randomKeypair();
80
- const groupChainCode = await crypto.randomBytes(32);
77
+ it("should encode and decode a stream. Encoding/Decoding should not alter the stream", () => {
78
+ const alice = crypto.randomKeypair();
79
+ const groupPk = crypto.randomKeypair();
80
+ const groupChainCode = crypto.randomBytes(32);
81
81
  const xpriv = new Uint8Array(64);
82
- const initializationVector = await crypto.randomBytes(16);
82
+ const initializationVector = crypto.randomBytes(16);
83
83
  xpriv.set(groupPk.privateKey);
84
84
  xpriv.set(groupChainCode, 32);
85
- const ephemeralPk = await crypto.randomKeypair();
85
+ const ephemeralPk = crypto.randomKeypair();
86
86
 
87
- const block1 = await signCommandBlock(
88
- await createCommandBlock(alice.publicKey, [
87
+ const block1 = signCommandBlock(
88
+ createCommandBlock(alice.publicKey, [
89
89
  new Seed(
90
- await crypto.randomBytes(16),
90
+ crypto.randomBytes(16),
91
91
  0,
92
92
  groupPk.publicKey,
93
93
  initializationVector,
@@ -99,21 +99,21 @@ describe("Encode/Decode command stream tester", () => {
99
99
  alice.privateKey,
100
100
  );
101
101
 
102
- const block2 = await signCommandBlock(
103
- await createCommandBlock(alice.publicKey, [
104
- new AddMember("Alice", await crypto.randomBytes(32), Permissions.OWNER),
102
+ const block2 = signCommandBlock(
103
+ createCommandBlock(alice.publicKey, [
104
+ new AddMember("Alice", crypto.randomBytes(32), Permissions.OWNER),
105
105
  new PublishKey(
106
- await crypto.randomBytes(16),
107
- await crypto.randomBytes(32),
108
- await crypto.randomBytes(32),
109
- await crypto.randomBytes(32),
106
+ crypto.randomBytes(16),
107
+ crypto.randomBytes(32),
108
+ crypto.randomBytes(32),
109
+ crypto.randomBytes(32),
110
110
  ),
111
111
  ]),
112
112
  alice.publicKey,
113
113
  alice.privateKey,
114
114
  );
115
- const block3 = await signCommandBlock(
116
- await createCommandBlock(alice.publicKey, []),
115
+ const block3 = signCommandBlock(
116
+ createCommandBlock(alice.publicKey, []),
117
117
  alice.publicKey,
118
118
  alice.privateKey,
119
119
  );
@@ -121,11 +121,11 @@ describe("Encode/Decode command stream tester", () => {
121
121
  const stream = [block1, block2, block3];
122
122
 
123
123
  const encoded = CommandStreamEncoder.encode(stream);
124
- const digestEncoded = await crypto.hash(encoded);
124
+ const digestEncoded = crypto.hash(encoded);
125
125
 
126
126
  const decoded = CommandStreamDecoder.decode(encoded);
127
127
  const reencoded = CommandStreamEncoder.encode(decoded);
128
- const digestReencoded = await crypto.hash(reencoded);
128
+ const digestReencoded = crypto.hash(reencoded);
129
129
  expect(digestEncoded).toEqual(digestReencoded);
130
130
  });
131
131