@ledgerhq/hw-ledger-key-ring-protocol 0.5.2-nightly.3 → 0.5.2
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 +1 -1
- package/CHANGELOG.md +5 -19
- package/lib/__tests__/codec.d.ts +2 -0
- package/lib/__tests__/codec.d.ts.map +1 -0
- package/lib/__tests__/codec.js +99 -0
- package/lib/__tests__/codec.js.map +1 -0
- package/lib/__tests__/crypto.d.ts +2 -0
- package/lib/__tests__/crypto.d.ts.map +1 -0
- package/lib/__tests__/crypto.js +37 -0
- package/lib/__tests__/crypto.js.map +1 -0
- package/lib/__tests__/indexed_tree.d.ts +2 -0
- package/lib/__tests__/indexed_tree.d.ts.map +1 -0
- package/lib/__tests__/indexed_tree.js +44 -0
- package/lib/__tests__/indexed_tree.js.map +1 -0
- package/lib/__tests__/key_exchange.d.ts +2 -0
- package/lib/__tests__/key_exchange.d.ts.map +1 -0
- package/lib/__tests__/key_exchange.js +120 -0
- package/lib/__tests__/key_exchange.js.map +1 -0
- package/lib/__tests__/seedId.d.ts +2 -0
- package/lib/__tests__/seedId.d.ts.map +1 -0
- package/lib/__tests__/seedId.js +92 -0
- package/lib/__tests__/seedId.js.map +1 -0
- package/lib/__tests__/shared_object.d.ts +2 -0
- package/lib/__tests__/shared_object.d.ts.map +1 -0
- package/lib/__tests__/shared_object.js +65 -0
- package/lib/__tests__/shared_object.js.map +1 -0
- package/lib/__tests__/units/NobleCrypto.test.d.ts +2 -0
- package/lib/__tests__/units/NobleCrypto.test.d.ts.map +1 -0
- package/lib/__tests__/units/NobleCrypto.test.js +58 -0
- package/lib/__tests__/units/NobleCrypto.test.js.map +1 -0
- package/lib-es/__tests__/codec.d.ts +2 -0
- package/lib-es/__tests__/codec.d.ts.map +1 -0
- package/lib-es/__tests__/codec.js +97 -0
- package/lib-es/__tests__/codec.js.map +1 -0
- package/lib-es/__tests__/crypto.d.ts +2 -0
- package/lib-es/__tests__/crypto.d.ts.map +1 -0
- package/lib-es/__tests__/crypto.js +35 -0
- package/lib-es/__tests__/crypto.js.map +1 -0
- package/lib-es/__tests__/indexed_tree.d.ts +2 -0
- package/lib-es/__tests__/indexed_tree.d.ts.map +1 -0
- package/lib-es/__tests__/indexed_tree.js +42 -0
- package/lib-es/__tests__/indexed_tree.js.map +1 -0
- package/lib-es/__tests__/key_exchange.d.ts +2 -0
- package/lib-es/__tests__/key_exchange.d.ts.map +1 -0
- package/lib-es/__tests__/key_exchange.js +115 -0
- package/lib-es/__tests__/key_exchange.js.map +1 -0
- package/lib-es/__tests__/seedId.d.ts +2 -0
- package/lib-es/__tests__/seedId.d.ts.map +1 -0
- package/lib-es/__tests__/seedId.js +90 -0
- package/lib-es/__tests__/seedId.js.map +1 -0
- package/lib-es/__tests__/shared_object.d.ts +2 -0
- package/lib-es/__tests__/shared_object.d.ts.map +1 -0
- package/lib-es/__tests__/shared_object.js +63 -0
- package/lib-es/__tests__/shared_object.js.map +1 -0
- package/lib-es/__tests__/units/NobleCrypto.test.d.ts +2 -0
- package/lib-es/__tests__/units/NobleCrypto.test.d.ts.map +1 -0
- package/lib-es/__tests__/units/NobleCrypto.test.js +56 -0
- package/lib-es/__tests__/units/NobleCrypto.test.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NobleCryptoSecp256k1 } from "../../NobleCrypto";
|
|
2
|
+
describe("NobleCryptoSecp256k1", () => {
|
|
3
|
+
const crypto = new NobleCryptoSecp256k1();
|
|
4
|
+
describe("derEncode", () => {
|
|
5
|
+
it("should encode a valid DER signature", () => {
|
|
6
|
+
// The R component starts with a byte < 0x80
|
|
7
|
+
// The S component starts with a 0 but the next byte is >= 0x80
|
|
8
|
+
const der32 = crypto.derEncode(Uint8Array.from([
|
|
9
|
+
...Buffer.from("4802f9f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891", "hex"),
|
|
10
|
+
...Buffer.from("008022731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809", "hex"),
|
|
11
|
+
]));
|
|
12
|
+
expect(Buffer.from(der32).toString("hex")).toBe(noWS `
|
|
13
|
+
30 44
|
|
14
|
+
02 20 4802f9f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891
|
|
15
|
+
02 20 008022731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809
|
|
16
|
+
`);
|
|
17
|
+
// The R and S component both start with a byte >= 0x80
|
|
18
|
+
const der33 = crypto.derEncode(Uint8Array.from([
|
|
19
|
+
...Buffer.from("8002f9f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891", "hex"),
|
|
20
|
+
...Buffer.from("ff7222731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809", "hex"),
|
|
21
|
+
]));
|
|
22
|
+
expect(Buffer.from(der33).toString("hex")).toBe(noWS `
|
|
23
|
+
30 46
|
|
24
|
+
02 21 008002f9f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891
|
|
25
|
+
02 21 00ff7222731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809
|
|
26
|
+
`);
|
|
27
|
+
// The R and S component both start with a 0 then have a byte < 0x80
|
|
28
|
+
const der31 = crypto.derEncode(Uint8Array.from([
|
|
29
|
+
...Buffer.from("0002f9f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891", "hex"),
|
|
30
|
+
...Buffer.from("007222731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809", "hex"),
|
|
31
|
+
]));
|
|
32
|
+
expect(Buffer.from(der31).toString("hex")).toBe(noWS `
|
|
33
|
+
30 42
|
|
34
|
+
02 1f 02f9f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891
|
|
35
|
+
02 1f 7222731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809
|
|
36
|
+
`);
|
|
37
|
+
// The R and S component both start several leading 0s
|
|
38
|
+
const derLeadingZeros = crypto.derEncode(Uint8Array.from([
|
|
39
|
+
...Buffer.from("000000f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891", "hex"),
|
|
40
|
+
...Buffer.from("000000731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809", "hex"),
|
|
41
|
+
]));
|
|
42
|
+
expect(Buffer.from(derLeadingZeros).toString("hex")).toBe(noWS `
|
|
43
|
+
30 3f
|
|
44
|
+
02 1e 00f997e06b7e98ec35ba75a10a0e0a5bd1a15767d7d1124869301081d891
|
|
45
|
+
02 1d 731cd6cd05ac285829d8d588b51bb4c5be5bad5a44cbd966fcf670f809
|
|
46
|
+
`);
|
|
47
|
+
});
|
|
48
|
+
it("should throw if a component is null", () => {
|
|
49
|
+
expect(() => crypto.derEncode(Uint8Array.from({ length: 64 }, () => 0))).toThrow(`Invalid DER component: 0000000000000000000000000000000000000000000000000000000000000000`);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
function noWS(...str) {
|
|
54
|
+
return str.join("").replace(/\s+/g, "");
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=NobleCrypto.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NobleCrypto.test.js","sourceRoot":"","sources":["../../../src/__tests__/units/NobleCrypto.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE1C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC7C,4CAA4C;YAC5C,+DAA+D;YAC/D,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAC5B,UAAU,CA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AAM,CAAC,IAAI,CAAC,kEAAkE,EAAE,KAAK,CAAC;aAC1F,CAAC,CACH,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;;;;OAI7D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC7C,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAC9E,yFAAyF,CAC1F,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,IAAI,CAAC,GAAG,GAA2B;IAC1C,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-ledger-key-ring-protocol",
|
|
3
|
-
"version": "0.5.2
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Ledger Key Ring Protocol hardware layer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger"
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"bip32": "^4.0.0",
|
|
22
22
|
"@noble/curves": "^1.9.7",
|
|
23
23
|
"create-hmac": "^1.1.7",
|
|
24
|
-
"@ledgerhq/hw-transport": "6.31.
|
|
24
|
+
"@ledgerhq/hw-transport": "6.31.12",
|
|
25
25
|
"@ledgerhq/logs": "6.13.0",
|
|
26
|
-
"@ledgerhq/live-env": "2.19.0
|
|
26
|
+
"@ledgerhq/live-env": "2.19.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/lodash": "4",
|