Skip to content

Conversation

@curiecrypt
Copy link
Collaborator

@curiecrypt curiecrypt commented Dec 1, 2025

Content

This PR includes the jubjub wrapper for the schnorr_signature module.
The jubjub exposer, located in ../schnorr_signature/jubjub/, includes:

  • curve_points
  • field_elements
  • poseidon_digest
    It exposes the jubjub functionality (from dusk for today) required by the Schnorr signature.

This wrapper removed all dusk imports from the Schnorr implementation.

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)

Closes #2817

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Test Results

    4 files  ±0    172 suites  ±0   23m 52s ⏱️ +21s
2 296 tests ±0  2 296 ✅ ±0  0 💤 ±0  0 ❌ ±0 
7 225 runs  ±0  7 225 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 7f64ad9. ± Comparison against base commit 27e041d.

♻️ This comment has been updated with latest results.

@curiecrypt curiecrypt force-pushed the curiecrypt/msnark/jubjub-wrapper branch from bdab491 to dc04ec6 Compare December 3, 2025 18:02
@curiecrypt curiecrypt marked this pull request as ready for review December 5, 2025 15:35
@curiecrypt curiecrypt requested a review from jpraynaud December 5, 2025 15:48
Copy link
Member

Choose a reason for hiding this comment

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

It seems a problem occurred during merging from your previous branch as this file should not be modified.

Copy link
Member

Choose a reason for hiding this comment

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

Same comment about this file which should not be modified.

Copy link
Member

Choose a reason for hiding this comment

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

Same comment about this file which should not be modified.

Copy link
Member

Choose a reason for hiding this comment

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

Same comment about this file which should not be modified.

Copy link
Member

Choose a reason for hiding this comment

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

Same comment about this file which should not be modified.

Comment on lines +75 to +77
pub(crate) fn from_prime_order_projective_point(
prime_order_projective_point: PrimeOrderProjectivePoint,
) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this conversion could be implemented with a From trait instead?

Comment on lines +57 to +61
let response_time_msg_hash_point = msg_hash_point.scalar_multiplication(&self.response);
let challenge_times_commitment_point =
self.commitment_point.scalar_multiplication(&self.challenge);
let random_point_1_recomputed =
response_time_msg_hash_point.add(challenge_times_commitment_point);
Copy link
Member

@jpraynaud jpraynaud Dec 8, 2025

Choose a reason for hiding this comment

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

Maybe we could leverage the std::ops::Add, std::ops::Mul to provide some syntactic sugar for these expression? (also for the rest of the module).

This would allow to have some more readable code?:

let random_point_1_recomputed =  self.response * msg_hash_point + self.challenge * self.commitment_point;

msg_hash,
verification_key.0.into(),
self.sigma,
let points_coordinates = BaseFieldElement::collect_coordinates_of_list_of_points(&[
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the collect_coordinates_of_list_of_points could be inlined in a more functional way with an iter/map pattern?

Comment on lines -157 to -206
use crate::{SchnorrSignature, SchnorrSigningKey, SchnorrVerificationKey};
use rand_chacha::ChaCha20Rng;
use rand_core::SeedableRng;

#[test]
fn invalid_sig() {
let msg = vec![0, 0, 0, 1];
let msg2 = vec![0, 0, 0, 2];
let seed = [0u8; 32];
let mut rng = ChaCha20Rng::from_seed(seed);
let sk = SchnorrSigningKey::try_generate(&mut rng).unwrap();
let vk = SchnorrVerificationKey::from(&sk);
let sk2 = SchnorrSigningKey::try_generate(&mut rng).unwrap();
let vk2 = SchnorrVerificationKey::from(&sk2);

let sig = sk.sign(&msg, &mut rng).unwrap();
let sig2 = sk.sign(&msg2, &mut rng).unwrap();

// Wrong verification key is used
let result1 = sig.verify(&msg, &vk2);
let result2 = sig2.verify(&msg, &vk);

result1.expect_err("Wrong verification key used, test should fail.");
// Wrong message is verified
result2.expect_err("Wrong message used, test should fail.");
}

#[test]
fn serialize_deserialize_signature() {
let mut rng = ChaCha20Rng::from_seed([0u8; 32]);

let msg = vec![0, 0, 0, 1];
let sk = SchnorrSigningKey::try_generate(&mut rng).unwrap();

let sig = sk.sign(&msg, &mut rng).unwrap();
let sig_bytes: [u8; 96] = sig.to_bytes();
let sig2 = SchnorrSignature::from_bytes(&sig_bytes).unwrap();

assert_eq!(sig, sig2);
}

#[test]
fn from_bytes_signature_not_enough_bytes() {
let msg = vec![0u8; 95];

let result = SchnorrSignature::from_bytes(&msg);

result.expect_err("Not enough bytes.");
}

Copy link
Member

Choose a reason for hiding this comment

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

I think that we should probably keep some unit test here for (de)serialization and basic signature unit tests.

Copy link
Member

Choose a reason for hiding this comment

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

These sub-modules lack proper rust doc comments for types and functions,

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.

Implement Jubjub/Poseidon backends wrappers in Schnorr signature scheme

3 participants