build: updated to latest gnark crypto api change (code gen)#1668
build: updated to latest gnark crypto api change (code gen)#1668
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the tinyfield code generation to use the latest gnark-crypto API. The changes migrate from the deprecated GenerateFF API to the new simpler generator.Generate function, and replace the structured FieldDependency configuration with direct field assignments in the gkrConfig struct.
- Migrated field generator API from
GenerateFFwithconfig.NewFieldConfigto the newgenerator.Generatefunction - Refactored
gkrConfigstruct to use direct field assignments instead of embeddedFieldDependencystruct - Added test coverage for the new
SetBytesCanonicalmethod generated by the updated gnark-crypto
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/smallfields/tinyfield/element_test.go | Added property-based test for SetBytesCanonical method to verify round-trip consistency with Bytes() |
| internal/smallfields/tinyfield/doc.go | Updated documentation to remove specific mention of AVX512/NEON instructions, making it more generic |
| internal/generator/backend/main.go | Migrated to new gnark-crypto generator API, replacing GenerateFF with Generate and flattening gkrConfig struct fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // conf, err := config.NewFieldConfig(d.Curve, "Element", d.AutoGenerateField, false) | ||
| // if err != nil { | ||
| // panic(err) | ||
| // } | ||
| // if err := generator.GenerateFF(conf, d.RootPath, generator.WithASM(nil)); err != nil { | ||
| // panic(err) | ||
| // } |
There was a problem hiding this comment.
The commented-out code should be removed rather than left in place. This old API code has been replaced by the new generator.Generate call and is no longer needed. Keeping dead code in the codebase reduces maintainability and can cause confusion for future developers.
| // conf, err := config.NewFieldConfig(d.Curve, "Element", d.AutoGenerateField, false) | |
| // if err != nil { | |
| // panic(err) | |
| // } | |
| // if err := generator.GenerateFF(conf, d.RootPath, generator.WithASM(nil)); err != nil { | |
| // panic(err) | |
| // } |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
| // } | ||
| // if err := generator.GenerateFF(conf, d.RootPath, generator.WithASM(nil)); err != nil { | ||
| // panic(err) | ||
| // } |
There was a problem hiding this comment.
Commented-out old implementation code left in codebase
The old implementation using config.NewFieldConfig and generator.GenerateFF with generator.WithASM(nil) has been left as commented-out code after the migration to the new generator.Generate API. This dead code adds noise to the codebase and could confuse future maintainers. It appears to have been kept for reference during development but wasn't cleaned up before the PR.
Description
Update
tinyfieldcode generation using latest gnark-crypto. Sister PR: Consensys/gnark-crypto#781Note
internal/generator/backendto new gnark-crypto field generator (generator.Generate), removing legacyconfig.FieldDependencyusageinternal/smallfields/tinyfieldwith updated codegen; addsSetBytesCanonicaltest and tweaks vector docs1.24.9and update deps (gnark-crypto, bavard, compress, pprof, x/crypto, x/exp, x/sync, x/sys); refresh go.sum2025-2026Written by Cursor Bugbot for commit e48f518. This will update automatically on new commits. Configure here.