Skip to content

Added service worker compatibility for snarkjs proof generation#72

Open
SergeyG-Solicy wants to merge 4 commits intomainfrom
feature/zk-service-worker-compatibility
Open

Added service worker compatibility for snarkjs proof generation#72
SergeyG-Solicy wants to merge 4 commits intomainfrom
feature/zk-service-worker-compatibility

Conversation

@SergeyG-Solicy
Copy link
Copy Markdown
Contributor

@SergeyG-Solicy SergeyG-Solicy commented Jan 26, 2026

User description

  • Switched from @cryptkeeperzk/snarkjs to [email protected] (has singleThread option)
  • Implemented hybrid environment detection for restricted contexts
  • Auto-detected Chrome MV3 service workers, Cloudflare Workers, Bun runtime
  • Used a singleThread mode only when Web Workers are unavailable
  • Added ProofGenerator.configure() API for manual override

Fixed ZK proof generation in Chrome MV3 extension service workers.


PR Type

Enhancement, Bug fix


Description

  • Switched from @cryptkeeperzk/snarkjs to [email protected] for singleThread support

  • Implemented hybrid environment detection for restricted contexts

  • Auto-detects Chrome MV3 service workers, Cloudflare Workers, Bun runtime

  • Added ProofGenerator.configure() API for manual override and logging

  • Uses single-threaded mode only when Web Workers unavailable


Diagram Walkthrough

flowchart LR
  A["Environment Detection"] -->|"Restricted Context"| B["Single-threaded Mode"]
  A -->|"Standard Browser/Node.js"| C["Parallel Workers Mode"]
  D["ProofGenerator.configure()"] -->|"Manual Override"| B
  D -->|"Manual Override"| C
  B --> E["snarkjs.groth16.fullProve"]
  C --> E
  E --> F["ZK Proof Generated"]
Loading

File Walkthrough

Relevant files
Enhancement
ProofGenerator.ts
Hybrid environment detection and configuration API             

src/encryption/zK/identity/ProofGenerator.ts

  • Added isRestrictedWorkerEnvironment() function to detect Chrome MV3
    service workers, Cloudflare Workers, Bun runtime, and other restricted
    contexts
  • Implemented ProofGeneratorConfig interface with forceSingleThread and
    logger options
  • Added configure(), getConfig(), and willUseSingleThread() exported
    functions for global configuration
  • Updated generateIdentityProof() to use singleThread option based on
    environment detection
  • Added logging support for proof generation mode selection
  • Fixed verifyProof() to include curve: 'bn128' in snarkjs proof format
  • Switched import from @cryptkeeperzk/snarkjs to snarkjs
+144/-1 
Dependencies
package.json
Update snarkjs dependency and add type definitions             

package.json

  • Replaced @cryptkeeperzk/snarkjs@^0.7.2 with snarkjs@^0.7.5 in
    dependencies
  • Added @types/snarkjs@^0.7.9 to devDependencies for TypeScript type
    support
+2/-1     

Summary by CodeRabbit

  • New Features

    • Proof generation now adapts to runtime environment (single-thread or parallel) with a public configuration API and optional structured logging; proofs include compatibility metadata for verification.
  • Chores

    • Cryptography dependency replaced and TypeScript types added to improve compatibility and developer experience.

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Jan 26, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Supply chain dependency

Description: The PR changes the cryptographic dependency from @cryptkeeperzk/snarkjs to the public npm
package snarkjs (and adds @types/snarkjs), which introduces a potential supply-chain risk
if the new package or its transitive dependencies are compromised or if the published code
differs from the previously vetted fork.
package.json [99-166]

Referred Code
"snarkjs": "^0.7.5",
"@kynesyslabs/demosdk": "^2.8.22",
"@metaplex-foundation/js": "^0.20.1",
"@multiversx/sdk-core": "^13.17.2",
"@multiversx/sdk-extension-provider": "^3.0.0",
"@multiversx/sdk-network-providers": "^2.9.3",
"@multiversx/sdk-wallet": "^4.6.0",
"@noble/curves": "1.9.4",
"@noble/hashes": "1.8.0",
"@noble/post-quantum": "^0.4.1",
"@project-serum/anchor": "^0.26.0",
"@roamhq/wrtc": "^0.8.0",
"@scure/bip39": "^2.0.1",
"@simplewebauthn/browser": "^11.0.0",
"@simplewebauthn/server": "^11.0.0",
"@solana/buffer-layout": "^4.0.1",
"@solana/web3.js": "1.98.0",
"@ton/core": "^0.62.0",
"@ton/crypto": "^3.3.0",
"@ton/ton": "^16.0.0",
"@types/simple-peer": "^9.11.8",


 ... (clipped 47 lines)
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing audit context: The newly added proof-mode logging does not include audit-trail context (e.g., user ID,
timestamp, outcome) which may be required if proof generation is considered a critical
security action.

Referred Code
// REVIEW: Phase 10.5 - Hybrid environment detection
// Automatically use singleThread in restricted environments (service workers, etc.)
// Use parallel workers in standard browser/Node.js for better performance
const useSingleThread = willUseSingleThread()

if (globalConfig.logger?.info) {
    globalConfig.logger.info(
        `[ProofGenerator] Using ${useSingleThread ? 'single-threaded' : 'parallel'} mode`
    )
}

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Unhandled prove failures: The new fullProve invocation uses environment-dependent options but is not wrapped with
additional contextual error handling, so failures may surface without actionable context
depending on upstream callers.

Referred Code
// REVIEW: Phase 10.5 - Hybrid environment detection
// Automatically use singleThread in restricted environments (service workers, etc.)
// Use parallel workers in standard browser/Node.js for better performance
const useSingleThread = willUseSingleThread()

if (globalConfig.logger?.info) {
    globalConfig.logger.info(
        `[ProofGenerator] Using ${useSingleThread ? 'single-threaded' : 'parallel'} mode`
    )
}

// REVIEW: Phase 10.1 - Production-ready proof generation using snarkjs
const { proof, publicSignals } = await snarkjs.groth16.fullProve(
    circuitInputs,
    wasmPath,
    zkeyPath,
    undefined, // logger
    undefined, // wtnsCalcOptions
    useSingleThread ? { singleThread: true } : undefined, // proverOptions - auto-detect environment
)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status:
Error message exposure: The updated verification path constructs and throws a new error in a catch block, but the
diff does not show whether the thrown message includes internal error details that could
leak to end users.

Referred Code
    return await snarkjs.groth16.verify(vkey, publicSignals, snarkjsProof)
} catch (error) {
    throw new Error(

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
External artifact trust: Proof generation relies on remote circuit artifacts loaded from CDN URLs, and the diff
does not show integrity/authenticity validation (e.g., pinning or checksums) for these
external inputs.

Referred Code
// REVIEW: Phase 10.4 - Production CDN URLs for circuit artifacts
const wasmPath = 'https://files.demos.sh/zk-circuits/v1/identity_with_merkle.wasm'
const zkeyPath = 'https://files.demos.sh/zk-circuits/v1/identity_with_merkle_final.zkey'

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 88f16fcd-bd14-4212-a39d-44491a070b46

📥 Commits

Reviewing files that changed from the base of the PR and between 7ce051a and f9f2d30.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • package.json

Walkthrough

Replaced a forked snarkjs dependency with the official snarkjs (plus types) and added an environment-aware ProofGenerator API: global config, restricted-worker detection, single-thread control, witness calculation, proverOptions usage, runtime logging, and curve metadata on proofs. (≤50 words)

Changes

Cohort / File(s) Summary
Dependency Updates
package.json
Replaced @cryptkeeperzk/snarkjs with snarkjs (^0.7.5); added @types/snarkjs (^0.7.9) to devDependencies.
Proof Generator & Runtime Config
src/encryption/zK/identity/ProofGenerator.ts
Added ProofGeneratorConfig and exported configure(), getConfig(), willUseSingleThread(); added restricted-environment detection, global config holder, logging hooks, compute witness via snarkjs.wtns.calculate, pass proverOptions (singleThread) to snarkjs.groth16.prove, and annotate produced proofs with curve metadata.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant PG as ProofGenerator
    participant Env as EnvDetector
    participant SNARK as snarkjs
    participant Logger as Logger

    App->>PG: configure(config)
    PG-->>App: ack

    App->>PG: generateIdentityProof(input)
    PG->>Env: isRestrictedWorkerEnvironment()
    Env-->>PG: envDecision
    PG->>PG: willUseSingleThread()

    alt singleThread
        PG->>Logger: info("using single-thread")
        PG->>SNARK: wtns.calculate(...)
        SNARK-->>PG: witness
        PG->>SNARK: groth16.prove(witness, proverOptions: {singleThread: true})
    else multiThread
        PG->>Logger: info("using parallel mode")
        PG->>SNARK: wtns.calculate(...)
        SNARK-->>PG: witness
        PG->>SNARK: groth16.prove(witness, proverOptions: {singleThread: false})
    end

    SNARK-->>PG: {proof, publicSignals}
    PG->>PG: annotate proof with curve
    PG-->>App: ProofGenerationResult

    App->>PG: verifyProof(proof, publicSignals)
    PG->>SNARK: groth16.verify(..., annotatedProof)
    SNARK-->>PG: boolean
    PG-->>App: verificationResult
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested labels

Review effort 2/5

Poem

🐇 I swapped the fork for upstream cheer,
I check the world and choose a gear,
I build the witness, thread by thread,
I tag the curve and hop ahead,
Small paws, big proofs — behold my cheer!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately captures the main objective: adding service worker compatibility for snarkjs proof generation. This directly reflects the core change of implementing hybrid environment detection and single-threaded mode support for restricted contexts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/zk-service-worker-compatibility

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Jan 26, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Pass configured logger to snarkjs
Suggestion Impact:The call to snarkjs.groth16.fullProve was updated to pass globalConfig.logger as the logger argument (replacing undefined), wiring up the configured logging as suggested.

code diff:

@@ -226,7 +247,7 @@
         circuitInputs,
         wasmPath,
         zkeyPath,
-        undefined, // logger
+        globalConfig.logger,
         undefined, // wtnsCalcOptions
         useSingleThread ? { singleThread: true } : undefined, // proverOptions - auto-detect environment
     )

Pass the configured globalConfig.logger to the snarkjs.groth16.fullProve
function to enable logging during proof generation, replacing the hardcoded
undefined value.

src/encryption/zK/identity/ProofGenerator.ts [224-232]

 // REVIEW: Phase 10.1 - Production-ready proof generation using snarkjs
 const { proof, publicSignals } = await snarkjs.groth16.fullProve(
     circuitInputs,
     wasmPath,
     zkeyPath,
-    undefined, // logger
+    globalConfig.logger, // logger
     undefined, // wtnsCalcOptions
     useSingleThread ? { singleThread: true } : undefined, // proverOptions - auto-detect environment
 )

[Suggestion processed]

Suggestion importance[1-10]: 7

__

Why: This suggestion fixes a bug where the newly introduced logging feature was not correctly wired up, as undefined was passed to snarkjs.groth16.fullProve instead of the configured globalConfig.logger.

Medium
General
Improve worker detection with robust checks
Suggestion Impact:The commit replaces the try/catch-based _listeners stub detection with a direct check that Worker.prototype exists and includes postMessage and terminate functions, matching the suggested more robust detection approach.

code diff:

     // Check if Worker constructor exists but is a stub/polyfill
     if (typeof Worker !== 'undefined') {
-        try {
-            // Some polyfills define Worker but it doesn't work properly
-            // Check for common stub patterns (e.g., _listeners property)
-            const workerProto = Worker.prototype
-            if (workerProto && typeof (workerProto as any)._listeners !== 'undefined') {
-                return true // It's our stub Worker
-            }
-        } catch {
-            // If checking fails, assume restricted
-            return true
+        // A valid Worker implementation should have standard methods on its prototype.
+        // If it's a simple stub/polyfill, these might be missing.
+        const workerProto = Worker.prototype
+        if (!workerProto || typeof workerProto.postMessage !== 'function' || typeof workerProto.terminate !== 'function') {
+            return true // Likely a stub Worker
         }
     }

Refactor the Worker polyfill detection to check for standard API methods like
postMessage and terminate on the prototype, instead of relying on a brittle
private _listeners property and a broad try-catch block.

src/encryption/zK/identity/ProofGenerator.ts [53-66]

 // Check if Worker constructor exists but is a stub/polyfill
 if (typeof Worker !== 'undefined') {
-    try {
-        // Some polyfills define Worker but it doesn't work properly
-        // Check for common stub patterns (e.g., _listeners property)
-        const workerProto = Worker.prototype
-        if (workerProto && typeof (workerProto as any)._listeners !== 'undefined') {
-            return true // It's our stub Worker
-        }
-    } catch {
-        // If checking fails, assume restricted
-        return true
+    // A valid Worker implementation should have standard methods on its prototype.
+    // If it's a simple stub/polyfill, these might be missing.
+    const workerProto = Worker.prototype
+    if (!workerProto || typeof workerProto.postMessage !== 'function' || typeof workerProto.terminate !== 'function') {
+        return true // Likely a stub Worker
     }
 }

[Suggestion processed]

Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that checking for a private _listeners property is brittle and proposes a more robust check against the standard Worker prototype API, improving the reliability of the new environment detection feature.

Low
  • Update

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@package.json`:
- Line 99: The TypeScript types for snarkjs are out of sync with the runtime:
you use snarkjs.fullProve with proverOptions (e.g., singleThread) but
`@types/snarkjs` lacks that overload; either update the `@types/snarkjs` package to
a release that includes the proverOptions type, or change calls to avoid
fullProve with options by switching to groth16.prove (call groth16.prove(..., {
singleThread: true }) where you currently call snarkjs.fullProve(..., {
singleThread: true })) and adjust imports/usages accordingly (references:
snarkjs, fullProve, groth16.prove, proverOptions, `@types/snarkjs`).

In `@src/encryption/zK/identity/ProofGenerator.ts`:
- Around line 100-141: Add a `// REVIEW:` marker immediately before the new
global config API block that defines globalConfig and the
configure/getConfig/willUseSingleThread functions; specifically insert the
comment above the declaration of globalConfig (symbol: globalConfig) and before
the JSDoc for configure (symbol: configure or ProofGenerator.configure) so the
new API surface (ProofGenerator.configure, getConfig, willUseSingleThread and
the ProofGeneratorConfig usage) is clearly marked for review per guidelines.
🧹 Nitpick comments (2)
src/encryption/zK/identity/ProofGenerator.ts (2)

19-75: Reduce any usage in environment detection.
This block relies on repeated as any, which conflicts with the “full TypeScript type coverage” guideline. Consider narrowing via a typed record and local guards.

♻️ Suggested typing cleanup
-    const g = globalThis as any
+    const g = globalThis as Record<string, unknown>
+    const ServiceWorkerGlobalScopeCtor =
+        g.ServiceWorkerGlobalScope as undefined | (new (...args: unknown[]) => unknown)
-    if (typeof g.ServiceWorkerGlobalScope !== 'undefined' &&
-        typeof self !== 'undefined' &&
-        self instanceof g.ServiceWorkerGlobalScope) {
+    if (ServiceWorkerGlobalScopeCtor &&
+        typeof self !== 'undefined' &&
+        self instanceof ServiceWorkerGlobalScopeCtor) {
         return true
     }

-    if (typeof globalThis !== 'undefined' &&
-        typeof (globalThis as any).caches !== 'undefined' &&
-        typeof (globalThis as any).window === 'undefined' &&
-        typeof (globalThis as any).document === 'undefined') {
+    if (typeof globalThis !== 'undefined' &&
+        typeof g.caches !== 'undefined' &&
+        typeof g.window === 'undefined' &&
+        typeof g.document === 'undefined') {
         // Could be Cloudflare Worker or Service Worker - check for CF-specific globals
-        if (typeof (globalThis as any).HTMLRewriter !== 'undefined') {
+        if (typeof g.HTMLRewriter !== 'undefined') {
             return true
         }
     }

-    if (typeof (globalThis as any).Bun !== 'undefined') {
+    if (typeof g.Bun !== 'undefined') {
         return true
     }

As per coding guidelines, please keep full TypeScript type coverage.


286-292: Derive curve from the loaded verification key to prevent mismatches.
The verification key JSON loaded from CDN includes a curve field according to snarkjs standard export format. Hardcoding 'bn128' risks a mismatch if the circuit is regenerated with a different curve (e.g., bls12-381). Extract the curve from vkey with a fallback to ensure consistency:

♻️ Safer curve handling
-        const snarkjsProof = {
+        const snarkjsProof = {
             pi_a: proof.pi_a,
             pi_b: proof.pi_b,
             pi_c: proof.pi_c,
             protocol: proof.protocol,
-            curve: 'bn128', // Standard curve for Groth16 proofs
+            curve: (vkey as { curve?: string }).curve ?? 'bn128',
         }

"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@cryptkeeperzk/snarkjs": "^0.7.2",
"snarkjs": "^0.7.5",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Search for singleThread usage in the codebase
rg -i "singlethread" --type json --type js --type ts -B 2 -A 2

Repository: kynesyslabs/sdks

Length of output: 2637


🏁 Script executed:

# Also check the package.json for the exact versions
fd package.json -x cat -n {} | head -200

Repository: kynesyslabs/sdks

Length of output: 10900


🌐 Web query:

snarkjs 0.7.5 release notes singleThread prover option fullProve

💡 Result:

In snarkjs v0.7.5 (released Oct 18, 2024), the release notes include “Support for wtns calc and prover options” (PR #517). This change adds the ability for fullProve/fullprove to pass options through to:

  • the witness calculator (e.g. memorySize), and
  • the prover, including a single-thread mode option (spelled singleThread in the API; the PR text contains a minor typo). [1][2]

Where it shows up: the v0.7.5 release notes list the PR, and the PR description explicitly says it “Pass[es] … singleTread option to prover” and adds an options parameter to groth16FullProve (and similarly for PLONK/FFLONK full prove). [1][2]

Sources:
[1] snarkjs v0.7.5 release notes (GitHub Releases) (github.com)
[2] PR #517 “Support for wtns calc and prover options” (github.com)

Citations:


🌐 Web query:

@types/snarkjs 0.7.9 type definitions groth16 fullProve singleThread

💡 Result:

In @types/snarkjs 0.7.9, groth16.fullProve is typed as:

  • fullProve(input, wasmFile, zkeyFileName, logger?) (no “options” parameter), so singleThread can’t be passed without a TS error. [1]

In snarkjs itself, the documented way to force single-threaded proving is not fullProve, but:

  • snarkjs.groth16.prove(zkeyFinal, wtns, undefined, { singleThread: true }) [2]

So in TS, the practical options are:

  1. Use wtns.calculate(...) + groth16.prove(..., { singleThread: true }) (instead of fullProve). [2]
  2. Override the typing (cast to any or add module augmentation) to allow a 4th/5th parameter—because the published DT types don’t include it. [1][2]

Sources: [1] [2]


Fix @types/snarkjs version mismatch with runtime API.

[email protected] supports singleThread in fullProve proverOptions (added Oct 2024, PR #517), but @types/[email protected] type definitions do not include the proverOptions parameter. This causes TypeScript compilation errors despite runtime compatibility. Either upgrade @types/snarkjs to a version that includes proverOptions, or refactor to use separate groth16.prove(..., { singleThread: true }) calls instead of fullProve.

🤖 Prompt for AI Agents
In `@package.json` at line 99, The TypeScript types for snarkjs are out of sync
with the runtime: you use snarkjs.fullProve with proverOptions (e.g.,
singleThread) but `@types/snarkjs` lacks that overload; either update the
`@types/snarkjs` package to a release that includes the proverOptions type, or
change calls to avoid fullProve with options by switching to groth16.prove (call
groth16.prove(..., { singleThread: true }) where you currently call
snarkjs.fullProve(..., { singleThread: true })) and adjust imports/usages
accordingly (references: snarkjs, fullProve, groth16.prove, proverOptions,
`@types/snarkjs`).

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/encryption/zK/identity/ProofGenerator.ts`:
- Around line 56-94: The isRestrictedWorkerEnvironment function must treat an
absent Worker constructor as a restricted environment: add an explicit early
check "if (typeof Worker === 'undefined') return true" so runtimes without
Worker choose non-parallel mode; also replace indiscriminate "globalThis as any"
usage with a narrow typed alias or guarded property checks (e.g., cast
globalThis to a small interface or use 'in' / typeof checks for caches,
HTMLRewriter, Bun) to preserve TypeScript type coverage while locating the
checks around globalThis, Worker.prototype and Bun/HTMLRewriter detections.
- Around line 18-43: The current augmentation and usage assume groth16.fullProve
accepts a proverOptions parameter; update ProofGenerator.ts to match snarkjs
0.7.5 by removing the extra proverOptions parameter from the fullProve type
declaration and instead add/augment types for wtnsCalculate and groth16.prove
(accepting zkey, wtns, optional logger, and ProverOptions). Refactor places that
call groth16.fullProve (referenced in this file around the proof generation
logic and the symbols fullProve and Groth16Proof) to compute the witness first
via wtnsCalculate(...) and then call groth16.prove(zkey, wtns, undefined, {
singleThread: true }) so single-threaded proving is enforced and runtime API
matches types.

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 6, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants