Add genus-2 split model (not_char2, arbitrary, char2; both reduced bases) - #1
Merged
Conversation
Ports the not-characteristic-2 split (two points at infinity) genus 2
divisor arithmetic from the Magma negReduced + posReduced formulas:
- precompute(): curve constants, Vpl/Vn, degree-0 adjust divisor
- negative basis: add_neg, double_neg
- positive basis: add_pos, double_pos
Divisors use the 4-coordinate balanced Mumford representation with an
integer balance weight n (DivisorCoords{u2,u1,u0,v1,v0,n}).
Verification mirrors the original Magma testers, checking against the
generic Cantor reference in src/generic/split.rs (no Magma needed):
- random divisor pairs over F7/F31/F127/F8191 (cf. *_random.mag)
- whitebox vectors auto-extracted from the GF(5)/GF(7) tester blocks
- test-only branch instrumentation proving all 154 formula branches
(ADD/DBL neg + PADD/PDBL pos) are exercised
cargo test --release: 203 passing (177 prior + 26 split).
- generic/split.rs: rewrite Add/Double/Adjust_SPLIT_{NEG,POS} to faithfully
match Magma with h threaded throughout (previously h=0-only). Factors the
shared compose/normalize/reduce. nch2 (h=0) regresses cleanly.
- g2/split/arbitrary.rs: arbitrary-characteristic split model (any field incl.
char 2 and 3), both reduced bases, ADD + DBL, ported from arb_splitG2_*.mag.
precompute takes a caller-supplied root y3 of x²+h3x−f6 (the ∞ points).
- arb_tests.rs: cross-checks vs the h-aware oracle over odd fields with h≠0;
all 18+59 branches per basis exercised.
cargo test --release: 218 passing.
Char-2 split genus 2 divisor arithmetic over GF(2^k), in the normalized form h = x³ + h1·x + h0, f = f6·x⁶ + f2·x² + f1·x + f0. Both reduced bases, ADD + DBL, ported from ch2_splitG2_*.mag with XOR-based char-2 arithmetic (no /2). precompute takes a caller-supplied root y3 of x²+x+f6 (the two ∞ points). Tested over GF(2^4/2^6/2^8) against the h-aware generic Cantor oracle: - A0 harness validation (round-trip incl. n, oracle well-formedness) - explicit add/double cross-checks (neg + pos) - branch coverage incl. an exhaustive deg-1 doubling sweep; the only branches not reached by testing are 13 double-degenerate ADD cases that return a trivial neutral constant (allowlisted; char2 whitebox vectors can't be ported because Magma's GF(2^k) uses a different irreducible than BinaryExtField). Fixed 4 transliteration bugs in the u=up special cases (CDBL09, CPDBL09, CADD13, CADD38) that returned degree 1 instead of the degree-2 u². cargo test --release: 226 passing.
- benches: representative degree-2 add/double benchmarks for the split model (nch2, arbitrary, char2), building valid divisors via the generic oracle then timing the explicit formulas. - README: document the split model + a split performance table. - scripts/test.sh: run the g2::split suites. - split mod docs: list all three variants.
Rebased onto current main (which added cargo fmt + clippy cleanup). Apply rustfmt, satisfy `clippy --all-targets -- -D warnings` (assign-op patterns, drop a dead s_deg store, module-level allow(too_many_arguments) for the coordinate-formula modules), and adopt main's generic/mod.rs (re-applying the h-threading edits). All four CI gates pass: test, fmt, clippy, doc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements explicit divisor arithmetic for the genus-2 split model (curves with two points at infinity,
y² + h·y = f,deg f = 6), ported from the Magma reference in salindne/divisorArithmetic. This fills insrc/g2/split/, which was previously a// TODOstub.Divisors use the balanced 4-coordinate Mumford representation with an integer balance weight
n, in both the positive (Vpl) and negative (Vn = −Vpl − h) reduced bases.What's added
g2::split::not_char2— odd characteristic,h = 0g2::split::arbitrary— any characteristic (incl. 2 and 3), generalhg2::split::char2— characteristic 2 overGF(2^k), XOR-basedprecompute+add_neg/double_neg+add_pos/double_pos.generic::splitgeneralized to threadhthroughAdd/Double/Adjust_SPLIT_{NEG,POS}(wash = 0-only), so it's a faithful Cantor reference for every characteristic.scripts/test.shruns the split suites.How it's verified
Mirroring the original Magma testers, every explicit formula is cross-checked against the generic Cantor reference (no Magma needed):
F7..F8191,GF(2^4..2^8)),DBLnn/ADDnnlabels).cargo test --release: 226 passing. Clippy (-D warnings), rustfmt, rustdoc, andcargo bench --no-runall clean.Notes
precomputeforarbitrary/char2takes a caller-supplied rooty3ofx² + h3·x − f6(the points at infinity); tests construct splitting curves with a knowny3.GF(2^k)uses a different irreducible than this crate'sBinaryExtField. Correctness of those branches follows by direct correspondence to the oracle-verified nch2/arb analogs.Out of scope: the genus-3 split model (
src/g3/remains a stub).Commits
generic::splitoracle forh≠0+ arbitrary-characteristic model