我正在通过这个https://github.com/iden3/snarkjs通过.circom和snarkJS进行zk汇总,当我试图运行index.html代码时,它并没有按照它应该运行的方式工作。并给出了误差bn.inherits is not a function。HTML代码:-
<!doctype html>
<html>
<head>
<title>Snarkjs client example</title>
</head>
<body>
<h1>Snarkjs client example</h1>
<button id="bGenProof"> Create proof </button>
<!-- JS-generated output will be added here. -->
<pre class="proof"> Proof: <code id="proof"></code></pre>
<pre class="proof"> Result: <code id="result"></code></pre>
<script src="snarkjs.min.js"></script>
<!-- This is the bundle generated by rollup.js -->
<script>
const proofComponent = document.getElementById('proof');
const resultComponent = document.getElementById('result');
const bGenProof = document.getElementById("bGenProof");
bGenProof.addEventListener("click", calculateProof);
async function calculateProof() {
const { proof, publicSignals } =
await snarkjs.groth16.fullProve({"a":"123","b":"234"}, "product.wasm", "product_0000.zkey");
proofComponent.innerHTML = JSON.stringify(proof, null, 1);
const vkey = await fetch("verification_key.json").then( function(res) {
return res.json();
});
const res = await snarkjs.groth16.verify(vkey, publicSignals, proof);
resultComponent.innerHTML = res;
}
</script>
</body>
</html>
发布于 2023-03-07 16:52:20
我刚刚从github/ got 3中获得了使用最新snarkjs.min.js的错误
我有一个早在2023年的文件,它的工作没有错误的发现。我建议从git历史上下载一个文件。
https://ethereum.stackexchange.com/questions/145187
复制相似问题