Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reclaim sdk does not support bun or macos #16

Open
roninjin10 opened this issue Oct 28, 2024 · 1 comment
Open

Reclaim sdk does not support bun or macos #16

roninjin10 opened this issue Oct 28, 2024 · 1 comment

Comments

@roninjin10
Copy link

To reproduce run any script using reclaim sdk using bun

import { ReclaimClient } from "@reclaimprotocol/zk-fetch";
import { verifyProof, transformForOnchain } from "@reclaimprotocol/js-sdk";

const apiUrl = "https://api.openai.com/v1/chat/completions";
const apiKey = process.env.OPENAI_API_KEY;
const reclaimPublicKey = process.env.RECLAIM_PUBLIC_KEY;
const reclaimPrivateKey = process.env.RECLAIM_PRIVATE_KEY;

const reclaimClient = new ReclaimClient(reclaimPublicKey, reclaimPrivateKey);

const getProof = async () => {
  const data = {
    model: "gpt-4o",
    messages: [
      {
        role: "system",
        content: "You are a helpful assistant.",
      },
      {
        role: "user",
        content: "Hello!",
      },
    ],
  };

  const publicOptions = {
    method: "POST",
    body: JSON.stringify(data),
    headers: {
      accept: "*/*",
      "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
      "content-type": "application/json",
    },
  };

  const privateOptions = {
    headers: {
      authorization: `Bearer ${apiKey}`,
    },
    responseMatches: [
      {
        type: "regex",
        value:
          '"choices":\\s*\\[\\s*{\\s*"index":\\s*0,\\s*"message":\\s*{\\s*"role":\\s*"assistant",\\s*"content":\\s*"(?<content>.*?)"',
      },
    ],
  };

  try {
    const proof = await reclaimClient.zkFetch(apiUrl, publicOptions, privateOptions);
    const isValidProof = await verifyProof(proof);
    return { proof, isValidProof };
  } catch (error) {
    console.error("Error during zkFetch:", error);
    if (error.response) {
      console.error("Response data:", error.response.data);
    }
  }
};

const main = async () => {
  const proof = await getProof();
  if (proof) {
    const transformedProof = transformForOnchain(proof.proof);
    console.log(transformedProof);
    const urlFromProof = JSON.parse(transformedProof.claimInfo.parameters).url;
    console.log(urlFromProof);
  } else {
    console.error("Failed to generate proof.");
  }
};

main()

You will get the following error

➜  daio git:(main) ✗ source .env && bun run zktls/reclaim.ts
warning: Node-API function "napi_type_tag_object" is not implemented yet.
 Track the status of Node-API in Bun: https://github.com/oven-sh/bun/issues/158
Gnark is only supported on linux x64 & ARM64. Error: Failed to load shared library: dlopen(/Users/williamcory/daio/node_modules/.p
npm/@reclaimprotocol+circom-symmetric-crypto@git+https+++git@github.com+reclaimprotocol+circom-sy_xxf3fxsuts3gw5j75fssr426le/node_
modules/@reclaimprotocol/circom-symmetric-crypto/resources/gnark/arm64/libverify.so, 0x0006): tried: '/Users/williamcory/daio/node
_modules/.pnpm/@reclaimprotocol+circom-symmetric-crypto@git+https+++git@github.com+reclaimprotocol+circom-sy_xxf3fxsuts3gw5j75fssr
426le/node_modules/@reclaimprotocol/circom-symmetric-crypto/resources/gnark/arm64/libverify.so' (not a mach-o file), '/System/Volu
mes/Preboot/Cryptexes/OS/Users/williamcory/daio/node_modules/.pnpm/@reclaimprotocol+circom-symmetric-crypto@git+https+++git@github
.com+reclaimprotocol+circom-sy_xxf3fxsuts3gw5j75fssr426le/node_modules/@reclaimprotocol/circom-symmetric-crypto/resources/gnark/ar
m64/libverify.so' (no such file), '/Users/williamcory/daio/node_modules/.pnpm/@reclaimprotocol+circom-symmetric-crypto@git+https++
+git@github.com+reclaimprotocol+circ
dyld[35193]: missing symbol called
[1]    35193 abort      bun run zktls/reclaim.ts
@roninjin10
Copy link
Author

Getting another bug using node that is platform specific

Gnark is only supported on linux x64 & ARM64. Error: Failed to load shared library: dlopen(/Users/williamcory/daio/node_modules/.p
npm/@reclaimprotocol+circom-symmetric-crypto@git+https+++git@github.com+reclaimprotocol+circom-sy_xxf3fxsuts3gw5j75fssr426le/node_
modules/@reclaimprotocol/circom-symmetric-crypto/resources/gnark/arm64/libverify.so, 0x0006): tried: '/Users/williamcory/daio/node
_modules/.pnpm/@reclaimprotocol+circom-symmetric-crypto@git+https+++git@github.com+reclaimprotocol+circom-sy_xxf3fxsuts3gw5j75fssr
426le/node_modules/@reclaimprotocol/circom-symmetric-crypto/resources/gnark/arm64/libverify.so' (not a mach-o file), '/System/Volu
mes/Preboot/Cryptexes/OS/Users/williamcory/daio/node_modules/.pnpm/@reclaimprotocol+circom-symmetric-crypto@git+https+++git@github
.com+reclaimprotocol+circom-sy_xxf3fxsuts3gw5j75fssr426le/node_modules/@reclaimprotocol/circom-symmetric-crypto/resources/gnark/ar
m64/libverify.so' (no such file), '/Users/williamcory/daio/node_modules/.pnpm/@reclaimprotocol+circom-symmetric-crypto@git+https++
+git@github.com+reclaimprotocol+circ
/Users/williamcory/daio/node_modules/.pnpm/@reclaimprotocol+zk-fetch@0.2.0_js-base64@3.7.7/node_modules/@reclaimprotocol/zk-fetch/
src/utils.ts:28
      throw new InvalidParamError(`${paramName} passed to ${functionName} must not be null or undefined.`);

@roninjin10 roninjin10 changed the title Reclaim sdk does not support bun Reclaim sdk does not support bun or macos Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant