iden3 / snarkjs

zkSNARK implementation in JavaScript & WASM
GNU General Public License v3.0
1.75k stars 421 forks source link

Can't export solidityverifier #120

Closed aa-sniperman closed 2 years ago

aa-sniperman commented 2 years ago

I followed the instruction in https://www.npmjs.com/package/snarkjs/v/0.4.10, at step Exporting verifier solidity contract, i got an error:

D:\Circom\Project1>snarkjs zkey export solidityverifier circuit_final.zkey verifier.sol [ERROR] snarkJS: [Error: ENOENT: no such file or directory, open 'D:\C:\Users\84325\AppData\Roaming\npm\node_modules\snarkjs\templates\verifier_groth16.sol.ejs'] { errno: -4058, code: 'ENOENT', syscall: 'open', path: 'D:\C:\Users\84325\AppData\Roaming\npm\node_modules\snarkjs\templates\verifier_groth16.sol.ejs' }

How can I fix it?

wizicer commented 2 years ago

I'm facing exactly same error, how do you fix this?

ddengster commented 2 years ago

Directory paths for windows seem to be malformed like those in issue #57 , seems like all the devs are using mainly linux.

Find the cli.cjs in your Roaming npm snarkjs folder, then search for a verifier_groth16 string for where it references the file. If you do console.log(path__default["default"].join(__dirname$1, "..", "templates", "verifier_groth16.sol.ejs")) you'll see it adds a \ character, just remove it, something like:

var groth16file = path__default["default"].join(__dirname$1, "..", "templates", "verifier_groth16.sol.ejs");
groth16file = groth16file.substring(1, groth16file.len);
console.log(groth16file);
templates.groth16 = await fs__default["default"].promises.readFile(groth16file, "utf8");

Ofc this is a hack and should be resolved properly.