Vana SDK - v0.1.0
    Preparing search index...

    Function decryptBlobWithSignedKey

    • Decrypts data using a signed key generated from the user's wallet signature.

      Parameters

      • encryptedData: string | Blob

        The encrypted data to decrypt (string or Blob)

      • key: string

        The signed key from generateEncryptionKey - MUST be the same wallet signature used for encryption

      • platformAdapter: VanaPlatformAdapter

        The platform adapter for crypto operations

      Returns Promise<Blob>

      Promise resolving to the decrypted blob

      This is a pure cryptographic primitive for decrypting data that was encrypted using encryptBlobWithSignedKey. It is network-agnostic and only handles decryption - it does not fetch data from any URL or make network requests. To decrypt a file from a URL, you must first fetch the encrypted blob using one of the fetch utilities, then pass it to this function.

      The key parameter must be the same signature that was used for encryption, typically generated by the generateEncryptionKey utility. This ensures that only the user who encrypted the data (or someone with the same wallet signature) can decrypt it.

      When decryption fails due to wrong key or corrupted data

      // Generate the same encryption key used for encryption
      const encryptionKey = await generateEncryptionKey(walletClient);

      // Fetch and decrypt using the high-level API
      const file = await vana.data.getUserFiles({ owner: "0x..." })[0];
      const decryptedBlob = await vana.data.decryptFile(file);

      // Or use the low-level primitives directly
      const encryptedBlob = await vana.data.fetch(file.url);
      const decryptedBlob = await decryptBlobWithSignedKey(
      encryptedBlob,
      encryptionKey,
      platformAdapter
      );

      // With IPFS gateway fallback
      const encryptedBlob = await vana.data.fetchFromIPFS(file.url, {
      gateways: ['https://my-gateway.com/ipfs/', 'https://ipfs.io/ipfs/']
      });
      const decryptedBlob = await decryptBlobWithSignedKey(
      encryptedBlob,
      encryptionKey,
      platformAdapter
      );