@@ -15,13 +15,7 @@ use rand::{CryptoRng, Rng};
1515/// A Schnorr protocol proving knowledge some discrete logarithm relation.
1616///
1717/// The specific proof instance is defined by a [`GroupMorphismPreimage`] over a group `G`.
18- pub struct SchnorrProof < G >
19- where
20- G : Group + GroupEncoding + GroupSerialisation ,
21- {
22- /// The public instance and its associated group morphism.
23- pub morphismp : GroupMorphismPreimage < G > ,
24- }
18+ pub struct SchnorrProof < G : Group + GroupEncoding + GroupSerialisation > ( pub GroupMorphismPreimage < G > ) ;
2519
2620/// Internal prover state during the protocol execution: (random nonce, witness)
2721pub struct SchnorrState < S > {
4741 witness : & Self :: Witness ,
4842 mut rng : & mut ( impl Rng + CryptoRng ) ,
4943 ) -> ( Self :: Commitment , Self :: ProverState ) {
50- let nonces: Vec < G :: Scalar > = ( 0 ..self . morphismp . morphism . num_scalars ) . map ( |_| G :: Scalar :: random ( & mut rng) ) . collect ( ) ;
44+ let nonces: Vec < G :: Scalar > = ( 0 ..self . 0 . morphism . num_scalars ) . map ( |_| G :: Scalar :: random ( & mut rng) ) . collect ( ) ;
5145 let prover_state = ( nonces. clone ( ) , witness. clone ( ) ) ;
52- let commitment = self . morphismp . morphism . evaluate ( & nonces) ;
46+ let commitment = self . 0 . morphism . evaluate ( & nonces) ;
5347 ( commitment, prover_state)
5448 }
5549
6054 challenge : & Self :: Challenge ,
6155 ) -> Self :: Response {
6256 let mut responses = Vec :: new ( ) ;
63- for i in 0 ..self . morphismp . morphism . num_scalars {
64- responses. push ( state. 0 [ i] + * challenge * state. 1 [ i] ) ;
57+ for i in 0 ..self . 0 . morphism . num_scalars {
58+ responses. push ( state. 0 [ i] + state. 1 [ i] * challenge ) ;
6559 }
6660 responses
6761 }
@@ -73,16 +67,16 @@ where
7367 challenge : & Self :: Challenge ,
7468 response : & Self :: Response ,
7569 ) -> Result < ( ) , ProofError > {
76- let lhs = self . morphismp . morphism . evaluate ( response) ;
70+ let lhs = self . 0 . morphism . evaluate ( response) ;
7771
7872 let mut rhs = Vec :: new ( ) ;
7973 for ( i, g) in commitment
8074 . iter ( )
8175 . enumerate ( )
82- . take ( self . morphismp . morphism . num_statements ( ) )
76+ . take ( self . 0 . morphism . num_statements ( ) )
8377 {
8478 rhs. push (
85- self . morphismp . morphism . group_elements [ self . morphismp . image [ i] ] * challenge + g,
79+ self . 0 . morphism . group_elements [ self . 0 . image [ i] ] * challenge + g,
8680 ) ;
8781 }
8882
10094 response : & Self :: Response ,
10195 ) -> Vec < u8 > {
10296 let mut bytes = Vec :: new ( ) ;
103- let scalar_nb = self . morphismp . morphism . num_scalars ;
104- let point_nb = self . morphismp . morphism . num_statements ( ) ;
97+ let scalar_nb = self . 0 . morphism . num_scalars ;
98+ let point_nb = self . 0 . morphism . num_statements ( ) ;
10599
106100 // Serialize commitments
107101 for commit in commitment. iter ( ) . take ( point_nb) {
@@ -117,8 +111,8 @@ where
117111
118112 /// Deserializes a batchable proof format back into (`commitment`, `response`).
119113 fn deserialize_batchable ( & self , data : & [ u8 ] ) -> Option < ( Self :: Commitment , Self :: Response ) > {
120- let scalar_nb = self . morphismp . morphism . num_scalars ;
121- let point_nb = self . morphismp . morphism . num_statements ( ) ;
114+ let scalar_nb = self . 0 . morphism . num_scalars ;
115+ let point_nb = self . 0 . morphism . num_statements ( ) ;
122116
123117 let point_size = G :: generator ( ) . to_bytes ( ) . as_ref ( ) . len ( ) ;
124118 let scalar_size = <<G as Group >:: Scalar as PrimeField >:: Repr :: default ( )
0 commit comments