feat: add LowLevel.GF16Mul for GF(2^16) field multiplication#327
feat: add LowLevel.GF16Mul for GF(2^16) field multiplication#327klauspost merged 6 commits intoklauspost:masterfrom
LowLevel.GF16Mul for GF(2^16) field multiplication#327Conversation
Expose two thin wrappers around the existing internal GF(2^16) log/exp table arithmetic in leopard.go: - GF16Init: explicitly pre-initializes the lookup tables (optional; useful for amortizing startup cost) - GF16Mul: multiplies two GF(2^16) elements, auto-initializing lazily on first use via the existing sync.Once-guarded initConstants This allows downstream consumers (e.g. celestia-app) to perform standalone GF(2^16) field arithmetic without maintaining a fork of this repository. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a new method Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
GF16Init and GF16Mul for GF(2^16) field arithmetic
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@gf16.go`:
- Around line 3-7: The doc comment on GF16Init is misleading—update it to state
that GF16Init is optional (it calls initConstants()) and not required because
GF16Mul performs lazy initialization on first use; specifically, change the
sentence "This must be called before using GF16Mul" to indicate the function
precomputes tables for performance but GF16Mul will call initConstants() itself
if needed. Reference: GF16Init, GF16Mul, and initConstants.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3194888a-155f-4bdd-bba6-a12a1e4b7555
📒 Files selected for processing (2)
gf16.gogf16_test.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
This seems like a flake unrelated to this PR: https://github.com/klauspost/reedsolomon/actions/runs/22743003914/job/65960582716?pr=327 |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
CI passed on re-trigger |
Co-authored-by: Klaus Post <klauspost@gmail.com>
Co-authored-by: Klaus Post <klauspost@gmail.com>
GF16Init and GF16Mul for GF(2^16) field arithmetic…e tests - Remove stale doc comment referencing deleted GF16Init() - Remove extra blank line in gf16.go - Update all tests to call GF16Mul as a LowLevel method - Remove TestGF16Init (function was deleted per maintainer feedback) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
LowLevel.GF16Mul for GF(2^16) field multiplication
|
Thanks for the review @klauspost! I addressed feedback. |
|
arm64 crash in #328 I will probably do a release once that is in. |
…dsolomon klauspost/reedsolomon#327 merged the GF16Mul API upstream, so we no longer need to maintain the celestiaorg fork. This updates the two packages that imported the fork (rsema1d/field and rsema1d/encoding) to use the upstream LowLevel.GF16Mul method instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I see #328 was resolved so will wait for the release and bump to it in celestia-app. Thanks for your hard work maintaining this repo! |
|
Didn't want to release on a Friday, since I wouldn't be available for fixes. Released https://github.com/klauspost/reedsolomon/releases/tag/v1.13.3 |
…dsolomon klauspost/reedsolomon#327 merged the GF16Mul API upstream, so we no longer need to maintain the celestiaorg fork. This updates the two packages that imported the fork (rsema1d/field and rsema1d/encoding) to use the upstream LowLevel.GF16Mul method instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Expose a thin public wrapper around the existing internal GF(2^16) log/exp table arithmetic in
leopard.go, as a method on the existingLowLeveltype:LowLevel.GF16Mul(a, b uint16) uint16— multiplies two elements in GF(2^16) using the existinglogLUT/expLUTtables. Initializes lazily on first use via the existingsync.Once-guardedinitConstants.No new math or tables are introduced — this is purely a public API surface over already-existing internals.
Motivation
Celestia currently maintains a fork of this repository solely to access GF(2^16) field multiplication for their data availability layer. The diff is small: master...celestiaorg:reedsolomon:master
Upstreaming this allows us to drop the fork and depend on this repo directly.
Test plan
TestGF16MulZero— anything × 0 = 0TestGF16MulOne— multiplicative identityTestGF16MulCommutativity— a×b = b×aTestGF16MulAssociativity— (a×b)×c = a×(b×c)TestGF16MulDistributivity— a×(b⊕c) = a×b ⊕ a×c (GF addition is XOR)TestGF16MulConsistentWithInternal— agrees with internalmulLog🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests