11#![ allow( non_snake_case) ]
2-
32#![ doc( include = "../docs/inner-product-protocol.md" ) ]
43
54use std:: borrow:: Borrow ;
@@ -8,10 +7,10 @@ use std::iter;
87use curve25519_dalek:: ristretto:: { CompressedRistretto , RistrettoPoint } ;
98use curve25519_dalek:: scalar:: Scalar ;
109use curve25519_dalek:: traits:: VartimeMultiscalarMul ;
11-
12- use proof_transcript:: ProofTranscript ;
10+ use merlin:: Transcript ;
1311
1412use errors:: ProofError ;
13+ use transcript:: TranscriptProtocol ;
1514
1615#[ derive( Clone , Debug ) ]
1716pub struct InnerProductProof {
@@ -34,7 +33,7 @@ impl InnerProductProof {
3433 /// The lengths of the vectors must all be the same, and must all be
3534 /// either 0 or a power of 2.
3635 pub fn create < I > (
37- verifier : & mut ProofTranscript ,
36+ transcript : & mut Transcript ,
3837 Q : & RistrettoPoint ,
3938 Hprime_factors : I ,
4039 mut G_vec : Vec < RistrettoPoint > ,
@@ -65,6 +64,8 @@ impl InnerProductProof {
6564 // All of the input vectors must have a length that is a power of two.
6665 assert ! ( n. is_power_of_two( ) ) ;
6766
67+ transcript. innerproduct_domain_sep ( n as u64 ) ;
68+
6869 // XXX save these scalar mults by unrolling them into the
6970 // first iteration of the loop below
7071 for ( H_i , h_i) in H . iter_mut ( ) . zip ( Hprime_factors . into_iter ( ) ) {
@@ -88,20 +89,20 @@ impl InnerProductProof {
8889 let L = RistrettoPoint :: vartime_multiscalar_mul (
8990 a_L. iter ( ) . chain ( b_R. iter ( ) ) . chain ( iter:: once ( & c_L) ) ,
9091 G_R . iter ( ) . chain ( H_L . iter ( ) ) . chain ( iter:: once ( Q ) ) ,
91- ) ;
92+ ) . compress ( ) ;
9293
9394 let R = RistrettoPoint :: vartime_multiscalar_mul (
9495 a_R. iter ( ) . chain ( b_L. iter ( ) ) . chain ( iter:: once ( & c_R) ) ,
9596 G_L . iter ( ) . chain ( H_R . iter ( ) ) . chain ( iter:: once ( Q ) ) ,
96- ) ;
97+ ) . compress ( ) ;
9798
98- L_vec . push ( L . compress ( ) ) ;
99- R_vec . push ( R . compress ( ) ) ;
99+ L_vec . push ( L ) ;
100+ R_vec . push ( R ) ;
100101
101- verifier . commit ( L . compress ( ) . as_bytes ( ) ) ;
102- verifier . commit ( R . compress ( ) . as_bytes ( ) ) ;
102+ transcript . commit_point ( b"L" , & L ) ;
103+ transcript . commit_point ( b"R" , & R ) ;
103104
104- let u = verifier . challenge_scalar ( ) ;
105+ let u = transcript . challenge_scalar ( b"u" ) ;
105106 let u_inv = u. invert ( ) ;
106107
107108 for i in 0 ..n {
@@ -129,18 +130,20 @@ impl InnerProductProof {
129130 /// in a parent protocol. See [inner product protocol notes](index.html#verification-equation) for details.
130131 pub ( crate ) fn verification_scalars (
131132 & self ,
132- transcript : & mut ProofTranscript ,
133+ transcript : & mut Transcript ,
133134 ) -> ( Vec < Scalar > , Vec < Scalar > , Vec < Scalar > ) {
134135 let lg_n = self . L_vec . len ( ) ;
135136 let n = 1 << lg_n;
136137
138+ transcript. innerproduct_domain_sep ( n as u64 ) ;
139+
137140 // 1. Recompute x_k,...,x_1 based on the proof transcript
138141
139142 let mut challenges = Vec :: with_capacity ( lg_n) ;
140143 for ( L , R ) in self . L_vec . iter ( ) . zip ( self . R_vec . iter ( ) ) {
141- transcript. commit ( L . as_bytes ( ) ) ;
142- transcript. commit ( R . as_bytes ( ) ) ;
143- challenges. push ( transcript. challenge_scalar ( ) ) ;
144+ transcript. commit_point ( b"L" , L ) ;
145+ transcript. commit_point ( b"R" , R ) ;
146+ challenges. push ( transcript. challenge_scalar ( b"u" ) ) ;
144147 }
145148
146149 // 2. Compute 1/(u_k...u_1) and 1/u_k, ..., 1/u_1
@@ -181,7 +184,7 @@ impl InnerProductProof {
181184 #[ allow( dead_code) ]
182185 pub fn verify < I > (
183186 & self ,
184- transcript : & mut ProofTranscript ,
187+ transcript : & mut Transcript ,
185188 Hprime_factors : I ,
186189 P : & RistrettoPoint ,
187190 Q : & RistrettoPoint ,
@@ -362,7 +365,7 @@ mod tests {
362365 G . iter ( ) . chain ( H . iter ( ) ) . chain ( iter:: once ( & Q ) ) ,
363366 ) ;
364367
365- let mut verifier = ProofTranscript :: new ( b"innerproducttest" ) ;
368+ let mut verifier = Transcript :: new ( b"innerproducttest" ) ;
366369 let proof = InnerProductProof :: create (
367370 & mut verifier,
368371 & Q ,
@@ -373,15 +376,15 @@ mod tests {
373376 b. clone ( ) ,
374377 ) ;
375378
376- let mut verifier = ProofTranscript :: new ( b"innerproducttest" ) ;
379+ let mut verifier = Transcript :: new ( b"innerproducttest" ) ;
377380 assert ! (
378381 proof
379382 . verify( & mut verifier, util:: exp_iter( y_inv) , & P , & Q , & G , & H )
380383 . is_ok( )
381384 ) ;
382385
383386 let proof = InnerProductProof :: from_bytes ( proof. to_bytes ( ) . as_slice ( ) ) . unwrap ( ) ;
384- let mut verifier = ProofTranscript :: new ( b"innerproducttest" ) ;
387+ let mut verifier = Transcript :: new ( b"innerproducttest" ) ;
385388 assert ! (
386389 proof
387390 . verify( & mut verifier, util:: exp_iter( y_inv) , & P , & Q , & G , & H )
0 commit comments