@ledgerhq/coin-casper
Version:
Ledger Casper integration
24 lines • 1.17 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.signMessage = void 0;
const logs_1 = require("@ledgerhq/logs");
const utils_1 = require("./common-logic/utils");
const signMessage = (signerContext) => async (deviceId, account, { message }) => {
(0, logs_1.log)("debug", "start signMessage process");
if (!message)
throw new Error(`Message cannot be empty`);
if (typeof message !== "string")
throw new Error(`Signing EIP712Message not supported`);
const r = await signerContext(deviceId, async (signer) => await signer.sign(account.freshAddressPath, (0, utils_1.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")}`,
};
};
exports.signMessage = signMessage;
exports.default = { signMessage: exports.signMessage };
//# sourceMappingURL=hw-signMessage.js.map
;