Skip to content

feat: add KB8 curve#832

Draft
yelhousni wants to merge 10 commits intomasterfrom
feat/kb8
Draft

feat: add KB8 curve#832
yelhousni wants to merge 10 commits intomasterfrom
feat/kb8

Conversation

@yelhousni
Copy link
Copy Markdown
Collaborator

@yelhousni yelhousni commented Apr 15, 2026

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Note that in most cases the PR should be against the develop branch.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran or implemented to verify your changes. Provide instructions so we can reproduce.

  • Test A
  • Test B

How has this been benchmarked?

Please describe the benchmarks that you ran to verify your changes.

  • Benchmark A, on Macbook pro M1, 32GB RAM
  • Benchmark B, on x86 Intel xxx, 16GB RAM

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Note

Medium Risk
Introduces a new curve ID and a large amount of generated finite-field code, plus changes to point (de)serialization paths; mistakes here could break compatibility or arithmetic correctness across multiple curves.

Overview
Adds support for a new KB8 curve identifier across the ecc package, including string parsing and new scalar/base field parameters.

Introduces a new ecc/kb8 package with fp wrappers over the koalabear field and a full generated fr implementation (including arch-specific assembly hooks and exponentiation chains).

Refactors marshaling in several curve packages by removing explicit G2Affine and []G2Affine encode branches (compressed and raw) and makes small generator/test updates (e.g., adds GenE4, tweaks loops/encoding checks), alongside minor generated-code cleanups (e.g., reflect.Ptr usage and wording in grumpkin marshal errors/comments).

Reviewed by Cursor Bugbot for commit ba5549b. Bugbot is set up for automated code reviews on this repo. Configure here.

@yelhousni yelhousni marked this pull request as draft April 15, 2026 04:08
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ba5549b. Configure here.

Comment thread ecc/bls12-377/marshal.go
for i := range len(t) {
buf = t[i].Bytes()
written, err = enc.w.Write(buf[:])
enc.n += int64(written)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

G2Affine encoding cases removed, breaking serialization

High Severity

The *G2Affine, []G2Affine, and *[]G2Affine cases were removed from both encode and encodeRaw across all pairing-friendly curve marshal.go files. Since G2Affine does not implement io.WriterTo, the generic interface check at the top of these functions won't handle it. Encoding any G2 point now falls through to the default case, which returns an "unsupported type" error. The decoder still has explicit *G2Affine and *[]G2Affine cases, confirming these types need explicit handling. This breaks G2 serialization in bls12-377, bls12-381, bls24-315, bls24-317, bn254, bw6-633, and bw6-761.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ba5549b. Configure here.

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