Open spacesailor24 opened 4 weeks ago
From another user:
I am getting this error as well, also during string decryption. Encryption and decryption the same way as @octoberak; sessionsSigs generated a bit differently though:
const createDelegateAuthSig = async (client, address) => {
const walletWithCapacityNFT = new Wallet(
String(process.env.CAPACITY_WALLET_PRIVATE_KEY)
);
try {
const { capacityDelegationAuthSig } =
await client.createCapacityDelegationAuthSig({
uses: "1",
dAppOwnerWallet: walletWithCapacityNFT,
capacityTokenId: CAPACITY_TOKEN_ID,
delegateeAddresses: [address],
});
return capacityDelegationAuthSig;
} catch (e) {
console.error("Error creating delegate auth sig", e);
return Promise.reject(e);
}
};
const generateSessionSigs = async (client, authSig) => {
const litResource = new LitActionResource("*");
try {
const capacityDelegationAuthSig = await createDelegateAuthSig(
client,
authSig.address
);
console.log("delegation auth sig", capacityDelegationAuthSig);
return await client.getSessionSigs({
chain,
resourceAbilityRequests: [
{
resource: litResource,
ability: LitAbility.AccessControlConditionDecryption,
},
],
capacityDelegationAuthSig,
authNeededCallback: async () => {
return authSig;
},
});
} catch (e) {
return Promise.reject(e);
}
};
I suspect it might have to do with incorrectly setting the uri parameter for the SIWE message.
I modified my createAuthSig function to look like this:
export const createAuthSig = async (params, wallet, litClient) => {
const sessionCapabilityObject = newSessionCapabilityObject();
const litResource = new LitAccessControlConditionResource("*");
sessionCapabilityObject.addCapabilityForResource(
litResource,
LitAbility.AccessControlConditionDecryption
);
sessionCapabilityObject.addCapabilityForResource(
litResource,
LitAbility.AccessControlConditionSigning
);
let siweMessage = new SiweMessage({
expirationTime: params.expiration,
address: wallet.address,
nonce: await litClient.getLatestBlockhash(),
statement:
params.statement,
chainId: 1,
uri: "https://example.com"
domain: "example.com",
version: "1",
});
siweMessage = sessionCapabilityObject.addToSiweMessage(siweMessage);
const preparedMessage = siweMessage.prepareMessage();
let signature;
if ("signMessage" in wallet) {
signature = await wallet.signMessage(preparedMessage);
} else if ("sign" in wallet) {
signature = await wallet.sign(preparedMessage);
}
return {
sig: signature,
derivedVia: "ethereum.web3.auth",
signedMessage: preparedMessage,
address: wallet.address,
};
}
};
I'm passing in a regular URL when creating the SIWE message. This is the only real difference between this version of the function and the one in my gist.
Is there a way to correctly generate the URI (it should look like lit:session:sdj3nonkdfsf...) so I can test if this is the case?
Description of the issue
with v3 and cayenne network, i following instruction here, for Making Encryption Requests, and get this errors when do decrypt with
decryptToString
:here's function that do encrypt and decrypt:
encryptString with the sessionSigs works fine, but when want to decrypt with same sessionSigs in decryptToString got 502 errors like above.
here's my function to get sessionSigs:
here's code on the github
Additional context
No response