@taquito/ledger-signer 11.2.0-beta-RC.0 → 11.2.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/README.md CHANGED
@@ -1,26 +1,38 @@
1
1
  # Taquito Ledger Signer package
2
+ *Documentation can be found [here](https://tezostaquito.io/docs/ledger_signer)*
3
+ *TypeDoc style documentation is available [here](https://tezostaquito.io/typedoc/modules/_taquito_ledger_signer.html)*
2
4
 
5
+ ## General Information
3
6
  `@taquito/ledger-signer` is an npm package that provides developers with ledger signing functionality for Taquito. It implements the Signer interface of Taquito, allowing you to sign operations from a Ledger Nano device.
4
7
 
5
- You first need to import the desired transport from the [LedgerJs library](https://github.com/LedgerHQ/ledgerjs). The Ledger Signer has currently been tested with `@ledgerhq/hw-transport-node-hid` for Node-based applications and with `@ledgerhq/hw-transport-u2f` for web applications.
6
- You can pass an instance of the transport of your choice to your Ledger Signer as follows:
8
+ ## Install
9
+ Install the package as follows
10
+ ```
11
+ npm install @taquito/ledger-signer
12
+ ```
13
+
14
+ ## Usage
15
+ ### Prerequisites
16
+ To use the Ledger Signer we must first import the desired transport from the [LedgerJs library](https://github.com/LedgerHQ/ledgerjs).
7
17
 
18
+ The Ledger Signer has currently been tested with `@ledgerhq/hw-transport-node-hid` for Node-based applications and with `@ledgerhq/hw-transport-webhi` for web applications.
19
+
20
+ Pass an instance of the transport of your choice to the Ledger Signer as follows:
8
21
  ```ts
9
- import TransportU2F from '@ledgerhq/hw-transport-u2f';
22
+ import transportWeb from '@ledgerhq/hw-transport-webhi';
10
23
  import { LedgerSigner } from '@taquito/ledger-signer';
11
24
 
12
- const transport = await TransportU2F.create();
25
+ const transport = await transportWeb.create();
13
26
  const ledgerSigner = new LedgerSigner(transport);
14
27
  ```
15
28
 
16
- The constructor of the `LedgerSigner` class can take three other parameters. If none are specified, the default values are used.
29
+ The constructor of the `LedgerSigner` class takes three other optional parameters. If none are specified, the following default values are used:
17
30
 
18
- - path: **default value is "44'/1729'/0'/0'"**
19
- You can use as a parameter the `HDPathTemplate` which refers to `44'/1729'/${account}'/0'`. You have to specify what is the index of the account you want to use. Or you can also use a complete path as a parameter.
20
- _More details about paths below_
21
- - prompt: **default is true**
22
- If true, you will be asked on your Ledger device to send your public key for validation. **_Note that confirmation is required when using `@ledgerhq/hw-transport-u2f`, so you should not set this parameter to false if you are using this transport._**
23
- - derivationType: **default is DerivationType.ED25519**
31
+ - `path`: **default value is "44'/1729'/0'/0'"**
32
+ You can use as a parameter the `HDPathTemplate` which refers to `44'/1729'/${account}'/0'`. You have to specify the index of the account you want to use. Or you can also use a complete path as a parameter. More details about paths [here](https://tezostaquito.io/docs/ledger_signer#derivation-paths-hd-wallet--bip-standards)
33
+ - `prompt`: **default is true**
34
+ If true, you will be asked on your Ledger device to send your public key for validation. **_Note that confirmation is required when using `@ledgerhq/hw-transport-webhi`, so you should not set this parameter to false if you are using this transport._**
35
+ - `derivationType`: **default is DerivationType.ED25519**
24
36
  It can be DerivationType.ED25519 (tz1), DerivationType.SECP256K1 (tz2) or DerivationType.P256 (tz3).
25
37
 
26
38
  ```ts
@@ -34,16 +46,16 @@ const ledgerSigner = new LedgerSigner(
34
46
  );
35
47
  ```
36
48
 
37
- ## Usage
49
+ ### Code Example
38
50
 
39
51
  ```ts
40
52
  import { LedgerSigner } from '@taquito/ledger-signer';
41
- import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
53
+ import TransportWeb from '@ledgerhq/hw-transport-webhi';
42
54
  import { TezosToolkit } from '@taquito/taquito';
43
55
 
44
56
  const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
45
57
 
46
- const transport = await TransportNodeHid.create();
58
+ const transport = await TransportWeb.create();
47
59
  const ledgerSigner = new LedgerSigner(transport);
48
60
 
49
61
  Tezos.setProvider({ signer: ledgerSigner });
@@ -53,11 +65,9 @@ const publicKey = await Tezos.signer.publicKey();
53
65
  const publicKeyHash = await Tezos.signer.publicKeyHash();
54
66
  ```
55
67
 
68
+ ## Additional Info
56
69
  See the top-level [https://github.com/ecadlabs/taquito](https://github.com/ecadlabs/taquito) file for details on reporting issues, contributing and versioning.
57
70
 
58
- ## API Documentation
59
-
60
- TypeDoc style documentation is available on-line [here](https://tezostaquito.io/typedoc/modules/_taquito_ledger_signer.html)
61
71
 
62
72
  ## Disclaimer
63
73
 
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  exports.VERSION = {
6
- "commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
7
- "version": "11.2.0-beta-RC.0"
6
+ "commitHash": "81f0a5b103f867f57fbe5d526315c375a3788346",
7
+ "version": "11.2.0"
8
8
  };
9
9
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC9D,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,kBAAkB;CAChC,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC9D,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,QAAQ;CACtB,CAAC"}
@@ -148,8 +148,8 @@ function extractValue(idxLength, response) {
148
148
 
149
149
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
150
150
  const VERSION = {
151
- "commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
152
- "version": "11.2.0-beta-RC.0"
151
+ "commitHash": "81f0a5b103f867f57fbe5d526315c375a3788346",
152
+ "version": "11.2.0"
153
153
  };
154
154
 
155
155
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-ledger-signer.es6.js","sources":["../src/utils.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: any[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e03d983c780c7f96d8291ddd1251ea82f4581858\",\n \"version\": \"11.2.0-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, prefix, Prefix } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport sodium from 'libsodium-wrappers';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n}\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(\"44'/1729'\")) {\n throw new Error(\"The derivation path must start with 44'/1729'\");\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new Error(\n 'The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256'\n );\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new Error(`Unable to get the public key hash.`);\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerpublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n await sodium.ready;\n const publicKeyHash = b58cencode(\n sodium.crypto_generichash(20, compressedPublicKey),\n prefixes.prefPkh\n );\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerpublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new Error('Unable to retrieve public key');\n }\n }\n\n async secretKey(): Promise<string> {\n throw new Error('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (this.derivationType === DerivationType.ED25519) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new Error('Cannot parse ledger response.');\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: any): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (this.derivationType === DerivationType.ED25519) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SP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CACX,CAAC;aACH;YACD,OAAO,cAAc,CAAC;SACvB;KAAA;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,OAAO,EAAE;YAClD,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9B,CAAC;SACH;aAAM,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,SAAS,EAAE;YAC3D,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9B,CAAC;SACH;aAAM;YACL,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9B,CAAC;SACH;KACF;;;;;"}
1
+ {"version":3,"file":"taquito-ledger-signer.es6.js","sources":["../src/utils.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: any[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"81f0a5b103f867f57fbe5d526315c375a3788346\",\n \"version\": \"11.2.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, prefix, Prefix } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport sodium from 'libsodium-wrappers';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n}\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(\"44'/1729'\")) {\n throw new Error(\"The derivation path must start with 44'/1729'\");\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new Error(\n 'The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256'\n );\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new Error(`Unable to get the public key hash.`);\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerpublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n await sodium.ready;\n const publicKeyHash = b58cencode(\n sodium.crypto_generichash(20, compressedPublicKey),\n prefixes.prefPkh\n );\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerpublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new Error('Unable to retrieve public key');\n }\n }\n\n async secretKey(): Promise<string> {\n throw new Error('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (this.derivationType === DerivationType.ED25519) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new Error('Cannot parse ledger response.');\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: any): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (this.derivationType === DerivationType.ED25519) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SPPK],\n prefPkh: prefix[Prefix.TZ2],\n prefSig: prefix[Prefix.SPSIG],\n };\n } else {\n return {\n prefPk: prefix[Prefix.P2PK],\n prefPkh: prefix[Prefix.TZ3],\n prefSig: prefix[Prefix.P2SIG],\n };\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AAOA,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;;;SAOgB,qBAAqB,CAAC,IAAY;IAChD,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,UAAU,CAA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C,MAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9B,CAAC;SACH;aAAM;YACL,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9B,CAAC;SACH;KACF;;;;;"}
@@ -155,8 +155,8 @@
155
155
 
156
156
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
157
157
  const VERSION = {
158
- "commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
159
- "version": "11.2.0-beta-RC.0"
158
+ "commitHash": "81f0a5b103f867f57fbe5d526315c375a3788346",
159
+ "version": "11.2.0"
160
160
  };
161
161
 
162
162
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-ledger-signer.umd.js","sources":["../src/utils.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: any[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e03d983c780c7f96d8291ddd1251ea82f4581858\",\n \"version\": \"11.2.0-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, prefix, Prefix } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport sodium from 'libsodium-wrappers';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n}\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(\"44'/1729'\")) {\n throw new Error(\"The derivation path must start with 44'/1729'\");\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new Error(\n 'The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256'\n );\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new Error(`Unable to get the public key hash.`);\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerpublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n await sodium.ready;\n const publicKeyHash = b58cencode(\n sodium.crypto_generichash(20, compressedPublicKey),\n prefixes.prefPkh\n );\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerpublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new Error('Unable to retrieve public key');\n }\n }\n\n async secretKey(): Promise<string> {\n throw new Error('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (this.derivationType === DerivationType.ED25519) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new Error('Cannot parse ledger response.');\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: any): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (this.derivationType === DerivationType.ED25519) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SPPK],\n prefPkh: prefix[Prefix.TZ2],\n prefSig: prefix[Prefix.SPSIG],\n };\n } else {\n return {\n prefPk: prefix[Prefix.P2PK],\n prefPkh: prefix[Prefix.TZ3],\n prefSig: prefix[Prefix.P2SIG],\n };\n }\n }\n}\n"],"names":["DerivationType","b58cencode","sodium","prefix","Prefix"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;;IAOA,MAAM,cAAc,GAAG,GAAG,CAAC;IAE3B;;;;;;;aAOgB,qBAAqB,CAAC,IAAY;QAChD,MAAM,MAAM,GAAU,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO;YACzB,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,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,CAACC,YAAM,CAAC,IAAI,CAAC;oBAC3B,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,GAAG,CAAC;oBAC3B,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;aACH;iBAAM;gBACL,OAAO;oBACL,MAAM,EAAED,YAAM,CAACC,YAAM,CAAC,IAAI,CAAC;oBAC3B,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,GAAG,CAAC;oBAC3B,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;aACH;SACF;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-ledger-signer.umd.js","sources":["../src/utils.ts","../src/version.ts","../src/taquito-ledger-signer.ts"],"sourcesContent":["/*\n * Some code in this file is adapted from sotez\n * Copyright (c) 2018 Andrew Kishino\n */\n\nimport { DerivationType } from './taquito-ledger-signer';\n\nconst MAX_CHUNK_SIZE = 230;\n\n/**\n *\n * @description Convert the path to a buffer that will be used as LC and CDATA in the APDU send to the ledger device (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n *\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @returns A buffer where the first element is the length of the path (default is 4), then 3 bytes for each number of the path to which is added 0x8000000\n */\nexport function transformPathToBuffer(path: string): Buffer {\n const result: any[] = [];\n const components = path.split('/');\n components.forEach((element) => {\n let toNumber = parseInt(element, 10);\n if (Number.isNaN(toNumber)) {\n return;\n }\n if (element.length > 1 && element[element.length - 1] === \"'\") {\n toNumber += 0x80000000;\n }\n result.push(toNumber);\n });\n const buffer = Buffer.alloc(1 + result.length * 4);\n buffer[0] = result.length;\n result.forEach((element, index) => {\n buffer.writeUInt32BE(element, 1 + 4 * index);\n });\n return buffer;\n}\n\n/**\n *\n * @description Converts uncompressed ledger key to standard tezos binary representation\n */\nexport function compressPublicKey(publicKey: Buffer, curve: DerivationType) {\n if (curve === 0x00) {\n publicKey = publicKey.slice(1);\n } else {\n publicKey[0] = 0x02 + (publicKey[64] & 0x01);\n publicKey = publicKey.slice(0, 33);\n }\n return publicKey;\n}\n\nexport function appendWatermark(bytes: string, watermark?: Uint8Array): string {\n let transactionHex = bytes;\n if (typeof watermark !== 'undefined') {\n const hexWatermark = Buffer.from(watermark).toString('hex');\n transactionHex = hexWatermark.concat(bytes);\n }\n return transactionHex;\n}\n\n/**\n *\n * @description In order not to exceed the data length allowed by the Ledger device, split the operation into buffers of 230 bytes (max) and add them to the message to send to the Ledger\n * @param messageToSend The message to send to the Ledger device\n * @param operation The operation which will be chunk if its length is over 230 bytes\n * @returns The instruction to send to the Ledger device\n */\nexport function chunkOperation(messageToSend: any, operation: Buffer) {\n let offset = 0;\n while (offset !== operation.length) {\n const chunkSize =\n offset + MAX_CHUNK_SIZE >= operation.length ? operation.length - offset : MAX_CHUNK_SIZE;\n const buff = Buffer.alloc(chunkSize);\n operation.copy(buff, 0, offset, offset + chunkSize);\n messageToSend.push(buff);\n offset += chunkSize;\n }\n return messageToSend;\n}\n\n/**\n *\n * @description Verify if the signature returned by the ledger for tz2 and tz3 is valid\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns True if valid, false otherwise\n */\nexport function validateResponse(response: Buffer): boolean {\n let valid = true;\n if (response[0] !== 0x31 && response[0] !== 0x30) {\n valid = false;\n }\n if (response[1] + 4 !== response.length) {\n valid = false;\n }\n if (response[2] !== 0x02) {\n valid = false;\n }\n const rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n const idxLengthSVal = 5 + rLength;\n const sLength = response[idxLengthSVal];\n if (idxLengthSVal + 1 + sLength + 2 !== response.length) {\n valid = false;\n }\n return valid;\n}\n\n/**\n *\n * @description Extract a part of the response returned by the Ledger\n * @param idxLength The index in the response from the Ledger that corresponds to the length of the part to extract\n * @param response The signature returned by the Ledger (return from the signWithLedger function)\n * @returns An object that contains the extracted buffer, the index where it starts in the response and the length of the extracted part\n */\nexport function extractValue(idxLength: number, response: Buffer) {\n const buffer = Buffer.alloc(32);\n buffer.fill(0);\n\n let length = response[idxLength];\n let idxValueStart = idxLength + 1;\n if (length > 32) {\n idxValueStart += length - 32;\n length = 32;\n }\n response.copy(buffer, 32 - length, idxValueStart, idxValueStart + length);\n return { buffer, idxValueStart, length };\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"81f0a5b103f867f57fbe5d526315c375a3788346\",\n \"version\": \"11.2.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/ledger-signer\n */\n\nimport { Signer } from '@taquito/taquito';\nimport Transport from '@ledgerhq/hw-transport';\nimport { b58cencode, prefix, Prefix } from '@taquito/utils';\nimport {\n appendWatermark,\n transformPathToBuffer,\n compressPublicKey,\n chunkOperation,\n validateResponse,\n extractValue,\n} from './utils';\nimport sodium from 'libsodium-wrappers';\n\nexport type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>;\n\nexport enum DerivationType {\n ED25519 = 0x00, // tz1\n SECP256K1 = 0x01, // tz2\n P256 = 0x02, // tz3\n}\n\nexport const HDPathTemplate = (account: number) => {\n return `44'/1729'/${account}'/0'`;\n};\n\nexport { VERSION } from './version';\n\n/**\n *\n * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device\n *\n * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node)\n * @param path The ledger derivation path (default is \"44'/1729'/0'/0'\")\n * @param prompt Whether to prompt the ledger for public key (default is true)\n * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256)\n *\n * @example\n * ```\n * import TransportNodeHid from \"@ledgerhq/hw-transport-node-hid\";\n * const transport = await TransportNodeHid.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", false, DerivationType.ED25519);\n * ```\n *\n * @example\n * ```\n * import TransportU2F from \"@ledgerhq/hw-transport-u2f\";\n * const transport = await TransportU2F.create();\n * const ledgerSigner = new LedgerSigner(transport, \"44'/1729'/0'/0'\", true, DerivationType.SECP256K1);\n * ```\n */\nexport class LedgerSigner implements Signer {\n // constants for APDU requests (https://github.com/obsidiansystems/ledger-app-tezos/blob/master/APDUs.md)\n private readonly CLA = 0x80; // Instruction class (always 0x80)\n private readonly INS_GET_PUBLIC_KEY = 0x02; // Instruction code to get the ledger’s internal public key without prompt\n private readonly INS_PROMPT_PUBLIC_KEY = 0x03; // Instruction code to get the ledger’s internal public key with prompt\n private readonly INS_SIGN = 0x04; // Sign a message with the ledger’s key\n private readonly FIRST_MESSAGE_SEQUENCE = 0x00;\n private readonly LAST_MESSAGE_SEQUENCE = 0x81;\n private readonly OTHER_MESSAGE_SEQUENCE = 0x01;\n\n private _publicKey?: string;\n private _publicKeyHash?: string;\n constructor(\n private transport: LedgerTransport,\n private path: string = \"44'/1729'/0'/0'\",\n private prompt: boolean = true,\n private derivationType: DerivationType = DerivationType.ED25519\n ) {\n this.transport.setScrambleKey('XTZ');\n if (!path.startsWith(\"44'/1729'\")) {\n throw new Error(\"The derivation path must start with 44'/1729'\");\n }\n if (!Object.values(DerivationType).includes(derivationType)) {\n throw new Error(\n 'The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256'\n );\n }\n }\n\n async publicKeyHash(): Promise<string> {\n if (!this._publicKeyHash) {\n await this.publicKey();\n }\n if (this._publicKeyHash) {\n return this._publicKeyHash;\n }\n throw new Error(`Unable to get the public key hash.`);\n }\n\n async publicKey(): Promise<string> {\n if (this._publicKey) {\n return this._publicKey;\n }\n const responseLedger = await this.getLedgerpublicKey();\n const publicKeyLength = responseLedger[0];\n const rawPublicKey = responseLedger.slice(1, 1 + publicKeyLength);\n const compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);\n\n const prefixes = this.getPrefixes();\n const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);\n await sodium.ready;\n const publicKeyHash = b58cencode(\n sodium.crypto_generichash(20, compressedPublicKey),\n prefixes.prefPkh\n );\n\n this._publicKey = publicKey;\n this._publicKeyHash = publicKeyHash;\n return publicKey;\n }\n\n private async getLedgerpublicKey(): Promise<Buffer> {\n try {\n let ins = this.INS_PROMPT_PUBLIC_KEY;\n if (this.prompt === false) {\n ins = this.INS_GET_PUBLIC_KEY;\n }\n const responseLedger = await this.transport.send(\n this.CLA,\n ins,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n transformPathToBuffer(this.path)\n );\n return responseLedger;\n } catch (error) {\n throw new Error('Unable to retrieve public key');\n }\n }\n\n async secretKey(): Promise<string> {\n throw new Error('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n const watermarkedBytes = appendWatermark(bytes, watermark);\n const watermarkedBytes2buff = Buffer.from(watermarkedBytes, 'hex');\n let messageToSend = [];\n messageToSend.push(transformPathToBuffer(this.path));\n messageToSend = chunkOperation(messageToSend, watermarkedBytes2buff);\n const ledgerResponse = await this.signWithLedger(messageToSend);\n let signature;\n if (this.derivationType === DerivationType.ED25519) {\n signature = ledgerResponse.slice(0, ledgerResponse.length - 2).toString('hex');\n } else {\n if (!validateResponse(ledgerResponse)) {\n throw new Error('Cannot parse ledger response.');\n }\n const idxLengthRVal = 3; // Third element of response is length of r value\n const rValue = extractValue(idxLengthRVal, ledgerResponse);\n const idxLengthSVal = rValue.idxValueStart + rValue.length + 1;\n const sValue = extractValue(idxLengthSVal, ledgerResponse);\n const signatureBuffer = Buffer.concat([rValue.buffer, sValue.buffer]);\n signature = signatureBuffer.toString('hex');\n }\n\n return {\n bytes,\n sig: b58cencode(signature, prefix[Prefix.SIG]),\n prefixSig: b58cencode(signature, this.getPrefixes().prefSig),\n sbytes: bytes + signature,\n };\n }\n\n private async signWithLedger(message: any): Promise<Buffer> {\n // first element of the message represents the path\n let ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n this.FIRST_MESSAGE_SEQUENCE,\n this.derivationType,\n message[0]\n );\n for (let i = 1; i < message.length; i++) {\n const p1 =\n i === message.length - 1 ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(\n this.CLA,\n this.INS_SIGN,\n p1,\n this.derivationType,\n message[i]\n );\n }\n return ledgerResponse;\n }\n\n private getPrefixes() {\n if (this.derivationType === DerivationType.ED25519) {\n return {\n prefPk: prefix[Prefix.EDPK],\n prefPkh: prefix[Prefix.TZ1],\n prefSig: prefix[Prefix.EDSIG],\n };\n } else if (this.derivationType === DerivationType.SECP256K1) {\n return {\n prefPk: prefix[Prefix.SPPK],\n prefPkh: prefix[Prefix.TZ2],\n prefSig: prefix[Prefix.SPSIG],\n };\n } else {\n return {\n prefPk: prefix[Prefix.P2PK],\n prefPkh: prefix[Prefix.TZ3],\n prefSig: prefix[Prefix.P2SIG],\n };\n }\n }\n}\n"],"names":["DerivationType","b58cencode","sodium","prefix","Prefix"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;;IAOA,MAAM,cAAc,GAAG,GAAG,CAAC;IAE3B;;;;;;;aAOgB,qBAAqB,CAAC,IAAY;QAChD,MAAM,MAAM,GAAU,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO;YACzB,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACrC,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;gBAC1B,OAAO;aACR;YACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC7D,QAAQ,IAAI,UAAU,CAAC;aACxB;YACD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC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CAAC,GAAG,CAAC;oBAC3B,OAAO,EAAED,YAAM,CAACC,YAAM,CAAC,KAAK,CAAC;iBAC9B,CAAC;aACH;SACF;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/ledger-signer",
3
- "version": "11.2.0-beta-RC.0",
3
+ "version": "11.2.0",
4
4
  "description": "Ledger signer provider",
5
5
  "keywords": [
6
6
  "tezos",
@@ -58,8 +58,8 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@ledgerhq/hw-transport": "^6.20.0",
61
- "@taquito/taquito": "^11.2.0-beta-RC.0",
62
- "@taquito/utils": "^11.2.0-beta-RC.0",
61
+ "@taquito/taquito": "^11.2.0",
62
+ "@taquito/utils": "^11.2.0",
63
63
  "buffer": "^6.0.3",
64
64
  "libsodium-wrappers": "0.7.8"
65
65
  },
@@ -93,5 +93,5 @@
93
93
  "ts-toolbelt": "^9.6.0",
94
94
  "typescript": "~4.1.5"
95
95
  },
96
- "gitHead": "7cc9152cdad01bacca4a1b682c7cb0a33a24f544"
96
+ "gitHead": "7323157124742e8f2fdb11642f6b779cfb15df43"
97
97
  }
package/src/version.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
3
3
  export const VERSION = {
4
- "commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
5
- "version": "11.2.0-beta-RC.0"
4
+ "commitHash": "81f0a5b103f867f57fbe5d526315c375a3788346",
5
+ "version": "11.2.0"
6
6
  };