LIT-Protocol / js-sdk

The Lit Protocol SDK provides developers with a framework for implementing Lit functionality into their own applications.
https://developer.litprotocol.com
MIT License
105 stars 65 forks source link

Feature/lit 3945 js sdk add sendtosinglenode feature #677

Closed Ansonhkg closed 1 month ago

Ansonhkg commented 1 month ago

Description

❗️❗️Note that setting the number of required responses to less than the threshold will cause Lit.Actions.signEcdsa to fail when running executeJs because ECDSA requires a minimum number of participants (the threshold) to collaboratively generate a valid signature. If fewer nodes participate, the signature cannot be formed, leading to a failure.

eg.

❌ Not good

  const res = await devEnv.litNodeClient.executeJs({
    sessionSigs: eoaSessionSigs,
    code: `(async () => {
      const sigShare = await LitActions.signEcdsa({ <== 👈 Signing using ECDSA 
        toSign: dataToSign,
        publicKey,
        sigName: "sig",
      });
    })();`,
    jsParams: {
      dataToSign: alice.loveLetter,
      publicKey: alice.pkp.publicKey,
    },
    numResponsesRequired: 1, <=== ❌ This will fail, eg. need at least 5 if we have connected to 9 nodes
  });

✅ This is good

  const res = await devEnv.litNodeClient.executeJs({
    sessionSigs: eoaSessionSigs,
    code: `(async () => {
        console.log("testing"); <=== 👈 Only console.logging
    })();`,
    jsParams: {
      dataToSign: alice.loveLetter,
      publicKey: alice.pkp.publicKey,
    },
    numResponsesRequired: 1, <=== ✅ Das ist gut 
  });
MaximusHaximus commented 1 month ago

❇️ thanks @Ansonhkg -- I'll update the call from the batchGeneratePrivateKeys functions in wrapped-keys in the LIT-3920 branch 👍