How to use the snarkjs/src/stringifybigint.js.unstringifyBigInts function in snarkjs

To help you get started, we’ve selected a few snarkjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kobigurk / semaphore / test / contracts / semaphore.js View on Github external
const nullifiers_hash = w[circuit.getSignalIdx('main.nullifiers_hash')];
        assert(circuit.checkWitness(w));
        assert.equal(w[circuit.getSignalIdx('main.root')].toString(), identity_path.root);

        //console.log(w[circuit.getSignalIdx('main.root')]);

        /*
        console.log(tree[0]);
        console.log(w[circuit.getSignalIdx('main.signal_hash')]);
        console.log(w[circuit.getSignalIdx('main.external_nullifier')]);
        console.log(w[circuit.getSignalIdx('main.root')]);
        console.log(w[circuit.getSignalIdx('main.nullifiers_hash')]);
        console.log(w[circuit.getSignalIdx('main.identity_commitment.out')]);
        */

        const vk_proof = unstringifyBigInts(JSON.parse(fs.readFileSync(path.join(__dirname,'../../build/proving_key.json')).toString()));
        const {proof, publicSignals} = groth.genProof(vk_proof, w);
        await semaphore.broadcastSignal(
            signal_to_contract, 
            [ proof.pi_a[0].toString(), proof.pi_a[1].toString() ],
            [ [ proof.pi_b[0][1].toString(), proof.pi_b[0][0].toString() ], [ proof.pi_b[1][1].toString(), proof.pi_b[1][0].toString() ] ],
            [ proof.pi_c[0].toString(), proof.pi_c[1].toString() ],
            [ publicSignals[0].toString(), publicSignals[1].toString(), publicSignals[2].toString(), publicSignals[3].toString() ],
        );

        /*
        const evs = await semaphore.getPastEvents('allEvents', {
            fromBlock: 0,
            toBlock: 'latest'
        });
        console.log(evs);
        */