Skip to content

chore: Extract algebra into its own crate#434

Open
dvdplm wants to merge 26 commits intomainfrom
dvdplm/chore/extract-crate-threshold-algebra
Open

chore: Extract algebra into its own crate#434
dvdplm wants to merge 26 commits intomainfrom
dvdplm/chore/extract-crate-threshold-algebra

Conversation

@dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Feb 23, 2026

Most of the diff is mechanical import rewiring. Focus review on the new crates and the open questions below.

What this does

Extracts the pure-algebra layer out of threshold-fhe into its own crate – threshold-algebra, abbreviated as algebra – along with three smaller utility crates.
The goal is to make threshold-fhe thinner and thus allow for more compilation parallelism. Smaller code units provides a clear(-er) dependency boundary (no IO, no async, no tokio). This is the first step of several.

New crates

Crate Path What it contains
threshold-algebra core/threshold-algebra/ base_ring, bivariate, galois_fields, galois_rings, poly, error_correction, syndrome, structure_traits — plus role, sharing and the PRSSConversions trait (see open questions)
threshold-hashing core/threshold-hashing/ hash_element, unsafe_hash_list, DomainSep, DIGEST_BYTES etc. — extracted from threshold-fhe
error-utils core/error-utils/ anyhow_error_and_log / anyhow_error_and_warn_log helpers (lived in threshold-fhe's internal error module)
thread-handles core/thread-handles/ Threading utilities extracted from threshold-fhe and some cleanup&tests

Other notable changes

  • genggen rename in choreography::grpc and networking — avoids clashing with the Rust gen reserved keyword. While we are still on the 2021 edition, tools like rust-analyzer flags gen as a syntax error. Suggestions for a better rename welcome!
  • Role is no longer re-exported from execution — consumers now import from algebra::role directly.
  • sharing is no longer re-exported from execution — consumers import from algebra::sharing.
  • Test and dev Cargo profiles: disabled full debug info (632a6e7f) after seeing the compiler spend a lot of time and RAM generating full debug info. The downside is that inspecting lvars during debugging is not possible with the partial debug info; backtraces are however intact.

Open questions for reviewers

  1. Should Role (and RoleTrait, RoleKind, TwoSetsRole, DualRole) live in its own crate?
    I moved it from threshold-fhe into threshold-algebra, but several types in execution::runtime (sessions, party) still depend on it heavily. Some role-related pieces are still left in execution, which is a bit of a code smell. A standalone threshold-role crate might make the dependency graph cleaner. Thoughts?

  2. Same question for sharing::{shamir, share}.
    ShamirSharings, Share, InputOp, RevealOp are now in threshold-algebra, but they're really protocol-level types used by execution. Should they stay in algebra or be extracted to a mini-crate? Currently there is code left in execution/sharing, which is not great.

  3. PRSSConversions trait is now defined in threshold-algebra/src/lib.rs.
    It exists so that galois ring types can implement it, but it's a protocol thing more than an algebra concern. Where should it live? It's re-exported in execution::small_execution::prf. This is a tricky one, ideas welcome.

Outstanding TODOs

Location Note
threshold-algebra/Cargo.toml:14 Get rid of lazy_static dep (kms-internal#2907)
threshold-algebra/Cargo.toml:30 Are all these feature flags actually needed now that the crate does no IO? non-wasm might be unnecessary.
threshold-algebra/src/role.rs:107 Used derive_more before — still needed?
threshold-algebra/src/structure_traits.rs:140,159 embed_role_to_exceptional_sequence and Derive trait could take 1-based indexes instead of Role — simplify? Can we get rid of Role and the other types fromalgebra?
threshold-algebra/src/sharing/shamir.rs:629 A test that should move back to threshold-fhe.
threshold-algebra/src/lib.rs:12-16 Notes on why shamir/PRSSConversions ended up here.
threshold-hashing/src/lib.rs:7 DomainSep/DSEP_LEN/DIGEST_BYTES constants — own "types and consts" crate?

@cla-bot cla-bot bot added the cla-signed The CLA has been signed. label Feb 23, 2026
@github-actions
Copy link

github-actions bot commented Feb 24, 2026

Consolidated Tests Results 2026-02-25 - 17:24:58

Test Results

passed 14 passed

Details

tests 14 tests
clock not captured
tool junit-to-ctrf
build build-and-test arrow-right test-reporter link #591
pull-request chore: Extract algebra into its own crate link #434

test-reporter: Run #591

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
14 14 0 0 0 0 0 not captured

🎉 All tests passed!

Tests

View All Tests
Test Name Status Flaky Duration
full_gen_tests_k8s_default_threshld_sequential_crs 32.6s
test_k8s_threshld_insecure 3m 16s
k8s_test_crs_uniqueness 32.5s
k8s_test_keygen_and_crs 3m 19s
k8s_test_keygen_uniqueness 8m 58s
full_gen_tests_k8s_default_threshld_sequential_crs 32.4s
test_k8s_threshld_insecure 3m 18s
k8s_test_crs_uniqueness 32.5s
k8s_test_keygen_and_crs 3m 18s
k8s_test_keygen_uniqueness 9m 7s
full_gen_tests_k8s_default_centralzd_sequential_crs 1.8s
test_k8s_centralzd_insecure 1m 3s
full_gen_tests_default_k8s_centralized_sequential_crs 1.8s
k8s_test_centralized_insecure 1m 3s

🍂 No flaky tests in this run.

Github Test Reporter by CTRF 💚

🔄 This comment has been updated

@dvdplm dvdplm changed the title Extract algebra into its own crate chore: Extract algebra into its own crate Feb 24, 2026
@dvdplm dvdplm marked this pull request as ready for review February 24, 2026 21:24
@dvdplm dvdplm requested a review from a team as a code owner February 24, 2026 21:24
@dvdplm dvdplm self-assigned this Feb 24, 2026
@dvdplm dvdplm added dependencies Pull requests that update a dependency file rust Pull requests that update rust code labels Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The CLA has been signed. dependencies Pull requests that update a dependency file rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant