@@ -9,16 +9,16 @@ use rand_core::{CryptoRng, RngCore};
99use group:: Group ;
1010
1111use crate :: schnorr_signature:: {
12- DST_SIGNATURE , SchnorrSignature , SchnorrVerificationKey ,
13- utils :: { get_coordinates_extended , get_coordinates_subgroup} ,
12+ DST_SIGNATURE , SchnorrSignature , SchnorrVerificationKey , get_coordinates_extended ,
13+ get_coordinates_subgroup,
1414} ;
1515
1616/// Schnorr Signing key, it is essentially a random scalar of the Jubjub scalar field
1717#[ derive( Debug , Clone ) ]
18- pub struct SchnorrSigningKey ( pub ( crate ) JubjubScalar ) ;
18+ pub struct SchnorrSigningKey ( pub JubjubScalar ) ;
1919
2020impl SchnorrSigningKey {
21- pub ( crate ) fn generate ( rng : & mut ( impl RngCore + CryptoRng ) ) -> Self {
21+ pub fn generate ( rng : & mut ( impl RngCore + CryptoRng ) ) -> Self {
2222 SchnorrSigningKey ( JubjubScalar :: random ( rng) )
2323 }
2424
@@ -61,7 +61,7 @@ impl SchnorrSigningKey {
6161 /// details in the implementation of the SchnorrSignature.
6262 ///
6363 // TODO: Check if we want the sign function to handle the randomness by itself
64- pub ( crate ) fn sign (
64+ pub fn sign (
6565 & self ,
6666 msg : & [ u8 ] ,
6767 rng : & mut ( impl RngCore + CryptoRng ) ,
@@ -71,40 +71,40 @@ impl SchnorrSigningKey {
7171 let verification_key = SchnorrVerificationKey :: from ( self ) ;
7272
7373 // First hashing the message to a scalar then hashing it to a curve point
74- let hash_msg = JubjubExtended :: hash_to_point ( msg) ;
74+ let msg_hash = JubjubExtended :: hash_to_point ( msg) ;
7575
76- let sigma = hash_msg * self . 0 ;
76+ let sigma = msg_hash * self . 0 ;
7777
7878 // Compute the random part of the signature with
7979 // r1 = H(msg) * r
8080 // r2 = g * r
8181 let random_scalar = JubjubScalar :: random ( rng) ;
82- let random_value_1 = hash_msg * random_scalar;
83- let random_value_2 = generator * random_scalar;
82+ let random_point_1 = msg_hash * random_scalar;
83+ let random_point_2 = generator * random_scalar;
8484
8585 // Since the hash function takes as input scalar elements
8686 // We need to convert the EC points to their coordinates
8787 // I use gx and gy for now but maybe we can replace them by a DST?
88- let ( hash_msg_x , hash_msg_y ) = get_coordinates_extended ( hash_msg ) ;
88+ let ( msg_hash_x , msg_hash_y ) = get_coordinates_extended ( msg_hash ) ;
8989 let ( verification_key_x, verification_key_y) = get_coordinates_subgroup ( verification_key. 0 ) ;
9090 let ( sigma_x, sigma_y) = get_coordinates_extended ( sigma) ;
91- let ( random_value_1_x , random_value_1_y ) = get_coordinates_extended ( random_value_1 ) ;
92- let ( random_value_2_x , random_value_2_y ) = get_coordinates_subgroup ( random_value_2 ) ;
91+ let ( random_point_1_x , random_point_1_y ) = get_coordinates_extended ( random_point_1 ) ;
92+ let ( random_point_2_x , random_point_2_y ) = get_coordinates_subgroup ( random_point_2 ) ;
9393
9494 let challenge = Hash :: digest_truncated (
9595 Domain :: Other ,
9696 & [
9797 DST_SIGNATURE ,
98- hash_msg_x ,
99- hash_msg_y ,
98+ msg_hash_x ,
99+ msg_hash_y ,
100100 verification_key_x,
101101 verification_key_y,
102102 sigma_x,
103103 sigma_y,
104- random_value_1_x ,
105- random_value_1_y ,
106- random_value_2_x ,
107- random_value_2_y ,
104+ random_point_1_x ,
105+ random_point_1_y ,
106+ random_point_2_x ,
107+ random_point_2_y ,
108108 ] ,
109109 ) [ 0 ] ;
110110
0 commit comments