@@ -275,6 +275,8 @@ func (p *rangeProver) preprocess() ([]*math.Zr, []*math.Zr, *math.Zr, *RangeProo
275275 }
276276 rho := p .Curve .NewRandomZr (rand )
277277 eta := p .Curve .NewRandomZr (rand )
278+ one := p .Curve .NewZrFromInt (1 )
279+ two := p .Curve .NewZrFromInt (2 )
278280 for i := range p .BitLength {
279281 b := 1 << i & p .value
280282 if b > 0 {
@@ -283,7 +285,7 @@ func (p *rangeProver) preprocess() ([]*math.Zr, []*math.Zr, *math.Zr, *RangeProo
283285 // this is an array of the bits b_i of p.value
284286 left [i ] = p .Curve .NewZrFromUint64 (b )
285287 // this is an array of b_i - 1
286- right [i ] = p .Curve .ModSub (left [i ], p . Curve . NewZrFromInt ( 1 ) , p .Curve .GroupOrder )
288+ right [i ] = p .Curve .ModSub (left [i ], one , p .Curve .GroupOrder )
287289 // these are randomly generated arrays
288290 randomLeft [i ] = p .Curve .NewRandomZr (rand )
289291 randomRight [i ] = p .Curve .NewRandomZr (rand )
@@ -315,7 +317,7 @@ func (p *rangeProver) preprocess() ([]*math.Zr, []*math.Zr, *math.Zr, *RangeProo
315317
316318 zPrime := make ([]* math.Zr , len (left ))
317319 // z^2
318- zSquare := z .PowMod (p . Curve . NewZrFromInt ( 2 ) )
320+ zSquare := z .PowMod (two )
319321 var y2i * math.Zr
320322 for i := range left {
321323 // compute L_i - z
@@ -324,7 +326,7 @@ func (p *rangeProver) preprocess() ([]*math.Zr, []*math.Zr, *math.Zr, *RangeProo
324326 rightPrime [i ] = p .Curve .ModAdd (right [i ], z , p .Curve .GroupOrder )
325327 // compute y^i
326328 if i == 0 {
327- y2i = p . Curve . NewZrFromInt ( 1 )
329+ y2i = one
328330 } else {
329331 y2i = p .Curve .ModMul (y , y2i , p .Curve .GroupOrder )
330332 }
@@ -333,7 +335,7 @@ func (p *rangeProver) preprocess() ([]*math.Zr, []*math.Zr, *math.Zr, *RangeProo
333335 // compute V_iy^i
334336 randRightPrime [i ] = p .Curve .ModMul (randomRight [i ], y2i , p .Curve .GroupOrder )
335337 // compute 2^iz^2
336- zPrime [i ] = p .Curve .ModMul (zSquare , p . Curve . NewZrFromInt ( 2 ) .PowMod (p .Curve .NewZrFromInt (int64 (i ))), p .Curve .GroupOrder )
338+ zPrime [i ] = p .Curve .ModMul (zSquare , two .PowMod (p .Curve .NewZrFromInt (int64 (i ))), p .Curve .GroupOrder )
337339 }
338340
339341 // compute \sum y^iV_i(L_i-z)
@@ -344,15 +346,13 @@ func (p *rangeProver) preprocess() ([]*math.Zr, []*math.Zr, *math.Zr, *RangeProo
344346 t1 = p .Curve .ModAdd (t1 , InnerProduct (zPrime , randomLeft , p .Curve ), p .Curve .GroupOrder )
345347 // commit to t1
346348 tau1 := p .Curve .NewRandomZr (rand )
347- T1 := p .CommitmentGenerators [0 ].Mul (t1 )
348- T1 .Add (p .CommitmentGenerators [1 ].Mul (tau1 ))
349+ T1 := p .CommitmentGenerators [0 ].Mul2 (t1 , p .CommitmentGenerators [1 ], tau1 )
349350
350351 // compute = \sum y^iU_iV_i
351352 t2 := InnerProduct (randomLeft , randRightPrime , p .Curve )
352353 // commit to t2
353354 tau2 := p .Curve .NewRandomZr (rand )
354- T2 := p .CommitmentGenerators [0 ].Mul (t2 )
355- T2 .Add (p .CommitmentGenerators [1 ].Mul (tau2 ))
355+ T2 := p .CommitmentGenerators [0 ].Mul2 (t2 , p .CommitmentGenerators [1 ], tau2 )
356356
357357 // compute challenge x
358358 array = common .GetG1Array ([]* math.G1 {T1 , T2 })
@@ -368,14 +368,14 @@ func (p *rangeProver) preprocess() ([]*math.Zr, []*math.Zr, *math.Zr, *RangeProo
368368 // f(z, y) = \sum (z-z^2)*y^i - z^3*2^i
369369 for i := 0 ; i < len (left ); i ++ {
370370 // compute (L_i-z) + xU_i
371- left [i ] = p .Curve .ModAdd (leftPrime [i ], p . Curve . ModMul ( x , randomLeft [i ], p . Curve . GroupOrder ) , p .Curve .GroupOrder )
371+ left [i ] = p .Curve .ModAddMul2 (leftPrime [i ], one , x , randomLeft [i ], p .Curve .GroupOrder )
372372 // compute y^i((R_i+z)+xV_i)+2^iz^2
373373 right [i ] = p .Curve .ModAdd (rightPrime [i ], p .Curve .ModMul (x , randRightPrime [i ], p .Curve .GroupOrder ), p .Curve .GroupOrder )
374374 right [i ] = p .Curve .ModAdd (right [i ], zPrime [i ], p .Curve .GroupOrder )
375375 }
376376 // tau = t1x + t2x^2 + z^2p.blindingFactor
377377 tau := p .Curve .ModMul (x , tau1 , p .Curve .GroupOrder )
378- tau = p .Curve .ModAdd (tau , p .Curve .ModMul (tau2 , x .PowMod (p . Curve . NewZrFromInt ( 2 ) ), p .Curve .GroupOrder ), p .Curve .GroupOrder )
378+ tau = p .Curve .ModAdd (tau , p .Curve .ModMul (tau2 , x .PowMod (two ), p .Curve .GroupOrder ), p .Curve .GroupOrder )
379379 tau = p .Curve .ModAdd (tau , p .Curve .ModMul (zSquare , p .blindingFactor , p .Curve .GroupOrder ), p .Curve .GroupOrder )
380380
381381 // delta = rho + eta*x
0 commit comments