1313//! - `C`: the codec (`Codec` trait).
1414//! - `G`: the group used for commitments and operations (`Group` trait).
1515
16- use crate :: {
17- codec:: Codec , CompactProtocol , ProofError , SigmaProtocol
18- } ;
16+ use crate :: { codec:: Codec , CompactProtocol , ProofError , SigmaProtocol } ;
1917
2018use group:: { Group , GroupEncoding } ;
2119use rand:: { CryptoRng , RngCore } ;
6765 pub fn prove (
6866 & mut self ,
6967 witness : & P :: Witness ,
70- rng : & mut ( impl RngCore + CryptoRng )
68+ rng : & mut ( impl RngCore + CryptoRng ) ,
7169 ) -> ( P :: Commitment , P :: Challenge , P :: Response ) {
7270 let mut codec = self . hash_state . clone ( ) ;
7371
7876 data. extend_from_slice ( commit. to_bytes ( ) . as_ref ( ) ) ;
7977 }
8078 // Fiat Shamir challenge
81- let challenge = codec
82- . prover_message ( & data)
83- . verifier_challenge ( ) ;
79+ let challenge = codec. prover_message ( & data) . verifier_challenge ( ) ;
8480 // Prover's response
8581 let response = self . sigmap . prover_response ( prover_state, & challenge) ;
8682 // Local verification of the proof
9692 & mut self ,
9793 commitment : & P :: Commitment ,
9894 challenge : & P :: Challenge ,
99- response : & P :: Response
95+ response : & P :: Response ,
10096 ) -> Result < ( ) , ProofError > {
10197 let mut codec = self . hash_state . clone ( ) ;
10298
@@ -106,9 +102,7 @@ where
106102 data. extend_from_slice ( commit. to_bytes ( ) . as_ref ( ) ) ;
107103 }
108104 // Recompute the challenge
109- let expected_challenge = codec
110- . prover_message ( & data)
111- . verifier_challenge ( ) ;
105+ let expected_challenge = codec. prover_message ( & data) . verifier_challenge ( ) ;
112106 // Verification of the proof
113107 match * challenge == expected_challenge {
114108 true => self . sigmap . verifier ( commitment, challenge, response) ,
@@ -119,17 +113,14 @@ where
119113 pub fn prove_batchable (
120114 & mut self ,
121115 witness : & P :: Witness ,
122- rng : & mut ( impl RngCore + CryptoRng )
116+ rng : & mut ( impl RngCore + CryptoRng ) ,
123117 ) -> Vec < u8 > {
124118 let ( commitment, challenge, response) = self . prove ( witness, rng) ;
125119 self . sigmap
126120 . serialize_batchable ( & commitment, & challenge, & response)
127121 }
128122
129- pub fn verify_batchable (
130- & mut self ,
131- proof : & [ u8 ]
132- ) -> Result < ( ) , ProofError > {
123+ pub fn verify_batchable ( & mut self , proof : & [ u8 ] ) -> Result < ( ) , ProofError > {
133124 let ( commitment, response) = self . sigmap . deserialize_batchable ( proof) . unwrap ( ) ;
134125
135126 let mut codec = self . hash_state . clone ( ) ;
@@ -140,9 +131,7 @@ where
140131 data. extend_from_slice ( commit. to_bytes ( ) . as_ref ( ) ) ;
141132 }
142133 // Recompute the challenge
143- let challenge = codec
144- . prover_message ( & data)
145- . verifier_challenge ( ) ;
134+ let challenge = codec. prover_message ( & data) . verifier_challenge ( ) ;
146135 // Verification of the proof
147136 self . sigmap . verifier ( & commitment, & challenge, & response)
148137 }
@@ -157,21 +146,18 @@ where
157146 pub fn prove_compact (
158147 & mut self ,
159148 witness : & P :: Witness ,
160- rng : & mut ( impl RngCore + CryptoRng )
149+ rng : & mut ( impl RngCore + CryptoRng ) ,
161150 ) -> Vec < u8 > {
162151 let ( commitment, challenge, response) = self . prove ( witness, rng) ;
163152 self . sigmap
164153 . serialize_compact ( & commitment, & challenge, & response)
165154 }
166155
167- pub fn verify_compact (
168- & mut self ,
169- proof : & [ u8 ]
170- ) -> Result < ( ) , ProofError > {
156+ pub fn verify_compact ( & mut self , proof : & [ u8 ] ) -> Result < ( ) , ProofError > {
171157 let ( challenge, response) = self . sigmap . deserialize_compact ( proof) . unwrap ( ) ;
172158 // Compute the commitments
173159 let commitment = self . sigmap . get_commitment ( & challenge, & response) ;
174160 // Verify the proof
175161 self . verify ( & commitment, & challenge, & response)
176162 }
177- }
163+ }
0 commit comments