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   22m 55s ⏱️ -46s
2 210 tests ±0  2 210 ✅ ±0  0 💤 ±0  0 ❌ ±0 
6 895 runs  ±0  6 895 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 40c68d6. ± Comparison against base commit b9f2466.

♻️ 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
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.

Comment on lines +1 to +2
// TODO: Remove
#![allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

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

We want the code to be as TODO free as possible.

You can use public visibility to avoid the dead code warnings that we don't want to keep when merged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

actually, I suggested this to be removed when we are finished with all tasks of this PR.

Comment on lines 4 to 22
use midnight_circuits::{
ecc::{hash_to_curve::HashToCurveGadget, native::EccChip},
hash::poseidon::PoseidonChip,
types::AssignedNative,
};
use midnight_curves::{
Fq as JubjubBase, Fr as JubjubScalar, JubjubAffine, JubjubExtended, JubjubSubgroup,
};
use sha2::{Digest, Sha256};

use anyhow::{Result, anyhow};

mod signature;
mod signing_key;
mod verification_key;

use signature::*;
// use signing_key::*;
use verification_key::*;
Copy link
Member

Choose a reason for hiding this comment

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

You should separate the module declaration from the imports and put the imports after. It is usually a good practice to create a new module inline to do that(you can refer to other files in the repository). A better option would be to move all this code in a new separate module like utils.

@damrobi damrobi force-pushed the damrobi/stm-add-schnorr-sig-module branch from 00276b3 to 3ddf71f Compare November 17, 2025 11:40
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.

You should use full names even in function parameters. For example verification_key instead of vk.
For simplicity and descriptiveness, we can use random_scalar_1 instead of random_value_1. Consequently, we can call the generator * random_scalar_1 as random_point_1.
This will apply for all cases where we obtain a curve point by multiplying the generator with a scalar: For example: point_signature = generator * signature.
This kind of naming seems more descriptive and pleasant.
Final remark, if you use an underscore for separating numbers in one place, then you should do the same for all other similar cases. It should apply for separating x and y as well.

// Computing R1 = H(msg) * s + sigma * c
let hash_msg_times_sig = hash_msg * self.signature;
let sigma_times_challenge = self.sigma * self.challenge;
let random_value_1_recomputed = hash_msg_times_sig + sigma_times_challenge;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can use random_scalar_1, random_scalar_2. WDYT? @damrobi @jpraynaud

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think scalar is fine, it's more descriptive

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually those values are points, so as you said in an other comment maybe random_point_1 would be better?

Comment on lines +1 to +2
// TODO: Remove
#![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.

actually, I suggested this to be removed when we are finished with all tasks of this PR.

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.

4 participants