@taquito/ledger-signer 11.0.0 → 11.1.0-stablelib.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.
@@ -43,7 +43,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.LedgerSigner = exports.VERSION = exports.HDPathTemplate = exports.DerivationType = void 0;
44
44
  var utils_1 = require("@taquito/utils");
45
45
  var utils_2 = require("./utils");
46
- var libsodium_wrappers_1 = require("libsodium-wrappers");
46
+ var blake2b_1 = require("@stablelib/blake2b");
47
47
  var DerivationType;
48
48
  (function (DerivationType) {
49
49
  DerivationType[DerivationType["ED25519"] = 0] = "ED25519";
@@ -141,10 +141,7 @@ var LedgerSigner = /** @class */ (function () {
141
141
  compressedPublicKey = utils_2.compressPublicKey(rawPublicKey, this.derivationType);
142
142
  prefixes = this.getPrefixes();
143
143
  publicKey = utils_1.b58cencode(compressedPublicKey, prefixes.prefPk);
144
- return [4 /*yield*/, libsodium_wrappers_1.default.ready];
145
- case 2:
146
- _a.sent();
147
- publicKeyHash = utils_1.b58cencode(libsodium_wrappers_1.default.crypto_generichash(20, compressedPublicKey), prefixes.prefPkh);
144
+ publicKeyHash = utils_1.b58cencode(blake2b_1.hash(compressedPublicKey, 20), prefixes.prefPkh);
148
145
  this._publicKey = publicKey;
149
146
  this._publicKeyHash = publicKeyHash;
150
147
  return [2 /*return*/, publicKey];
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-ledger-signer.js","sourceRoot":"","sources":["../../src/taquito-ledger-signer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,wCAA4D;AAC5D,iCAOiB;AACjB,yDAAwC;AAIxC,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,yDAAc,CAAA;IACd,6DAAgB,CAAA;IAChB,mDAAW,CAAA,CAAC,MAAM;AACpB,CAAC,EAJW,cAAc,GAAd,sBAAc,KAAd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C,CAAC,CAAC,CAAC,EAAA;;wBAAxG,cAAc,GAAG,SAAuF,CAAC;;;wBAFvE,CAAC,EAAE,CAAA;;4BAIvC,sBAAO,cAAc,EAAC;;;;KACvB;IAEO,kCAAW,GAAnB;QACE,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,OAAO,EAAE;YAClD,OAAO;gBACL,MAAM,EAAE,cAAM,CAAC,cAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,cAAM,CAAC,cAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,cAAM,CAAC,cAAM,CAAC,KAAK,CAAC;aAC9B,CAAA;SACF;aAAM,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,SAAS,EAAE;YAC3D,OAAO;gBACL,MAAM,EAAE,cAAM,CAAC,cAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,cAAM,CAAC,cAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,cAAM,CAAC,cAAM,CAAC,KAAK,CAAC;aAC9B,CAAA;SACF;aAAM;YACL,OAAO;gBACL,MAAM,EAAE,cAAM,CAAC,cAAM,CAAC,IAAI,CAAC;gBAC3B,OAAO,EAAE,cAAM,CAAC,cAAM,CAAC,GAAG,CAAC;gBAC3B,OAAO,EAAE,cAAM,CAAC,cAAM,CAAC,KAAK,CAAC;aAC9B,CAAA;SACF;IAEH,CAAC;IACH,mBAAC;AAAD,CAAC,AAxID,IAwIC;AAxIY,oCAAY"}
@@ -4,8 +4,8 @@ exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  /* tslint:disable */
6
6
  exports.VERSION = {
7
- "commitHash": "f7dbf5647ce1a35266ad921e6dd2aeef0b4aff93",
8
- "version": "11.0.0"
7
+ "commitHash": "a8af7336e7400f03b091c8b19373ecb2f49aef8e",
8
+ "version": "11.1.0-stablelib.0"
9
9
  };
10
10
  /* tslint:enable */
11
11
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC3E,oBAAoB;AACP,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,QAAQ;CACtB,CAAC;AACF,mBAAmB"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC3E,oBAAoB;AACP,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,oBAAoB;CAClC,CAAC;AACF,mBAAmB"}
@@ -1,5 +1,5 @@
1
1
  import { prefix, Prefix, b58cencode } from '@taquito/utils';
2
- import sodium from 'libsodium-wrappers';
2
+ import { hash } from '@stablelib/blake2b';
3
3
 
4
4
  /*! *****************************************************************************
5
5
  Copyright (c) Microsoft Corporation.
@@ -177,8 +177,8 @@ function extractValue(idxLength, response) {
177
177
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
178
178
  /* tslint:disable */
179
179
  var VERSION = {
180
- "commitHash": "f7dbf5647ce1a35266ad921e6dd2aeef0b4aff93",
181
- "version": "11.0.0"
180
+ "commitHash": "a8af7336e7400f03b091c8b19373ecb2f49aef8e",
181
+ "version": "11.1.0-stablelib.0"
182
182
  };
183
183
  /* tslint:enable */
184
184
 
@@ -279,10 +279,7 @@ var LedgerSigner = /** @class */ (function () {
279
279
  compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);
280
280
  prefixes = this.getPrefixes();
281
281
  publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);
282
- return [4 /*yield*/, sodium.ready];
283
- case 2:
284
- _a.sent();
285
- publicKeyHash = b58cencode(sodium.crypto_generichash(20, compressedPublicKey), prefixes.prefPkh);
282
+ publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);
286
283
  this._publicKey = publicKey;
287
284
  this._publicKeyHash = publicKeyHash;
288
285
  return [2 /*return*/, publicKey];
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-ledger-signer.es5.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 let 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 let 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 let chunkSize = 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{\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 let rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n let idxLengthSVal = 5 + rLength;\n let 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// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\n/* tslint:disable */\nexport const VERSION = {\n \"commitHash\": \"f7dbf5647ce1a35266ad921e6dd2aeef0b4aff93\",\n \"version\": \"11.0.0\"\n};\n/* tslint:enable */\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<string>, '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\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(\"The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256\")\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(sodium.crypto_generichash(20, compressedPublicKey), prefixes.prefPkh);\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(this.CLA, ins, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, transformPathToBuffer(this.path));\n return responseLedger;\n }\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 let 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 let 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(this.CLA, this.INS_SIGN, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, message[0]);\n for (let i = 1; i < message.length; i++) {\n let p1 = (i === message.length - 1) ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(this.CLA, this.INS_SIGN, p1, this.derivationType, message[i]);\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,IAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;;;SAOgB,qBAAqB,CAAC,IAAa;IAC/C,IAAM,MAAM,GAAU,EAAE,CAAC;IACzB,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,CAAC,UAAC,OAAO;QACvB,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YACxB,OAAO;SACV;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;YAC3D,QAAQ,IAAI,UAAU,CAAC;SAC1B;QACD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KACzB,CAAC,CAAC;IACH,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1B,MAAM,CAAC,OAAO,CAAC,UAAC,OAAO,EAAE,KAAK;QAC1B,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,KAA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.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 let 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 let 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 let chunkSize = 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{\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 let rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n let idxLengthSVal = 5 + rLength;\n let 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// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\n/* tslint:disable */\nexport const VERSION = {\n \"commitHash\": \"a8af7336e7400f03b091c8b19373ecb2f49aef8e\",\n \"version\": \"11.1.0-stablelib.0\"\n};\n/* tslint:enable */\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 { hash } from '@stablelib/blake2b';\n\nexport type LedgerTransport = Pick<Transport<string>, '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\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(\"The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256\")\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 const publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);\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(this.CLA, ins, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, transformPathToBuffer(this.path));\n return responseLedger;\n }\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 let 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 let 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(this.CLA, this.INS_SIGN, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, message[0]);\n for (let i = 1; i < message.length; i++) {\n let p1 = (i === message.length - 1) ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(this.CLA, this.INS_SIGN, p1, this.derivationType, message[i]);\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.P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AC,EAAA;;wBAAxG,cAAc,GAAG,SAAuF,CAAC;;;wBAFvE,CAAC,EAAE,CAAA;;4BAIvC,sBAAO,cAAc,EAAC;;;;KACvB;IAEO,kCAAW,GAAnB;QACE,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,CAAA;SACF;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,CAAA;SACF;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,CAAA;SACF;KAEF;IACH,mBAAC;AAAD,CAAC;;;;"}
@@ -1,12 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@taquito/utils'), require('libsodium-wrappers')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@taquito/utils', 'libsodium-wrappers'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoLedgerSigner = {}, global.utils, global.sodium));
5
- }(this, (function (exports, utils, sodium) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var sodium__default = /*#__PURE__*/_interopDefaultLegacy(sodium);
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@taquito/utils'), require('@stablelib/blake2b')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@taquito/utils', '@stablelib/blake2b'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoLedgerSigner = {}, global.utils, global.blake2b));
5
+ })(this, (function (exports, utils, blake2b) { 'use strict';
10
6
 
11
7
  /*! *****************************************************************************
12
8
  Copyright (c) Microsoft Corporation.
@@ -184,8 +180,8 @@
184
180
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
185
181
  /* tslint:disable */
186
182
  var VERSION = {
187
- "commitHash": "f7dbf5647ce1a35266ad921e6dd2aeef0b4aff93",
188
- "version": "11.0.0"
183
+ "commitHash": "a8af7336e7400f03b091c8b19373ecb2f49aef8e",
184
+ "version": "11.1.0-stablelib.0"
189
185
  };
190
186
  /* tslint:enable */
191
187
 
@@ -286,10 +282,7 @@
286
282
  compressedPublicKey = compressPublicKey(rawPublicKey, this.derivationType);
287
283
  prefixes = this.getPrefixes();
288
284
  publicKey = utils.b58cencode(compressedPublicKey, prefixes.prefPk);
289
- return [4 /*yield*/, sodium__default['default'].ready];
290
- case 2:
291
- _a.sent();
292
- publicKeyHash = utils.b58cencode(sodium__default['default'].crypto_generichash(20, compressedPublicKey), prefixes.prefPkh);
285
+ publicKeyHash = utils.b58cencode(blake2b.hash(compressedPublicKey, 20), prefixes.prefPkh);
293
286
  this._publicKey = publicKey;
294
287
  this._publicKeyHash = publicKeyHash;
295
288
  return [2 /*return*/, publicKey];
@@ -422,5 +415,5 @@
422
415
 
423
416
  Object.defineProperty(exports, '__esModule', { value: true });
424
417
 
425
- })));
418
+ }));
426
419
  //# sourceMappingURL=taquito-ledger-signer.umd.js.map
@@ -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 let 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 let 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 let chunkSize = 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{\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 let rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n let idxLengthSVal = 5 + rLength;\n let 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// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\n/* tslint:disable */\nexport const VERSION = {\n \"commitHash\": \"f7dbf5647ce1a35266ad921e6dd2aeef0b4aff93\",\n \"version\": \"11.0.0\"\n};\n/* tslint:enable */\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<string>, '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\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(\"The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256\")\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(sodium.crypto_generichash(20, compressedPublicKey), prefixes.prefPkh);\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(this.CLA, ins, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, transformPathToBuffer(this.path));\n return responseLedger;\n }\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 let 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 let 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(this.CLA, this.INS_SIGN, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, message[0]);\n for (let i = 1; i < message.length; i++) {\n let p1 = (i === message.length - 1) ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(this.CLA, this.INS_SIGN, p1, this.derivationType, message[i]);\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,IAAM,cAAc,GAAG,GAAG,CAAC;IAE3B;;;;;;;aAOgB,qBAAqB,CAAC,IAAa;QAC/C,IAAM,MAAM,GAAU,EAAE,CAAC;QACzB,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,UAAU,CAAC,OAAO,CAAC,UAAC,OAAO;YACvB,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACrC,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;gBACxB,OAAO;aACV;YACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC3D,QAAQ,IAAI,UAAU,CAAC;aAC1B;YACD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACzB,CAAC,CAAC;QACH,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAC1B,MAAM,CAAC,OAAO,CAAC,UAAC,OAAO,EAAE,KAAK;YAC1B,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;SAChD,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;aAIgB,iBAAiB,C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qBAAqB,GAAG,IAAI,CAAC,sBAAsB,CAAC;4BAC9E,qBAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAA;;4BAAxG,cAAc,GAAG,SAAuF,CAAC;;;4BAFvE,CAAC,EAAE,CAAA;;gCAIvC,sBAAO,cAAc,EAAC;;;;SACvB;QAEO,kCAAW,GAAnB;YACE,IAAI,IAAI,CAAC,cAAc,KAAKD,sBAAc,CAAC,OAAO,EAAE;gBAClD,OAAO;oBACL,MAAM,EAAEG,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,CAAA;aACF;iBAAM,IAAI,IAAI,CAAC,cAAc,KAAKJ,sBAAc,CAAC,SAAS,EAAE;gBAC3D,OAAO;oBACL,MAAM,EAAEG,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,CAAA;aACF;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,CAAA;aACF;SAEF;QACH,mBAAC;IAAD,CAAC;;;;;;;;;;;;"}
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 let 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 let 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 let chunkSize = 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{\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 let rLength = response[3];\n if (response[4 + rLength] !== 0x02) {\n valid = false;\n }\n\n let idxLengthSVal = 5 + rLength;\n let 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// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\n/* tslint:disable */\nexport const VERSION = {\n \"commitHash\": \"a8af7336e7400f03b091c8b19373ecb2f49aef8e\",\n \"version\": \"11.1.0-stablelib.0\"\n};\n/* tslint:enable */\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 { hash } from '@stablelib/blake2b';\n\nexport type LedgerTransport = Pick<Transport<string>, '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\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(\"The derivation type must be DerivationType.ED25519, DerivationType.SECP256K1 or DerivationType.P256\")\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 const publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);\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(this.CLA, ins, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, transformPathToBuffer(this.path));\n return responseLedger;\n }\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 let 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 let 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(this.CLA, this.INS_SIGN, this.FIRST_MESSAGE_SEQUENCE, this.derivationType, message[0]);\n for (let i = 1; i < message.length; i++) {\n let p1 = (i === message.length - 1) ? this.LAST_MESSAGE_SEQUENCE : this.OTHER_MESSAGE_SEQUENCE;\n ledgerResponse = await this.transport.send(this.CLA, this.INS_SIGN, p1, this.derivationType, message[i]);\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 pref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AO,CAAC,CAAC,CAAC,CAAC,EAAA;;4BAAxG,cAAc,GAAG,SAAuF,CAAC;;;4BAFvE,CAAC,EAAE,CAAA;;gCAIvC,sBAAO,cAAc,EAAC;;;;SACvB;QAEO,kCAAW,GAAnB;YACE,IAAI,IAAI,CAAC,cAAc,KAAKD,sBAAc,CAAC,OAAO,EAAE;gBAClD,OAAO;oBACL,MAAM,EAAEG,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,CAAA;aACF;iBAAM,IAAI,IAAI,CAAC,cAAc,KAAKJ,sBAAc,CAAC,SAAS,EAAE;gBAC3D,OAAO;oBACL,MAAM,EAAEG,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,CAAA;aACF;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,CAAA;aACF;SAEF;QACH,mBAAC;IAAD,CAAC;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/ledger-signer",
3
- "version": "11.0.0",
3
+ "version": "11.1.0-stablelib.0",
4
4
  "description": "Ledger signer provider",
5
5
  "keywords": [
6
6
  "tezos",
@@ -58,16 +58,15 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@ledgerhq/hw-transport": "^5.51.1",
61
- "@taquito/taquito": "^11.0.0",
62
- "@taquito/utils": "^11.0.0",
61
+ "@stablelib/blake2b": "^1.0.1",
62
+ "@taquito/taquito": "^11.1.0-stablelib.0",
63
+ "@taquito/utils": "^11.1.0-stablelib.0",
63
64
  "@types/jest": "^26.0.24",
64
- "buffer": "^6.0.3",
65
- "libsodium-wrappers": "0.7.8"
65
+ "buffer": "^6.0.3"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/jest": "^26.0.24",
69
69
  "@types/ledgerhq__hw-transport-node-hid": "^4.22.2",
70
- "@types/libsodium-wrappers": "0.7.8",
71
70
  "@types/node": "^15.12.2",
72
71
  "@types/ws": "^7.4.4",
73
72
  "@typescript-eslint/eslint-plugin": "^4.28.1",
@@ -95,5 +94,5 @@
95
94
  "tslint-config-standard": "^9.0.0",
96
95
  "typescript": "~4.1.5"
97
96
  },
98
- "gitHead": "631210a1b0a9120700b07f3395dc3a3255027dcf"
97
+ "gitHead": "127dbf8226d180c4adc8014afdd378e090558f7c"
99
98
  }
@@ -14,7 +14,7 @@ import {
14
14
  validateResponse,
15
15
  extractValue
16
16
  } from './utils';
17
- import sodium from 'libsodium-wrappers';
17
+ import { hash } from '@stablelib/blake2b';
18
18
 
19
19
  export type LedgerTransport = Pick<Transport<string>, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>
20
20
 
@@ -102,8 +102,7 @@ export class LedgerSigner implements Signer {
102
102
 
103
103
  const prefixes = this.getPrefixes();
104
104
  const publicKey = b58cencode(compressedPublicKey, prefixes.prefPk);
105
- await sodium.ready;
106
- const publicKeyHash = b58cencode(sodium.crypto_generichash(20, compressedPublicKey), prefixes.prefPkh);
105
+ const publicKeyHash = b58cencode(hash(compressedPublicKey, 20), prefixes.prefPkh);
107
106
 
108
107
  this._publicKey = publicKey;
109
108
  this._publicKeyHash = publicKeyHash;
package/src/version.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
3
3
  /* tslint:disable */
4
4
  export const VERSION = {
5
- "commitHash": "f7dbf5647ce1a35266ad921e6dd2aeef0b4aff93",
6
- "version": "11.0.0"
5
+ "commitHash": "a8af7336e7400f03b091c8b19373ecb2f49aef8e",
6
+ "version": "11.1.0-stablelib.0"
7
7
  };
8
8
  /* tslint:enable */
package/.eslintrc.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "es2021": true,
5
- "jest": true,
6
- "node": true
7
- },
8
- "extends": [
9
- "eslint:recommended",
10
- "../../.eslintrc.json"
11
- ],
12
- "parser": "@typescript-eslint/parser",
13
- "parserOptions": {
14
- "ecmaVersion": 12,
15
- "sourceType": "module"
16
- },
17
- "rules": {
18
- }
19
- }