How to use the snarkjs.setup 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
console.log('Reusing', SETUP_FILEPATH)
            // The override flag isn't present and the setup exists, so read it
            setup = unstringifyBigInts(
                JSON.parse(
                    readFileSync(
                        SETUP_FILEPATH, 
                        'utf8'
                    )
                )
            )
            provingKey = setup.provingKey
            verifyingKey = setup.verifyingKey
        } else {
            // The override flag is present, so generate the setup
            console.log('Generating setup', SETUP_FILEPATH)
            setup = snarkjs.setup(circuit);
            provingKey = setup.vk_proof
            verifyingKey = setup.vk_verifier

            writeFileSync(
                SETUP_FILEPATH,
                JSON.stringify(
                    stringifyBigInts({
                        provingKey,
                        verifyingKey
                    })
                ),
                'utf8'
            )
        }
    } catch (err) {
        console.log('Error with the trusted setup')