Skip to content

Conversation

@volodymyr-basiuk
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces dynamic prove/verify functionality to support multiple circuit versions dynamically at runtime, rather than requiring separate static instances for each circuit variant.

Key Changes:

  • Adds DynamicProve and DynamicVerify methods that accept circuit-specific parameters at runtime
  • Refactors ProvingMethodGroth16AuthV3 to support multiple circuit sub-versions (e.g., authV3-8-32) through a single instance
  • Removes the separate ProvingMethodGroth16AuthV3_8_32Instance in favor of dynamic circuit selection

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
jwz.go Adds new types (ProvingParam, VerificationKeyParam, DynamicProofInputsPreparerHandlerFunc) and methods (DynamicProve, DynamicVerify, circuitIDFromProofOrHeader) to support dynamic circuit selection
authV3Groth16.go Consolidates AuthV3 circuit support by adding circuitSubVersions field and SupportedCircuits() method; removes separate AuthV3_8_32 instance; moves Groth16 constant definition from deleted authGroth16.go
authV2Groth16.go Adds circuitSubVersions field (empty) and SupportedCircuits() method to maintain consistency with authV3 structure
authGroth16.go Removes entire file (AuthV1 circuit support)
jwz_test.go Refactors test to use new DynamicProve and DynamicVerify methods with authV3-8-32 circuit

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +85
func (m *ProvingMethodGroth16AuthV3) SupportedCircuits() []string {
seen := make(map[string]struct{}, 1+len(m.circuitSubVersions))
out := make([]string, 0, 1+len(m.circuitSubVersions))

add := func(s string) {
if _, ok := seen[s]; ok {
return
}
seen[s] = struct{}{}
out = append(out, s)
}

add(m.ProvingMethodAlg.CircuitID)
for _, s := range m.circuitSubVersions {
add(s)
}
return out
}
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

The SupportedCircuits() method is duplicated identically between ProvingMethodGroth16AuthV3 and ProvingMethodGroth16AuthV2. Consider extracting this logic into a shared helper function or embedding a common type to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
}
}
}
}
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

Potential nil pointer dereference: The function checks if token != nil at line 394, but then directly accesses token.CircuitID at line 406 without verifying token is not nil in the fallback case. If token is nil, this will panic. Add a nil check before accessing token.CircuitID.

Suggested change
}
}
if token == nil {
return ""
}

Copilot uses AI. Check for mistakes.
jwz.go Outdated
}

// ProofInputsPreparerHandlerFunc is a function type for preparing proof inputs
type DynamicProofInputsPreparerHandlerFunc func(
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

The type name DynamicProofInputsPreparerHandlerFunc is inconsistent with the existing ProofInputsPreparerHandlerFunc naming convention. Consider renaming to ProofInputsPreparerDynamicHandlerFunc or simply DynamicProofInputsPreparer to maintain consistency with the existing naming pattern where the "HandlerFunc" suffix follows a simpler name.

Suggested change
type DynamicProofInputsPreparerHandlerFunc func(
type ProofInputsPreparerHandlerFunc func(

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +74
func (m *ProvingMethodGroth16AuthV2) SupportedCircuits() []string {
seen := make(map[string]struct{}, 1+len(m.circuitSubVersions))
out := make([]string, 0, 1+len(m.circuitSubVersions))

add := func(s string) {
if _, ok := seen[s]; ok {
return
}
seen[s] = struct{}{}
out = append(out, s)
}

add(m.ProvingMethodAlg.CircuitID)
for _, s := range m.circuitSubVersions {
add(s)
}
return out
}
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

The SupportedCircuits() method is duplicated identically between ProvingMethodGroth16AuthV2 and ProvingMethodGroth16AuthV3. Consider extracting this logic into a shared helper function or embedding a common type to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
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.

2 participants