Skip to content

feat(proof): feat(proof): support single-threaded proof generation#1090

Open
pengqima wants to merge 1 commit into
semaphore-protocol:mainfrom
pengqima:fix-single-thread-proof-generation
Open

feat(proof): feat(proof): support single-threaded proof generation#1090
pengqima wants to merge 1 commit into
semaphore-protocol:mainfrom
pengqima:fix-single-thread-proof-generation

Conversation

@pengqima

Copy link
Copy Markdown

Description

BREAKING CHANGE: n

re #1072

Description

This PR adds an optional GenerateProofOptions argument to generateProof and forwards its singleThread flag to the snarkjs Groth16 prover.

In runtimes where worker threads are unavailable, such as Bun v1.3.2, proof generation currently fails before a proof can be produced. Consumers can now opt into single-threaded proof generation:

const proof = await generateProof(identity, group, message, scope, treeDepth, undefined, {
    singleThread: true
})

The existing multithreaded behavior remains the default, so this change is backward-compatible.
This PR also:
validates the singleThread option at runtime
exports the new GenerateProofOptions type
documents the new option in the proof package README
adds a regression test that generates a valid proof in single-threaded mode
updates @types/snarkjs to a version that includes the prover options supported by the installed snarkjs runtime

Related Issue(s)

Closes #1072

Other information

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run yarn format and yarn lint without getting any errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Important

We do not accept pull requests for minor grammatical fixes (e.g., correcting typos, rewording sentences) or for fixing broken links, unless they significantly improve clarity or functionality. These contributions, while appreciated, are not a priority for merging. If you notice any of these issues, please create a GitHub Issue to report them so they can be properly tracked and addressed.

@pengqima
pengqima requested a review from a team as a code owner July 16, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for single-threaded proof generation (Bun compatibility)

1 participant