Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.8k stars 360 forks source link

Unable to initialize zokrates provider using zokrates-js #1335

Closed spencer-coti closed 11 months ago

spencer-coti commented 1 year ago

Description

Unable to initialize ZoKrates provider using zokrates-js

Environment

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
spencer-coti commented 1 year ago

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

dark64 commented 1 year ago

Thanks for reporting this @spencer-coti! Fixed in https://github.com/Zokrates/ZoKrates/pull/1338