Skip to content

fix(stm): Fix the implementation difference for schnorr signature between cpu and circuit#2994

Merged
damrobi merged 8 commits into
mainfrom
damrobi/msnark/fix-schnorr-sign-diff-cpu-circuit
Feb 11, 2026
Merged

fix(stm): Fix the implementation difference for schnorr signature between cpu and circuit#2994
damrobi merged 8 commits into
mainfrom
damrobi/msnark/fix-schnorr-sign-diff-cpu-circuit

Conversation

@damrobi

@damrobi damrobi commented Feb 10, 2026

Copy link
Copy Markdown
Collaborator

Content

This PR includes a fix to the implementation of the unique schnorr signature that differs between cpu and circuit. This fix mainly consists in modifying the input to the sign and verify functions of the unique_schnorr_signature module to take BaseFieldElements instead of arbitrary bytes. The bytes that were previously handled within the sign function will be treated outside of the signature in a later PR.
Warning: This PR does not include the proper handling of the message bytes and merkle root before giving them to the signature function!

Content of the PR:

  • Changed hash_to_projective_point to have BaseFieldElement as inputs
  • Modified inputs of sign and verify functions to take &[BaseFieldElement] instead of &[u8]
  • Exposed BaseFieldElement to the benches
  • Added TryFrom<&[u8]> implementation to BaseFieldElement using SHA256 to compress arbitrary bytes slices

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • 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 #2993

@github-actions

github-actions Bot commented Feb 10, 2026

Copy link
Copy Markdown

Test Results

    5 files  ±0    172 suites  ±0   39m 23s ⏱️ -12s
2 513 tests ±0  2 513 ✅ ±0  0 💤 ±0  0 ❌ ±0 
7 783 runs  ±0  7 783 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit a7b0897. ± Comparison against base commit c52f287.

♻️ This comment has been updated with latest results.

@hjeljeli32 hjeljeli32 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@damrobi
Thanks a lot for the quick turnaround on this PR 🙏
This looks really good to me and is fully aligned with the decisions we discussed yesterday.
I left a couple of small comments regarding doc comments that are now slightly outdated, but nothing blocking from my side.
Great work 👍

Comment thread mithril-stm/src/signature_scheme/unique_schnorr_signature/jubjub/curve_points.rs Outdated
Comment thread mithril-stm/src/signature_scheme/unique_schnorr_signature/signing_key.rs Outdated
Comment thread mithril-stm/src/signature_scheme/unique_schnorr_signature/signature.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the CPU implementation of the unique Schnorr signature with the circuit version by switching the hashing-to-curve and signature APIs to operate on Jubjub base field elements rather than raw bytes, removing the CPU-side SHA-256 step.

Changes:

  • Update hash_to_projective_point, sign, and verify to take &[BaseFieldElement] instead of &[u8].
  • Re-export BaseFieldElement for use in benchmarks and update benches/tests to pass field elements.
  • Remove the sha2 dependency and refresh golden vectors impacted by the hashing change.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
mithril-stm/src/signature_scheme/unique_schnorr_signature/signing_key.rs sign now takes base field elements; call path updated accordingly.
mithril-stm/src/signature_scheme/unique_schnorr_signature/signature.rs verify now takes base field elements; tests + golden vectors updated.
mithril-stm/src/signature_scheme/unique_schnorr_signature/mod.rs Re-export BaseFieldElement; update proptests to use new API.
mithril-stm/src/signature_scheme/unique_schnorr_signature/jubjub/field_elements.rs Add test/bench-only conversion from byte slices to BaseFieldElement.
mithril-stm/src/signature_scheme/unique_schnorr_signature/jubjub/curve_points.rs hash_to_projective_point now hashes base field elements and drops SHA-256.
mithril-stm/src/lib.rs Expose BaseFieldElement under benchmark-internals for benches.
mithril-stm/benches/schnorr_sig.rs Update bench to pass &[BaseFieldElement] to sign/verify.
mithril-stm/Cargo.toml Remove sha2 dependency now that SHA-256 is no longer used here.
Cargo.lock Lockfile updated to reflect dependency removal.

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

Comment thread mithril-stm/src/signature_scheme/unique_schnorr_signature/jubjub/curve_points.rs Outdated
Comment thread mithril-stm/src/signature_scheme/unique_schnorr_signature/jubjub/curve_points.rs Outdated
Comment thread mithril-stm/src/signature_scheme/unique_schnorr_signature/mod.rs Outdated
Comment thread mithril-stm/src/signature_scheme/unique_schnorr_signature/jubjub/curve_points.rs Outdated
Comment thread mithril-stm/benches/schnorr_sig.rs Fixed
Comment thread mithril-stm/benches/schnorr_sig.rs Fixed
@damrobi
damrobi force-pushed the damrobi/msnark/fix-schnorr-sign-diff-cpu-circuit branch from 50ebfe3 to eb394ae Compare February 11, 2026 12:40
@damrobi
damrobi requested a review from jpraynaud February 11, 2026 12:56
@damrobi
damrobi marked this pull request as ready for review February 11, 2026 12:56

@jpraynaud jpraynaud left a comment

Copy link
Copy Markdown
Member

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/fix-schnorr-sign-diff-cpu-circuit branch from eb394ae to a7b0897 Compare February 11, 2026 13:59
@damrobi
damrobi merged commit 9ed09c3 into main Feb 11, 2026
56 checks passed
@damrobi
damrobi deleted the damrobi/msnark/fix-schnorr-sign-diff-cpu-circuit branch February 11, 2026 14: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.

5 participants