Skip to main content
Version: v3.x.x

Signing with EIP191

Use EIP191 eth_personal_sign to sign a message instead of a transaction or raw signature.

This can be done with

LitActions.ethPersonalSignMessageEcdsa({ message, publicKey , sigName }); 

It will prepend "\x19Ethereum Signed Message:\n" to the message and then hash and sign it according to

const go = async () => {
const message = "Hello World";
const litNodeClient = new LitJsSdk.LitNodeClient({
litNetwork: "cayenne",
await litNodeClient.connect();

const signatures = await litNodeClient.executeJs({
code: litActionCode,
jsParams: {
// this is the string "Hello World" for testing
sigName: "sig1",
console.log("signatures: ", signatures);
const sig = signatures.sig1;
const dataSigned = "0x" + sig.dataSigned;
const encodedSig = joinSignature({
r: "0x" + sig.r,
s: "0x" + sig.s,
v: sig.recid,

console.log("encodedSig", encodedSig);
console.log("sig length in bytes: ", encodedSig.substring(2).length / 2);
console.log("dataSigned", dataSigned);
const splitSig = splitSignature(encodedSig);
console.log("splitSig", splitSig);

const recoveredPubkey = recoverPublicKey(dataSigned, encodedSig);
console.log("uncompressed recoveredPubkey", recoveredPubkey);
const compressedRecoveredPubkey = computePublicKey(recoveredPubkey, true);
console.log("compressed recoveredPubkey", compressedRecoveredPubkey);
const recoveredAddress = recoverAddress(dataSigned, encodedSig);
console.log("recoveredAddress", recoveredAddress);

const recoveredAddressViaMessage = verifyMessage(message, encodedSig);
console.log("recoveredAddressViaMessage", recoveredAddressViaMessage);