-
Notifications
You must be signed in to change notification settings - Fork 51
Implementation of Schnorr signature module for mithril-stm. #2761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
b254ad2 to
1e07c07
Compare
There was a problem hiding this 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.
There was a problem hiding this 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.
curiecrypt
left a comment
There was a problem hiding this 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" } |
There was a problem hiding this comment.
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)] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #![allow(dead_code)] | |
| /// TODO: Remove | |
| #![allow(dead_code)] |
| mod signing_key; | ||
| mod verification_key; | ||
|
|
||
| /// A DST to distinguish between use of Poseidon hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// 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.
| use crate::schnorr_signature::{ | ||
| signature::SchnorrSignature, verification_key::SchnorrVerificationKey, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
| use crate::{ | ||
| Index, | ||
| schnorr_signature::{ | ||
| DST_LOTTERY, DST_SIGNATURE, JubjubHashToCurve, get_coordinates, hash_msg_to_jubjubbase, | ||
| jubjub_base_to_scalar, verification_key::SchnorrVerificationKey, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Descriptive names : )
Content
This PR includes a new module for
mithril-stmcontaining an implementation for the Schnorr signature that will be used in the SNARK version of mithril.Pre-submit checklist
Comments
Issue(s)
Relates to #2756