UNPKG

@ledgerhq/coin-stacks

Version:
18 lines 827 B
import { getBufferFromString, getPath, throwIfError } from "../utils"; export const signMessage = (signerContext) => async (deviceId, account, { message }) => { if (!message) throw new Error(`Message cannot be empty`); if (typeof message !== "string") throw new Error(`Message must be string`); const r = await signerContext(deviceId, signer => signer.sign(getPath(account.freshAddressPath), getBufferFromString(message))); throwIfError(r); return { rsv: { r: r.signatureCompact.slice(0, 32).toString("hex"), s: r.signatureCompact.slice(32, 64).toString("hex"), v: parseInt(r.signatureCompact.slice(64, 65).toString("hex"), 16), }, signature: `0x${r.signatureVRS.toString("hex")}`, }; }; //# sourceMappingURL=signMessage.js.map