4545 /// Current codec state.
4646 pub hash_state : C ,
4747 /// Underlying interactive proof.
48- pub ip : P ,
48+ pub interactive_proof : P ,
4949}
5050
5151impl < P , C > NISigmaProtocol < P , C >
@@ -70,15 +70,15 @@ where
7070 ) ;
7171 Self {
7272 hash_state,
73- ip : interactive_proof,
73+ interactive_proof,
7474 }
7575 }
7676
77- pub fn from_iv ( iv : [ u8 ; 32 ] , instance : P ) -> Self {
77+ pub fn from_iv ( iv : [ u8 ; 32 ] , interactive_proof : P ) -> Self {
7878 let hash_state = C :: from_iv ( iv) ;
7979 Self {
8080 hash_state,
81- ip : instance ,
81+ interactive_proof ,
8282 }
8383 }
8484
@@ -106,15 +106,16 @@ where
106106 ) -> Result < Transcript < P > , Error > {
107107 let mut hash_state = self . hash_state . clone ( ) ;
108108
109- let ( commitment, prover_state) = self . ip . prover_commit ( witness, rng) ?;
109+ let ( commitment, prover_state) = self . interactive_proof . prover_commit ( witness, rng) ?;
110110 // Fiat Shamir challenge
111- let serialized_commitment = self . ip . serialize_commitment ( & commitment) ;
111+ let serialized_commitment = self . interactive_proof . serialize_commitment ( & commitment) ;
112112 hash_state. prover_message ( & serialized_commitment) ;
113113 let challenge = hash_state. verifier_challenge ( ) ;
114114 // Prover's response
115- let response = self . ip . prover_response ( prover_state, & challenge) ?;
115+ let response = self . interactive_proof . prover_response ( prover_state, & challenge) ?;
116+
116117 // Local verification of the proof
117- self . ip . verifier ( & commitment, & challenge, & response) ? ;
118+ debug_assert ! ( self . interactive_proof . verifier( & commitment, & challenge, & response) . is_ok ( ) ) ;
118119 Ok ( ( commitment, challenge, response) )
119120 }
120121
@@ -142,12 +143,12 @@ where
142143 let mut hash_state = self . hash_state . clone ( ) ;
143144
144145 // Recompute the challenge
145- let serialized_commitment = self . ip . serialize_commitment ( commitment) ;
146+ let serialized_commitment = self . interactive_proof . serialize_commitment ( commitment) ;
146147 hash_state. prover_message ( & serialized_commitment) ;
147148 let expected_challenge = hash_state. verifier_challenge ( ) ;
148149 // Verification of the proof
149150 match * challenge == expected_challenge {
150- true => self . ip . verifier ( commitment, challenge, response) ,
151+ true => self . interactive_proof . verifier ( commitment, challenge, response) ,
151152 false => Err ( Error :: VerificationFailure ) ,
152153 }
153154 }
@@ -169,8 +170,8 @@ where
169170 ) -> Result < Vec < u8 > , Error > {
170171 let ( commitment, _challenge, response) = self . prove ( witness, rng) ?;
171172 let mut bytes = Vec :: new ( ) ;
172- bytes. extend_from_slice ( & self . ip . serialize_commitment ( & commitment) ) ;
173- bytes. extend_from_slice ( & self . ip . serialize_response ( & response) ) ;
173+ bytes. extend_from_slice ( & self . interactive_proof . serialize_commitment ( & commitment) ) ;
174+ bytes. extend_from_slice ( & self . interactive_proof . serialize_response ( & response) ) ;
174175 Ok ( bytes)
175176 }
176177
@@ -188,18 +189,18 @@ where
188189 /// - The challenge doesn't match the recomputed one from the commitment.
189190 /// - The response fails verification under the Sigma protocol.
190191 pub fn verify_batchable ( & self , proof : & [ u8 ] ) -> Result < ( ) , Error > {
191- let commitment = self . ip . deserialize_commitment ( proof) ?;
192- let commitment_size = self . ip . serialize_commitment ( & commitment) . len ( ) ;
193- let response = self . ip . deserialize_response ( & proof[ commitment_size..] ) ?;
192+ let commitment = self . interactive_proof . deserialize_commitment ( proof) ?;
193+ let commitment_size = self . interactive_proof . serialize_commitment ( & commitment) . len ( ) ;
194+ let response = self . interactive_proof . deserialize_response ( & proof[ commitment_size..] ) ?;
194195
195196 let mut hash_state = self . hash_state . clone ( ) ;
196197
197198 // Recompute the challenge
198- let serialized_commitment = self . ip . serialize_commitment ( & commitment) ;
199+ let serialized_commitment = self . interactive_proof . serialize_commitment ( & commitment) ;
199200 hash_state. prover_message ( & serialized_commitment) ;
200201 let challenge = hash_state. verifier_challenge ( ) ;
201202 // Verification of the proof
202- self . ip . verifier ( & commitment, & challenge, & response)
203+ self . interactive_proof . verifier ( & commitment, & challenge, & response)
203204 }
204205}
205206
@@ -229,8 +230,8 @@ where
229230 ) -> Result < Vec < u8 > , Error > {
230231 let ( _commitment, challenge, response) = self . prove ( witness, rng) ?;
231232 let mut bytes = Vec :: new ( ) ;
232- bytes. extend_from_slice ( & self . ip . serialize_challenge ( & challenge) ) ;
233- bytes. extend_from_slice ( & self . ip . serialize_response ( & response) ) ;
233+ bytes. extend_from_slice ( & self . interactive_proof . serialize_challenge ( & challenge) ) ;
234+ bytes. extend_from_slice ( & self . interactive_proof . serialize_response ( & response) ) ;
234235 Ok ( bytes)
235236 }
236237
@@ -251,12 +252,12 @@ where
251252 /// - The recomputed commitment or response is invalid under the Sigma protocol.
252253 pub fn verify_compact ( & self , proof : & [ u8 ] ) -> Result < ( ) , Error > {
253254 // Deserialize challenge and response from compact proof
254- let challenge = self . ip . deserialize_challenge ( proof) ?;
255- let challenge_size = self . ip . serialize_challenge ( & challenge) . len ( ) ;
256- let response = self . ip . deserialize_response ( & proof[ challenge_size..] ) ?;
255+ let challenge = self . interactive_proof . deserialize_challenge ( proof) ?;
256+ let challenge_size = self . interactive_proof . serialize_challenge ( & challenge) . len ( ) ;
257+ let response = self . interactive_proof . deserialize_response ( & proof[ challenge_size..] ) ?;
257258
258259 // Compute the commitments
259- let commitment = self . ip . simulate_commitment ( & challenge, & response) ?;
260+ let commitment = self . interactive_proof . simulate_commitment ( & challenge, & response) ?;
260261 // Verify the proof
261262 self . verify ( & commitment, & challenge, & response)
262263 }
0 commit comments