@@ -69,64 +69,64 @@ where
6969
7070// Structure representing the Commitment type of Protocol as SigmaProtocol
7171#[ derive( Clone ) ]
72- pub enum ProtocolCommitment < G : PrimeGroup > {
72+ pub enum ComposedCommitment < G : PrimeGroup > {
7373 Simple ( <SchnorrProof < G > as SigmaProtocol >:: Commitment ) ,
74- And ( Vec < ProtocolCommitment < G > > ) ,
75- Or ( Vec < ProtocolCommitment < G > > ) ,
74+ And ( Vec < ComposedCommitment < G > > ) ,
75+ Or ( Vec < ComposedCommitment < G > > ) ,
7676}
7777
7878// Structure representing the ProverState type of Protocol as SigmaProtocol
7979#[ derive( Clone ) ]
80- pub enum ProtocolProverState < G : PrimeGroup > {
80+ pub enum ComposedProverState < G : PrimeGroup > {
8181 Simple ( <SchnorrProof < G > as SigmaProtocol >:: ProverState ) ,
82- And ( Vec < ProtocolProverState < G > > ) ,
82+ And ( Vec < ComposedProverState < G > > ) ,
8383 Or (
8484 usize , // real index
85- Vec < ProtocolProverState < G > > , // real ProverState
86- ( Vec < ProtocolChallenge < G > > , Vec < ProtocolResponse < G > > ) , // simulated transcripts
85+ Vec < ComposedProverState < G > > , // real ProverState
86+ ( Vec < ComposedChallenge < G > > , Vec < ComposedResponse < G > > ) , // simulated transcripts
8787 ) ,
8888}
8989
9090// Structure representing the Response type of Protocol as SigmaProtocol
9191#[ derive( Clone ) ]
92- pub enum ProtocolResponse < G : PrimeGroup > {
92+ pub enum ComposedResponse < G : PrimeGroup > {
9393 Simple ( <SchnorrProof < G > as SigmaProtocol >:: Response ) ,
94- And ( Vec < ProtocolResponse < G > > ) ,
95- Or ( Vec < ProtocolChallenge < G > > , Vec < ProtocolResponse < G > > ) ,
94+ And ( Vec < ComposedResponse < G > > ) ,
95+ Or ( Vec < ComposedChallenge < G > > , Vec < ComposedResponse < G > > ) ,
9696}
9797
9898// Structure representing the Witness type of Protocol as SigmaProtocol
99- pub enum ProtocolWitness < G : PrimeGroup > {
99+ pub enum ComposedWitness < G : PrimeGroup > {
100100 Simple ( <SchnorrProof < G > as SigmaProtocol >:: Witness ) ,
101- And ( Vec < ProtocolWitness < G > > ) ,
102- Or ( usize , Vec < ProtocolWitness < G > > ) ,
101+ And ( Vec < ComposedWitness < G > > ) ,
102+ Or ( usize , Vec < ComposedWitness < G > > ) ,
103103}
104104
105105// Structure representing the Challenge type of Protocol as SigmaProtocol
106- type ProtocolChallenge < G > = <SchnorrProof < G > as SigmaProtocol >:: Challenge ;
106+ type ComposedChallenge < G > = <SchnorrProof < G > as SigmaProtocol >:: Challenge ;
107107
108108impl < G : PrimeGroup > SigmaProtocol for ComposedRelation < G > {
109- type Commitment = ProtocolCommitment < G > ;
110- type ProverState = ProtocolProverState < G > ;
111- type Response = ProtocolResponse < G > ;
112- type Witness = ProtocolWitness < G > ;
113- type Challenge = ProtocolChallenge < G > ;
109+ type Commitment = ComposedCommitment < G > ;
110+ type ProverState = ComposedProverState < G > ;
111+ type Response = ComposedResponse < G > ;
112+ type Witness = ComposedWitness < G > ;
113+ type Challenge = ComposedChallenge < G > ;
114114
115115 fn prover_commit (
116116 & self ,
117117 witness : & Self :: Witness ,
118118 rng : & mut ( impl rand:: Rng + rand:: CryptoRng ) ,
119119 ) -> Result < ( Self :: Commitment , Self :: ProverState ) , Error > {
120120 match ( self , witness) {
121- ( ComposedRelation :: Simple ( p) , ProtocolWitness :: Simple ( w) ) => {
121+ ( ComposedRelation :: Simple ( p) , ComposedWitness :: Simple ( w) ) => {
122122 p. prover_commit ( w, rng) . map ( |( c, s) | {
123123 (
124- ProtocolCommitment :: Simple ( c) ,
125- ProtocolProverState :: Simple ( s) ,
124+ ComposedCommitment :: Simple ( c) ,
125+ ComposedProverState :: Simple ( s) ,
126126 )
127127 } )
128128 }
129- ( ComposedRelation :: And ( ps) , ProtocolWitness :: And ( ws) ) => {
129+ ( ComposedRelation :: And ( ps) , ComposedWitness :: And ( ws) ) => {
130130 if ps. len ( ) != ws. len ( ) {
131131 return Err ( Error :: InvalidInstanceWitnessPair ) ;
132132 }
@@ -140,11 +140,11 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
140140 }
141141
142142 Ok ( (
143- ProtocolCommitment :: And ( commitments) ,
144- ProtocolProverState :: And ( prover_states) ,
143+ ComposedCommitment :: And ( commitments) ,
144+ ComposedProverState :: And ( prover_states) ,
145145 ) )
146146 }
147- ( ComposedRelation :: Or ( ps) , ProtocolWitness :: Or ( w_index, w) ) => {
147+ ( ComposedRelation :: Or ( ps) , ComposedWitness :: Or ( w_index, w) ) => {
148148 let mut commitments = Vec :: new ( ) ;
149149 let mut simulated_challenges = Vec :: new ( ) ;
150150 let mut simulated_responses = Vec :: new ( ) ;
@@ -160,8 +160,8 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
160160 commitments. insert ( * w_index, real_commitment) ;
161161
162162 Ok ( (
163- ProtocolCommitment :: Or ( commitments) ,
164- ProtocolProverState :: Or (
163+ ComposedCommitment :: Or ( commitments) ,
164+ ComposedProverState :: Or (
165165 * w_index,
166166 vec ! [ real_state] ,
167167 ( simulated_challenges, simulated_responses) ,
@@ -178,10 +178,10 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
178178 challenge : & Self :: Challenge ,
179179 ) -> Result < Self :: Response , Error > {
180180 match ( self , state) {
181- ( ComposedRelation :: Simple ( p) , ProtocolProverState :: Simple ( state) ) => p
181+ ( ComposedRelation :: Simple ( p) , ComposedProverState :: Simple ( state) ) => p
182182 . prover_response ( state, challenge)
183- . map ( ProtocolResponse :: Simple ) ,
184- ( ComposedRelation :: And ( ps) , ProtocolProverState :: And ( states) ) => {
183+ . map ( ComposedResponse :: Simple ) ,
184+ ( ComposedRelation :: And ( ps) , ComposedProverState :: And ( states) ) => {
185185 if ps. len ( ) != states. len ( ) {
186186 return Err ( Error :: InvalidInstanceWitnessPair ) ;
187187 }
@@ -191,11 +191,11 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
191191 . map ( |( p, s) | p. prover_response ( s, challenge) )
192192 . collect ( ) ;
193193
194- Ok ( ProtocolResponse :: And ( responses?) )
194+ Ok ( ComposedResponse :: And ( responses?) )
195195 }
196196 (
197197 ComposedRelation :: Or ( ps) ,
198- ProtocolProverState :: Or (
198+ ComposedProverState :: Or (
199199 w_index,
200200 real_state,
201201 ( simulated_challenges, simulated_responses) ,
@@ -221,7 +221,7 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
221221 responses. push ( simulated_responses[ simulated_index] . clone ( ) ) ;
222222 }
223223 }
224- Ok ( ProtocolResponse :: Or ( challenges, responses) )
224+ Ok ( ComposedResponse :: Or ( challenges, responses) )
225225 }
226226 _ => panic ! ( ) ,
227227 }
@@ -236,22 +236,22 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
236236 match ( self , commitment, response) {
237237 (
238238 ComposedRelation :: Simple ( p) ,
239- ProtocolCommitment :: Simple ( c) ,
240- ProtocolResponse :: Simple ( r) ,
239+ ComposedCommitment :: Simple ( c) ,
240+ ComposedResponse :: Simple ( r) ,
241241 ) => p. verifier ( c, challenge, r) ,
242242 (
243243 ComposedRelation :: And ( ps) ,
244- ProtocolCommitment :: And ( commitments) ,
245- ProtocolResponse :: And ( responses) ,
244+ ComposedCommitment :: And ( commitments) ,
245+ ComposedResponse :: And ( responses) ,
246246 ) => ps
247247 . iter ( )
248248 . zip ( commitments)
249249 . zip ( responses)
250250 . try_for_each ( |( ( p, c) , r) | p. verifier ( c, challenge, r) ) ,
251251 (
252252 ComposedRelation :: Or ( ps) ,
253- ProtocolCommitment :: Or ( commitments) ,
254- ProtocolResponse :: Or ( challenges, responses) ,
253+ ComposedCommitment :: Or ( commitments) ,
254+ ComposedResponse :: Or ( challenges, responses) ,
255255 ) => {
256256 let mut expected_difference = * challenge;
257257 for ( i, p) in ps. iter ( ) . enumerate ( ) {
@@ -269,11 +269,11 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
269269
270270 fn serialize_commitment ( & self , commitment : & Self :: Commitment ) -> Vec < u8 > {
271271 match ( self , commitment) {
272- ( ComposedRelation :: Simple ( p) , ProtocolCommitment :: Simple ( c) ) => {
272+ ( ComposedRelation :: Simple ( p) , ComposedCommitment :: Simple ( c) ) => {
273273 p. serialize_commitment ( c)
274274 }
275- ( ComposedRelation :: And ( ps) , ProtocolCommitment :: And ( commitments) )
276- | ( ComposedRelation :: Or ( ps) , ProtocolCommitment :: Or ( commitments) ) => ps
275+ ( ComposedRelation :: And ( ps) , ComposedCommitment :: And ( commitments) )
276+ | ( ComposedRelation :: Or ( ps) , ComposedCommitment :: Or ( commitments) ) => ps
277277 . iter ( )
278278 . zip ( commitments)
279279 . flat_map ( |( p, c) | p. serialize_commitment ( c) )
@@ -339,15 +339,15 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
339339
340340 fn serialize_response ( & self , response : & Self :: Response ) -> Vec < u8 > {
341341 match ( self , response) {
342- ( ComposedRelation :: Simple ( p) , ProtocolResponse :: Simple ( r) ) => p. serialize_response ( r) ,
343- ( ComposedRelation :: And ( ps) , ProtocolResponse :: And ( responses) ) => {
342+ ( ComposedRelation :: Simple ( p) , ComposedResponse :: Simple ( r) ) => p. serialize_response ( r) ,
343+ ( ComposedRelation :: And ( ps) , ComposedResponse :: And ( responses) ) => {
344344 let mut bytes = Vec :: new ( ) ;
345345 for ( i, p) in ps. iter ( ) . enumerate ( ) {
346346 bytes. extend ( p. serialize_response ( & responses[ i] ) ) ;
347347 }
348348 bytes
349349 }
350- ( ComposedRelation :: Or ( ps) , ProtocolResponse :: Or ( challenges, responses) ) => {
350+ ( ComposedRelation :: Or ( ps) , ComposedResponse :: Or ( challenges, responses) ) => {
351351 let mut bytes = Vec :: new ( ) ;
352352 for ( i, p) in ps. iter ( ) . enumerate ( ) {
353353 bytes. extend ( & serialize_scalars :: < G > ( & [ challenges[ i] ] ) ) ;
@@ -363,7 +363,7 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
363363 match self {
364364 ComposedRelation :: Simple ( p) => {
365365 let c = p. deserialize_commitment ( data) ?;
366- Ok ( ProtocolCommitment :: Simple ( c) )
366+ Ok ( ComposedCommitment :: Simple ( c) )
367367 }
368368 ComposedRelation :: And ( ps) | ComposedRelation :: Or ( ps) => {
369369 let mut cursor = 0 ;
@@ -377,8 +377,8 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
377377 }
378378
379379 Ok ( match self {
380- ComposedRelation :: And ( _) => ProtocolCommitment :: And ( commitments) ,
381- ComposedRelation :: Or ( _) => ProtocolCommitment :: Or ( commitments) ,
380+ ComposedRelation :: And ( _) => ComposedCommitment :: And ( commitments) ,
381+ ComposedRelation :: Or ( _) => ComposedCommitment :: Or ( commitments) ,
382382 _ => unreachable ! ( ) ,
383383 } )
384384 }
@@ -394,7 +394,7 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
394394 match self {
395395 ComposedRelation :: Simple ( p) => {
396396 let r = p. deserialize_response ( data) ?;
397- Ok ( ProtocolResponse :: Simple ( r) )
397+ Ok ( ComposedResponse :: Simple ( r) )
398398 }
399399 ComposedRelation :: And ( ps) => {
400400 let mut cursor = 0 ;
@@ -405,7 +405,7 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
405405 cursor += size;
406406 responses. push ( r) ;
407407 }
408- Ok ( ProtocolResponse :: And ( responses) )
408+ Ok ( ComposedResponse :: And ( responses) )
409409 }
410410 ComposedRelation :: Or ( ps) => {
411411 let ch_bytes_len = <G :: Scalar as PrimeField >:: Repr :: default ( ) . as_ref ( ) . len ( ) ;
@@ -423,7 +423,7 @@ impl<G: PrimeGroup> SigmaProtocol for ComposedRelation<G> {
423423 challenges. push ( ch) ;
424424 responses. push ( r) ;
425425 }
426- Ok ( ProtocolResponse :: Or ( challenges, responses) )
426+ Ok ( ComposedResponse :: Or ( challenges, responses) )
427427 }
428428 }
429429 }
@@ -436,35 +436,35 @@ impl<G: PrimeGroup> SigmaProtocolSimulator for ComposedRelation<G> {
436436 response : & Self :: Response ,
437437 ) -> Result < Self :: Commitment , Error > {
438438 match ( self , response) {
439- ( ComposedRelation :: Simple ( p) , ProtocolResponse :: Simple ( r) ) => Ok (
440- ProtocolCommitment :: Simple ( p. simulate_commitment ( challenge, r) ?) ,
439+ ( ComposedRelation :: Simple ( p) , ComposedResponse :: Simple ( r) ) => Ok (
440+ ComposedCommitment :: Simple ( p. simulate_commitment ( challenge, r) ?) ,
441441 ) ,
442- ( ComposedRelation :: And ( ps) , ProtocolResponse :: And ( rs) ) => {
442+ ( ComposedRelation :: And ( ps) , ComposedResponse :: And ( rs) ) => {
443443 let commitments = ps
444444 . iter ( )
445445 . zip ( rs)
446446 . map ( |( p, r) | p. simulate_commitment ( challenge, r) )
447447 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
448- Ok ( ProtocolCommitment :: And ( commitments) )
448+ Ok ( ComposedCommitment :: And ( commitments) )
449449 }
450- ( ComposedRelation :: Or ( ps) , ProtocolResponse :: Or ( challenges, rs) ) => {
450+ ( ComposedRelation :: Or ( ps) , ComposedResponse :: Or ( challenges, rs) ) => {
451451 let commitments = ps
452452 . iter ( )
453453 . zip ( challenges)
454454 . zip ( rs)
455455 . map ( |( ( p, ch) , r) | p. simulate_commitment ( ch, r) )
456456 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
457- Ok ( ProtocolCommitment :: Or ( commitments) )
457+ Ok ( ComposedCommitment :: Or ( commitments) )
458458 }
459459 _ => panic ! ( ) ,
460460 }
461461 }
462462
463463 fn simulate_response < R : rand:: Rng + rand:: CryptoRng > ( & self , rng : & mut R ) -> Self :: Response {
464464 match self {
465- ComposedRelation :: Simple ( p) => ProtocolResponse :: Simple ( p. simulate_response ( rng) ) ,
465+ ComposedRelation :: Simple ( p) => ComposedResponse :: Simple ( p. simulate_response ( rng) ) ,
466466 ComposedRelation :: And ( ps) => {
467- ProtocolResponse :: And ( ps. iter ( ) . map ( |p| p. simulate_response ( rng) ) . collect ( ) )
467+ ComposedResponse :: And ( ps. iter ( ) . map ( |p| p. simulate_response ( rng) ) . collect ( ) )
468468 }
469469 ComposedRelation :: Or ( ps) => {
470470 let mut challenges = Vec :: with_capacity ( ps. len ( ) ) ;
@@ -475,7 +475,7 @@ impl<G: PrimeGroup> SigmaProtocolSimulator for ComposedRelation<G> {
475475 for p in ps. iter ( ) {
476476 responses. push ( p. simulate_response ( & mut * rng) ) ;
477477 }
478- ProtocolResponse :: Or ( challenges, responses)
478+ ComposedResponse :: Or ( challenges, responses)
479479 }
480480 }
481481 }
@@ -488,9 +488,9 @@ impl<G: PrimeGroup> SigmaProtocolSimulator for ComposedRelation<G> {
488488 ComposedRelation :: Simple ( p) => {
489489 let ( c, ch, r) = p. simulate_transcript ( rng) ?;
490490 Ok ( (
491- ProtocolCommitment :: Simple ( c) ,
491+ ComposedCommitment :: Simple ( c) ,
492492 ch,
493- ProtocolResponse :: Simple ( r) ,
493+ ComposedResponse :: Simple ( r) ,
494494 ) )
495495 }
496496 ComposedRelation :: And ( ps) => {
@@ -506,9 +506,9 @@ impl<G: PrimeGroup> SigmaProtocolSimulator for ComposedRelation<G> {
506506 . collect :: < Result < Vec < _ > , Error > > ( ) ?;
507507
508508 Ok ( (
509- ProtocolCommitment :: And ( commitments) ,
509+ ComposedCommitment :: And ( commitments) ,
510510 challenge,
511- ProtocolResponse :: And ( responses) ,
511+ ComposedResponse :: And ( responses) ,
512512 ) )
513513 }
514514 ComposedRelation :: Or ( ps) => {
@@ -524,9 +524,9 @@ impl<G: PrimeGroup> SigmaProtocolSimulator for ComposedRelation<G> {
524524 }
525525 let challenge = challenges. iter ( ) . sum ( ) ;
526526 Ok ( (
527- ProtocolCommitment :: Or ( commitments) ,
527+ ComposedCommitment :: Or ( commitments) ,
528528 challenge,
529- ProtocolResponse :: Or ( challenges, responses) ,
529+ ComposedResponse :: Or ( challenges, responses) ,
530530 ) )
531531 }
532532 }
0 commit comments