@@ -12,33 +12,34 @@ fn test_composition_example() {
1212 // Composition and verification of proof for the following protocol :
1313 //
1414 // And(
15- // Or( dleq, pedersen_commitment ),
16- // Simple( discrete_logarithm ),
17- // And( pedersen_commitment_dleq, bbs_blind_commitment_computation )
15+ // Or(dleq, pedersen_commitment),
16+ // Simple(discrete_logarithm),
17+ // And(pedersen_commitment_dleq, bbs_blind_commitment_computation)
1818 // )
1919 let domain_sep = b"hello world" ;
2020
2121 // definitions of the underlying protocols
2222 let mut rng = rand:: thread_rng ( ) ;
23- let ( relation1 , witness1) = dleq ( & mut rng) ;
24- let ( relation2 , witness2) = pedersen_commitment ( & mut rng) ;
25- let ( relation3 , witness3) = discrete_logarithm ( & mut rng) ;
26- let ( relation4 , witness4) = pedersen_commitment_dleq ( & mut rng) ;
27- let ( relation5 , witness5) = bbs_blind_commitment ( & mut rng) ;
23+ let ( instance1 , witness1) = dleq :: < G , _ > ( & mut rng) ;
24+ let ( instance2 , witness2) = pedersen_commitment :: < G , _ > ( & mut rng) ;
25+ let ( instance3 , witness3) = discrete_logarithm :: < G , _ > ( & mut rng) ;
26+ let ( instance4 , witness4) = pedersen_commitment_dleq :: < G , _ > ( & mut rng) ;
27+ let ( instance5 , witness5) = bbs_blind_commitment :: < G , _ > ( & mut rng) ;
2828
2929 let wrong_witness2 = ( 0 ..witness2. len ( ) )
3030 . map ( |_| <G as Group >:: Scalar :: random ( & mut rng) )
3131 . collect :: < Vec < _ > > ( ) ;
3232 // second layer protocol definitions
33- let or_protocol1 = ComposedRelation :: < G > :: or ( [ relation1 , relation2 ] ) ;
33+ let or_protocol1 = ComposedRelation :: or ( [ instance1 , instance2 ] ) ;
3434 let or_witness1 = ComposedWitness :: or ( [ witness1, wrong_witness2] ) ;
3535
36- let and_protocol1 = ComposedRelation :: and ( [ relation4 , relation5 ] ) ;
36+ let and_protocol1 = ComposedRelation :: and ( [ instance4 , instance5 ] ) ;
3737 let and_witness1 = ComposedWitness :: and ( [ witness4, witness5] ) ;
3838
3939 // definition of the final protocol
40- let instance = ComposedRelation :: and ( [ or_protocol1, relation3. into ( ) , and_protocol1] ) ;
41- let witness = ComposedWitness :: and ( [ or_witness1, witness3. into ( ) , and_witness1] ) ;
40+ let instance =
41+ ComposedRelation :: and ( [ or_protocol1, instance3. try_into ( ) , and_protocol1] ) . unwrap ( ) ;
42+ let witness = ComposedWitness :: and ( [ or_witness1, witness3. try_into ( ) . unwrap ( ) , and_witness1] ) ;
4243
4344 let nizk = instance. into_nizk ( domain_sep) ;
4445
@@ -67,13 +68,13 @@ fn test_or_one_true() {
6768 . map ( |_| <G as Group >:: Scalar :: random ( & mut rng) )
6869 . collect :: < Vec < _ > > ( ) ;
6970
70- let or_protocol = ComposedRelation :: or ( [ relation1, relation2] ) ;
71+ let or_instance = ComposedRelation :: or ( [ relation1, relation2] ) . unwrap ( ) ;
7172
7273 // Construct two witnesses to the protocol, the first and then the second as the true branch.
7374 let witness_or_1 = ComposedWitness :: or ( [ witness1, wrong_witness2] ) ;
7475 let witness_or_2 = ComposedWitness :: or ( [ wrong_witness1, witness2] ) ;
7576
76- let nizk = or_protocol . into_nizk ( b"test_or_one_true" ) ;
77+ let nizk = or_instance . into_nizk ( b"test_or_one_true" ) ;
7778
7879 for witness in [ witness_or_1, witness_or_2] {
7980 // Batchable and compact proofs
@@ -95,7 +96,7 @@ fn test_or_both_true() {
9596 let ( relation1, witness1) = dleq :: < G , _ > ( & mut rng) ;
9697 let ( relation2, witness2) = dleq :: < G , _ > ( & mut rng) ;
9798
98- let or_protocol = ComposedRelation :: or ( [ relation1, relation2] ) ;
99+ let or_protocol = ComposedRelation :: or ( [ relation1, relation2] ) . unwrap ( ) ;
99100
100101 let witness = ComposedWitness :: or ( [ witness1, witness2] ) ;
101102 let nizk = or_protocol. into_nizk ( b"test_or_both_true" ) ;
0 commit comments