UNPKG

@taquito/ledger-signer

Version:

Ledger signer provider

76 lines (75 loc) 2.85 kB
/** * @packageDocumentation * @module @taquito/ledger-signer */ import { Signer } from '@taquito/taquito'; import Transport from '@ledgerhq/hw-transport'; export { InvalidDerivationPathError } from '@taquito/core'; export type LedgerTransport = Pick<Transport, 'send' | 'decorateAppAPIMethods' | 'setScrambleKey'>; export declare enum DerivationType { ED25519 = 0,// tz1 SECP256K1 = 1,// tz2 P256 = 2,// tz3 BIP32_ED25519 = 3 } export { InvalidDerivationTypeError } from './errors'; export declare const HDPathTemplate: (account: number) => string; export { VERSION } from './version'; /** * * @description Implementation of the Signer interface that will allow signing operation from a Ledger Nano device * * @param transport A transport instance from LedgerJS libraries depending on the platform used (e.g. Web, Node) * @param path The ledger derivation path (default is "44'/1729'/0'/0'") * @param prompt Whether to prompt the ledger for public key (default is true) * @param derivationType The value which defines the curve to use (DerivationType.ED25519(default), DerivationType.SECP256K1, DerivationType.P256, DerivationType.BIP32_ED25519) * * @example * ``` * import TransportNodeHid from "@ledgerhq/hw-transport-node-hid"; * const transport = await TransportNodeHid.create(); * const ledgerSigner = new LedgerSigner(transport, "44'/1729'/0'/0'", false, DerivationType.ED25519); * ``` * * @example * ``` * import TransportU2F from "@ledgerhq/hw-transport-u2f"; * const transport = await TransportU2F.create(); * const ledgerSigner = new LedgerSigner(transport, "44'/1729'/0'/0'", true, DerivationType.SECP256K1); * ``` * * @example * ``` * import TransportU2F from "@ledgerhq/hw-transport-u2f"; * const transport = await TransportU2F.create(); * const ledgerSigner = new LedgerSigner(transport, "44'/1729'/6'/0'", true, DerivationType.BIP32_ED25519); * ``` */ export declare class LedgerSigner implements Signer { private transport; private path; private prompt; private derivationType; private readonly CLA; private readonly INS_GET_PUBLIC_KEY; private readonly INS_PROMPT_PUBLIC_KEY; private readonly INS_SIGN; private readonly FIRST_MESSAGE_SEQUENCE; private readonly LAST_MESSAGE_SEQUENCE; private readonly OTHER_MESSAGE_SEQUENCE; private _publicKey?; private _publicKeyHash?; constructor(transport: LedgerTransport, path?: string, prompt?: boolean, derivationType?: DerivationType); publicKeyHash(): Promise<string>; publicKey(): Promise<string>; private getLedgerPublicKey; secretKey(): Promise<string>; sign(bytes: string, watermark?: Uint8Array): Promise<{ bytes: string; sig: string; prefixSig: string; sbytes: string; }>; private signWithLedger; private getPrefixes; }