Skip to content

Conversation

@damrobi
Copy link
Collaborator

@damrobi damrobi commented Jan 8, 2026

Content

Change the backend used for the Jubjub curve and Poseidon hash function from the Dusk implementation to the newly released Midnight crates.

Pre-submit checklist

  • Branch
    • Tests are provided
    • Crates versions are updated
    • CHANGELOG file is updated
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • No new TODOs introduced

Comments

Issue(s)

Relates to #2888

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Test Results

    4 files  ±0    169 suites  ±0   22m 22s ⏱️ +17s
2 317 tests ±0  2 317 ✅ ±0  0 💤 ±0  0 ❌ ±0 
7 296 runs  ±0  7 296 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 34e95e8. ± Comparison against base commit 1e052e6.

♻️ This comment has been updated with latest results.

@damrobi damrobi temporarily deployed to testing-preview January 9, 2026 14:59 — with GitHub Actions Inactive
@damrobi damrobi temporarily deployed to testing-preview January 9, 2026 15:45 — with GitHub Actions Inactive
@damrobi damrobi marked this pull request as ready for review January 9, 2026 16:16
@jpraynaud jpraynaud requested a review from Copilot January 9, 2026 17:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request migrates the cryptographic backend for Jubjub curve operations and Poseidon hash functions from Dusk Network's implementation (dusk-jubjub, dusk-poseidon) to Input Output's Midnight implementation (midnight-circuits, midnight-curves). This represents a significant change in the underlying cryptographic dependencies for the Schnorr signature scheme.

Key Changes

  • Replaced Dusk cryptographic libraries with Midnight equivalents (versions 6.0.0 and 0.2.0)
  • Updated Poseidon hash to return BaseFieldElement instead of ScalarFieldElement with type conversion added for signature operations
  • Implemented SHA256 pre-hashing for hash-to-curve operations using the Midnight HashToCurveGadget
  • Updated all golden test values to reflect the new backend's outputs

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
mithril-stm/Cargo.toml Replaced dusk dependencies with midnight-circuits and midnight-curves; added sha2 dependency
Cargo.lock Updated dependency tree with new midnight crates and their transitive dependencies
mithril-stm/src/signature_scheme/schnorr_signature/jubjub/poseidon_digest.rs Migrated from Dusk's Hash::digest_truncated to Midnight's PoseidonChip::hash; changed return type to BaseFieldElement
mithril-stm/src/signature_scheme/schnorr_signature/jubjub/field_elements.rs Added BaseFieldElement serialization methods, from_raw and from_base_field conversion methods for ScalarFieldElement
mithril-stm/src/signature_scheme/schnorr_signature/jubjub/curve_points.rs Replaced Dusk's hash_to_point with Midnight's HashToCurveGadget using SHA256 pre-hashing; updated type aliases
mithril-stm/src/signature_scheme/schnorr_signature/signature.rs Changed challenge field type from ScalarFieldElement to BaseFieldElement; added type conversion in verification
mithril-stm/src/signature_scheme/schnorr_signature/signing_key.rs Updated to use new Poseidon digest function and added BaseFieldElement to ScalarFieldElement conversion
mithril-stm/src/signature_scheme/schnorr_signature/verification_key.rs Reordered imports to follow Rust conventions
mithril-stm/src/signature_scheme/schnorr_signature/error.rs Added BaseFieldElementSerialization error variant
mithril-stm/src/signature_scheme/schnorr_signature/jubjub/mod.rs Added serde implementation for BaseFieldElement
mithril-stm/benches/schnorr_sig.rs Updated benchmark names and implementation to use Midnight's PoseidonChip

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@damrobi damrobi force-pushed the damrobi/msnark/change-jubjub-midnight-zk branch from 5b5546d to c16ada3 Compare January 14, 2026 15:59
Copy link
Collaborator

@hjeljeli32 hjeljeli32 left a comment

Choose a reason for hiding this comment

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

LGTM ✅
I left 3 small non-blocking comments.

@damrobi damrobi temporarily deployed to testing-preview January 15, 2026 10:00 — with GitHub Actions Inactive
Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

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

LGTM

@damrobi damrobi force-pushed the damrobi/msnark/change-jubjub-midnight-zk branch from 38cea02 to 5076a93 Compare January 15, 2026 15:53
Copy link
Collaborator

@curiecrypt curiecrypt left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@damrobi damrobi force-pushed the damrobi/msnark/change-jubjub-midnight-zk branch from 2b1155f to 34e95e8 Compare January 19, 2026 13:45
@damrobi damrobi temporarily deployed to testing-preview January 19, 2026 13:56 — with GitHub Actions Inactive
@damrobi damrobi merged commit f45e5fb into main Jan 19, 2026
76 of 82 checks passed
@damrobi damrobi deleted the damrobi/msnark/change-jubjub-midnight-zk branch January 19, 2026 14:29
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.

5 participants