@thorchain/ledger-thorchain
Version:
Node API for THORChain App (Ledger Nano S/X)
29 lines • 1.77 kB
TypeScript
/// <reference types="node" />
import type Transport from "@ledgerhq/hw-transport";
import { PubKeyResponse, SignResponse, VersionResponse } from "./types";
export declare function serializeHRP(hrp: string): Buffer;
export declare function getBech32FromPK(hrp: string, pk: Buffer): string;
export declare function serializePath(path: number[]): Buffer;
export declare function signSendChunk(transport: Transport, chunkIdx: number, chunkNum: number, chunk: Buffer): Promise<SignResponse>;
export declare function getVersion(transport: Transport): Promise<VersionResponse>;
export declare function getPublicKey(transport: Transport, data: Buffer): Promise<PubKeyResponse>;
/**
* Takes raw output from Ledger device which is TLV encoded in the format "0x30 L 0x02 Lr r 0x02 Ls s"
* where L is length of entire message (after 2nd byte), Lr is length of r and Ls is length of s.
* This function extracts r and s, ensures they are 32 bytes each, joins into a single 64 byte Array.
* This value returned should be base64 encoded to a string to add to the JSON 'signatures' to send to RPC.
*
* Example raw sig:
* [ 48, 69, 2, 33,
* 0, 161, 207, 217, 127, 151, 190, 23, 98, 217, 186, 108, 82, 102, 19, 222, 20, 171, 6, 240, 134, 195, 251, 98, 190, 246, 228, 243, 215, 95, 166, 121, 165,
* 2, 32,
* 69, 188, 53, 213, 24, 9, 191, 90, 244, 21, 213, 146, 240, 109, 156, 221, 247, 63, 131, 52, 150, 253, 199, 153, 132, 76, 91, 239, 28, 254, 68, 80 ]
*
* 48 69 -- length is 69
* 2 33 -- length of r is 33 bytes
* <33 bytes of r> -- (the leading zero here can be dropped)
* 2 32 -- length of s is 32 bytes
* <32 bytes of s>
*/
export declare function extractSignatureFromTLV(signatureArray: Buffer): Buffer;
//# sourceMappingURL=helper.d.ts.map