How to use the snarkjs.genProof 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.

github weijiekoh / zkmm / mastermind / src / old.ts View on Github external
pubGuessC: testCase.guess[2],
            pubGuessD: testCase.guess[3],
            privSolnA: testCase.soln[0],
            privSolnB: testCase.soln[1],
            privSolnC: testCase.soln[2],
            privSolnD: testCase.soln[3],

        try {
            console.log('The codemaster calculates the witness')
            const witness = circuit.calculateWitness(testInput)

            console.log('The codemaster generates a proof', new Date())

            // Codemaster generates the proof and public signals
            const { proof, publicSignals } = snarkjs.genProof(provingKey, witness);

            // Save to file
                PROOF_AND_SIGNALS_DIR + '/' + i.toString() + '.json',
                    stringifyBigInts({ proof, publicSignals }),

            console.log('Verifying proof', new Date())
            const isValid: boolean = snarkjs.isValid(verifyingKey, proof, publicSignals)

            if (!isValid) {
                throw new Error('Invalid proof')
            } else {