GithubHelp home page GithubHelp logo

Getting the error message of "Invalid ipfsCid" when trying to decrypt the encrypted file uploaded to IPFS using the SDK about js-sdk HOT 4 CLOSED

lit-protocol avatar lit-protocol commented on July 20, 2024
Getting the error message of "Invalid ipfsCid" when trying to decrypt the encrypted file uploaded to IPFS using the SDK

from js-sdk.

Comments (4)

Eric1015 avatar Eric1015 commented on July 20, 2024

I have changed the implementation a little instead by getting the source code of the decryptFromIpfs function and put it in my custom function, replaced the code of getting the symmetric key to the following which is the normal way to get the symmetric key, but seems like I am getting the 500 error like the following, want to know how this issue can occur:

      const symmetricKey = await window.litNodeClient.getEncryptionKey({
        accessControlConditions: metadata.accessControlConditions,
        toDecrypt: metadata.encryptedSymmetricKeyString,
        chain,
        authSig,
      });

Error:

POST https://node2.litgateway.com:7371/web/encryption/retrieve 500 (Internal Server Error)

The code implementation of using the code extracted from the decryptFromIpfs can be found here: https://github.com/Eric1015/lit-encrypt-decrypt-file/tree/feature/extracted-version

Example file uploaded to IPFS: https://ipfs.io/ipfs/QmRCfFASmzJ2EfdBemdj59yY8rkEbghAfamqZ4TCia5EuU

from js-sdk.

Eric1015 avatar Eric1015 commented on July 20, 2024

I actually figured this out myself. I have chosen to use the serrano developer network for now. Although I know the contents uploaded there is subject to deletion, but for my personal project, I can tolerate this.

I don't know if anything additional is required in the mainnet, but according to the official document, the mainnet is in alpha state and that might be the reason why it does not function well enough to support my use case at this moment.

https://developer.litprotocol.com/support/stateofnetwork/

from js-sdk.

scientiststwin avatar scientiststwin commented on July 20, 2024

I believe, Your accessControlConditions are incorrect, which is why you (yourself) do not have permission to access the data and will see an error.

see below example:

const yourEthAddress = 'xxxxxxxxxx'
const accessControlConditions = [
  {
    contractAddress: '',
    standardContractType: '',
    chain: chain,
    method: '',
    parameters: [
      ':userAddress',
    ],
    returnValueTest: {
      comparator: '=',
      value: adminEthAddress
    }
  }
]

const ipfsCid = await litNodeClientNodejs.encryptToIpfs({
    authSig: authSigVal,
    chain: chain,
    string: stringForEncryption,
    litNodeClient: litNodeClient,
    accessControlConditions: accessControlConditions,
    infuraId: infuraId,
    infuraSecretKey: infuraSecretKey,
})

const str = await litNodeClientNodejs.decryptFromIpfs({
  authSig: authSigVal,
  ipfsCid: ipfsCid,
  litNodeClient: litNodeClient
})
console.log("[str] ", str)

It will be working fine :)

from js-sdk.

Eric1015 avatar Eric1015 commented on July 20, 2024

Hum, yeah seems like you are right.
I also made that change in my second try along with the network change, so I didn't notice it.

Thank you for the information, closing this issue.

from js-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.