Skip to content

Conversation

@damrobi
Copy link
Collaborator

@damrobi damrobi commented Nov 3, 2025

Content

This PR includes a new module for mithril-stm containing an implementation for the Schnorr signature that will be used in the SNARK version of mithril.

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
    • Update README file (if relevant)
    • Update documentation website (if relevant)
    • Add dev blog post (if relevant)
    • Add ADR blog post or Dev ADR entry (if relevant)
    • No new TODOs introduced

Comments

Issue(s)

Relates to #2756

@damrobi damrobi added the feature 🚀 New implemented feature label Nov 3, 2025
@damrobi damrobi force-pushed the damrobi/stm-add-schnorr-sig-module branch from b254ad2 to 1e07c07 Compare November 5, 2025 08:22
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

cargo-doc found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

clippy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Test Results

    4 files  ±0    168 suites  ±0   23m 57s ⏱️ + 1m 1s
2 207 tests ±0  2 207 ✅ ±0  0 💤 ±0  0 ❌ ±0 
6 887 runs  ±0  6 887 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit cf446ba. ± Comparison against base commit 2ad7d5e.

♻️ This comment has been updated with latest results.

@damrobi damrobi changed the title Added file structure for Schnorr signature module. Implementation of Schnorr signature module for mithril-stm. Nov 6, 2025
@damrobi damrobi temporarily deployed to testing-preview November 7, 2025 16:45 — with GitHub Actions Inactive
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.

First batch of reviews. It looks good at first glance.

digest = { workspace = true }
ff = "0.13.1"
group = "0.13.0"
midnight-circuits = { git = "https://github.com/midnightntwrk/midnight-zk", rev = "c88a50c2169f060120a52ad0980de90f08bc9535" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that @kitounliu also used this revision. Don't we get the latest version of the midnight repo?
If that is not the case, can you write a comment for these revisions, giving the date of the rev and the reason for using this specific rev.

@@ -0,0 +1,168 @@
#![allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#![allow(dead_code)]
/// TODO: Remove
#![allow(dead_code)]

mod signing_key;
mod verification_key;

/// A DST to distinguish between use of Poseidon hash
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// A DST to distinguish between use of Poseidon hash
use signature::*;
use signing_key::*;
use verification_key::*;
/// A DST to distinguish between use of Poseidon hash

By doing so, we can simplify the imports in the files. In the future, we might make these uses public if needed.

Comment on lines +16 to +18
use crate::schnorr_signature::{
signature::SchnorrSignature, verification_key::SchnorrVerificationKey,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
use crate::schnorr_signature::{
signature::SchnorrSignature, verification_key::SchnorrVerificationKey,
};
use crate::schnorr_signature::{SchnorrSignature, SchnorrVerificationKey};

SchnorrSigningKey(JubjubScalar::random(rng))
}

// TODO: Check if we want the sign function to handle the randomness by itself
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's explain the signature scheme in the function doc.

// Compute the random part of the signature with
// r1 = H(msg) * r
// r2 = g * r
let r = JubjubScalar::random(rng);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should think of more descriptive variable names within the code. WDYT @jpraynaud ?

/// Convert a Shnorr secret key into a verification key
/// This is done by computing `vk = g * sk` where g is the generator
/// of the subgroup and sk is the schnorr secret key
fn from(sk: &SchnorrSigningKey) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly, we should use more descriptive names

Comment on lines +9 to +15
use crate::{
Index,
schnorr_signature::{
DST_LOTTERY, DST_SIGNATURE, JubjubHashToCurve, get_coordinates, hash_msg_to_jubjubbase,
jubjub_base_to_scalar, verification_key::SchnorrVerificationKey,
},
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
use crate::{
Index,
schnorr_signature::{
DST_LOTTERY, DST_SIGNATURE, JubjubHashToCurve, get_coordinates, hash_msg_to_jubjubbase,
jubjub_base_to_scalar, verification_key::SchnorrVerificationKey,
},
};
use crate::{
Index,
schnorr_signature::{
DST_LOTTERY, DST_SIGNATURE, JubjubHashToCurve, SchnorrVerificationKey, get_coordinates,
hash_msg_to_jubjubbase, jubjub_base_to_scalar,
},
};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct SchnorrSignature {
pub(crate) sigma: JubjubSubgroup,
pub(crate) s: JubjubScalar,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Descriptive names : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 🚀 New implemented feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants