Skip to content

refactor(generators): consolidate Groth16 generators#491

Open
feltroidprime wants to merge 9 commits intomainfrom
refactor/consolidate-groth16-generators
Open

refactor(generators): consolidate Groth16 generators#491
feltroidprime wants to merge 9 commits intomainfrom
refactor/consolidate-groth16-generators

Conversation

@feltroidprime
Copy link
Copy Markdown
Collaborator

Summary

  • Extract shared template fragments (MSM syscall, pairing check, imports) into reusable functions
  • Add Groth16VerifierGenerator base class with common generation logic
  • Implement StandardGroth16Generator, Risc0VerifierGenerator, SP1VerifierGenerator subclasses
  • Maintain backward compatibility via existing function signatures
  • Generated Cairo output is functionally identical to before refactor

Benefits

Change Type Before After
Update pairing check Edit 3 files Edit get_pairing_check_code() once
Update MSM syscall Edit 3 files Edit get_msm_syscall_code() once
Add new proof system Copy 200+ lines Subclass Groth16VerifierGenerator

Test plan

  • make rewrite generates functionally identical output
  • All 143 Cairo tests pass
  • All 108 Python tests pass

🤖 Generated with Claude Code

feltroidprime and others added 9 commits January 24, 2026 20:19
refactor(generators): use Risc0VerifierGenerator in gen_risc0_groth16_verifier
refactor(generators): use SP1VerifierGenerator in gen_sp1_groth16_verifier
- Extract shared template fragments (MSM syscall, pairing check, imports)
- Add Groth16VerifierGenerator base class
- Implement StandardGroth16Generator, Risc0VerifierGenerator, SP1VerifierGenerator
- Maintain backward compatibility via existing function signatures
- Generated Cairo output is functionally identical to before refactor

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add helper functions for additional common patterns:
- get_storage_struct(): Empty storage struct
- get_verification_comment(): DO NOT EDIT comment block
- get_msm_hint_loop(): Loop to append hint array
- get_curve_id_append(): Curve identifier append with comment

These can be used to further reduce duplication in generator subclasses.
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.

1 participant