@ledgerhq/coin-filecoin
Version:
Ledger Filecoin Coin integration
19 lines • 926 B
JavaScript
import { log } from "@ledgerhq/logs";
import { getBufferFromString } from "./bridge/utils";
export const signMessage = (signerContext) => async (deviceId, account, { message }) => {
log("debug", "start signMessage process");
if (typeof message !== "string")
throw new Error("Invalid message type");
if (!message)
throw new Error("Message cannot be empty");
const r = await signerContext(deviceId, signer => signer.sign(account.freshAddressPath, getBufferFromString(message)));
return {
rsv: {
r: Buffer.from(r.signature_compact.slice(0, 32)).toString("hex"),
s: Buffer.from(r.signature_compact.slice(32, 64)).toString("hex"),
v: parseInt(Buffer.from(r.signature_compact.slice(64, 65)).toString("hex"), 16),
},
signature: `0x${Buffer.from(r.signature_compact).toString("hex")}`,
};
};
//# sourceMappingURL=hw-signMessage.js.map