Skip to content

fix: replace hashset with BTreeSet for honest party ids#1482

Merged
hmzakhalid merged 2 commits into
mainfrom
fix/party-ordering
Mar 25, 2026
Merged

fix: replace hashset with BTreeSet for honest party ids#1482
hmzakhalid merged 2 commits into
mainfrom
fix/party-ordering

Conversation

@hmzakhalid

@hmzakhalid hmzakhalid commented Mar 25, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Documentation

    • Clarified that BFV ciphertexts are ordered by ascending party_id.
    • Updated documentation for honest parties ordering across multiple components.
    • Added specifications for commitment data ordering consistency.
  • Tests

    • Added a new consistency test verifying alignment between ciphertext and commitment data ordering.
  • Improvements

    • Enhanced determinism in honest party ID ordering.

@vercel

vercel Bot commented Mar 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Mar 25, 2026 11:54am
enclave-docs Ready Ready Preview, Comment Mar 25, 2026 11:54am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3f7a843e-a7b6-44e9-95df-6bb24505ee6c

📥 Commits

Reviewing files that changed from the base of the PR and between ce3d331 and 48581e9.

📒 Files selected for processing (4)
  • crates/events/src/enclave_event/compute_request/zk.rs
  • crates/keyshare/src/threshold_keyshare.rs
  • crates/zk-helpers/src/circuits/dkg/share_decryption/circuit.rs
  • crates/zk-helpers/src/circuits/dkg/share_decryption/computation.rs

📝 Walkthrough

Walkthrough

The PR enforces deterministic ordering of honest parties and their ciphertexts across the DKG share-decryption flow by changing the honest_parties field from HashSet<u64> to BTreeSet<u64>, clarifying documentation about party-ID ordering, and adding a test to verify commitment consistency across the ordering scheme.

Changes

Cohort / File(s) Summary
Documentation Updates
crates/events/src/enclave_event/compute_request/zk.rs, crates/zk-helpers/src/circuits/dkg/share_decryption/circuit.rs
Clarified doc comments to specify that honest_ciphertexts_raw and honest_ciphertexts contain BFV ciphertexts ordered by ascending party_id.
Deterministic Party Ordering
crates/keyshare/src/threshold_keyshare.rs
Changed honest_parties field type from Option<HashSet<u64>> to Option<BTreeSet<u64>> to enforce ascending party-ID ordering; updated construction and added debug assertion to verify honest_shares order alignment.
Test Addition
crates/zk-helpers/src/circuits/dkg/share_decryption/computation.rs
Added test_commitment_ordering_consistency unit test to verify that computed expected commitments match direct commitment derivations across all honest party rows and modulus indices.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • ctrlc03
  • cedoor

Poem

🐰 A HashSet once scattered with glee,
Now a BTreeSet, ordered you see!
Each party in line, from smallest to grand,
Commitments align across ciphertext land.
With tests that ensure the ordering's right,
Our DKG shines with deterministic light! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main structural change across multiple files: replacing HashSet with BTreeSet for honest_parties to ensure deterministic ordering by party_id.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/party-ordering

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@0xjei 0xjei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK

@hmzakhalid hmzakhalid enabled auto-merge (squash) March 25, 2026 12:15
@hmzakhalid hmzakhalid merged commit c316bd8 into main Mar 25, 2026
28 checks passed
@github-actions github-actions Bot deleted the fix/party-ordering branch April 2, 2026 03:20
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.

2 participants