-
Notifications
You must be signed in to change notification settings - Fork 52
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.
| // TODO: Remove | ||
| #![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.
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.
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.
actually, I suggested this to be removed when we are finished with all tasks of this PR.
| 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::*; |
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.
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.
… it is not published.
00276b3 to
3ddf71f
Compare
…n from schnorr signature.
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.
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; |
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 can use random_scalar_1, random_scalar_2. WDYT? @damrobi @jpraynaud
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 think scalar is fine, it's more descriptive
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.
Actually those values are points, so as you said in an other comment maybe random_point_1 would be better?
| // TODO: Remove | ||
| #![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.
actually, I suggested this to be removed when we are finished with all tasks of this PR.
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