Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum

Home Page:https://zokrates.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to initialize zokrates provider using zokrates-js

spencer-coti opened this issue · comments

Description

Unable to initialize ZoKrates provider using zokrates-js

Environment

  • Operating System: Mac
  • NodeJS version: 20.4.0

Steps to Reproduce

package.json:

{
  "dependencies": {
    "zokrates-js": "^1.1.8"
  }
}

test.js (using dynamic import):

const main = async () => {
    let { initialize } = await import("zokrates-js");
}

main()

Output:

globalThis.crypto = webcrypto;
                  ^

TypeError: Cannot set property crypto of #<Object> which has only a getter

test.mjs (notice file extension):

import { initialize } from "zokrates-js";

const main = async () => {
    console.log('hello')
}

main()

Output:

globalThis.crypto = webcrypto;
                  ^

TypeError: Cannot set property crypto of #<Object> which has only a getter

I was able to solve this by switching to NodeJS v16.16.0

Thanks for reporting this @spencer-coti!
Fixed in #1338