@@ -5,8 +5,8 @@ use super::math::Math;
5
5
use super :: nizk:: { DotProductProofGens , DotProductProofLog } ;
6
6
use super :: random:: RandomTape ;
7
7
use super :: transcript:: { AppendToTranscript , ProofTranscript } ;
8
- use ark_ec:: msm :: VariableBaseMSM ;
9
- use ark_ec:: ProjectiveCurve ;
8
+ use ark_ec:: CurveGroup ;
9
+ use ark_ec:: VariableBaseMSM ;
10
10
use ark_ff:: PrimeField ;
11
11
use ark_serialize:: * ;
12
12
use ark_std:: Zero ;
@@ -27,7 +27,7 @@ pub struct PolyCommitmentGens<G> {
27
27
pub gens : DotProductProofGens < G > ,
28
28
}
29
29
30
- impl < G : ProjectiveCurve > PolyCommitmentGens < G > {
30
+ impl < G : CurveGroup > PolyCommitmentGens < G > {
31
31
// the number of variables in the multilinear polynomial
32
32
pub fn new ( num_vars : usize , label : & ' static [ u8 ] ) -> Self {
33
33
let ( _left, right) = EqPolynomial :: < G :: ScalarField > :: compute_factored_lens ( num_vars) ;
@@ -41,12 +41,12 @@ pub struct PolyCommitmentBlinds<F> {
41
41
}
42
42
43
43
#[ derive( Debug , CanonicalSerialize , CanonicalDeserialize ) ]
44
- pub struct PolyCommitment < G : ProjectiveCurve > {
44
+ pub struct PolyCommitment < G : CurveGroup > {
45
45
C : Vec < G > ,
46
46
}
47
47
48
48
#[ derive( Debug , CanonicalSerialize , CanonicalDeserialize ) ]
49
- pub struct ConstPolyCommitment < G : ProjectiveCurve > {
49
+ pub struct ConstPolyCommitment < G : CurveGroup > {
50
50
C : G ,
51
51
}
52
52
@@ -163,7 +163,7 @@ impl<F: PrimeField> DensePolynomial<F> {
163
163
}
164
164
165
165
#[ cfg( not( feature = "multicore" ) ) ]
166
- fn commit_inner < G : ProjectiveCurve < ScalarField = F > > (
166
+ fn commit_inner < G : CurveGroup < ScalarField = F > > (
167
167
& self ,
168
168
blinds : & [ F ] ,
169
169
gens : & MultiCommitGens < G > ,
@@ -189,7 +189,7 @@ impl<F: PrimeField> DensePolynomial<F> {
189
189
random_tape : Option < & mut RandomTape < G > > ,
190
190
) -> ( PolyCommitment < G > , PolyCommitmentBlinds < F > )
191
191
where
192
- G : ProjectiveCurve < ScalarField = F > ,
192
+ G : CurveGroup < ScalarField = F > ,
193
193
{
194
194
let n = self . Z . len ( ) ;
195
195
let ell = self . get_num_vars ( ) ;
@@ -244,7 +244,7 @@ impl<F: PrimeField> DensePolynomial<F> {
244
244
// returns Z(r) in O(n) time
245
245
pub fn evaluate < G > ( & self , r : & [ F ] ) -> F
246
246
where
247
- G : ProjectiveCurve < ScalarField = F > ,
247
+ G : CurveGroup < ScalarField = F > ,
248
248
{
249
249
// r must have a value for each variable
250
250
assert_eq ! ( r. len( ) , self . get_num_vars( ) ) ;
@@ -298,7 +298,7 @@ impl<F> Index<usize> for DensePolynomial<F> {
298
298
}
299
299
}
300
300
301
- impl < G : ProjectiveCurve > AppendToTranscript < G > for PolyCommitment < G > {
301
+ impl < G : CurveGroup > AppendToTranscript < G > for PolyCommitment < G > {
302
302
fn append_to_transcript ( & self , label : & ' static [ u8 ] , transcript : & mut Transcript ) {
303
303
transcript. append_message ( label, b"poly_commitment_begin" ) ;
304
304
for i in 0 ..self . C . len ( ) {
@@ -309,11 +309,11 @@ impl<G: ProjectiveCurve> AppendToTranscript<G> for PolyCommitment<G> {
309
309
}
310
310
311
311
#[ derive( Debug , CanonicalSerialize , CanonicalDeserialize ) ]
312
- pub struct PolyEvalProof < G : ProjectiveCurve > {
312
+ pub struct PolyEvalProof < G : CurveGroup > {
313
313
proof : DotProductProofLog < G > ,
314
314
}
315
315
316
- impl < G : ProjectiveCurve > PolyEvalProof < G > {
316
+ impl < G : CurveGroup > PolyEvalProof < G > {
317
317
fn protocol_name ( ) -> & ' static [ u8 ] {
318
318
b"polynomial evaluation proof"
319
319
}
@@ -395,10 +395,9 @@ impl<G: ProjectiveCurve> PolyEvalProof<G> {
395
395
let ( L , R ) = eq. compute_factored_evals ( ) ;
396
396
397
397
// compute a weighted sum of commitments and L
398
- let C_affine = G :: batch_normalization_into_affine ( & comm. C ) ;
398
+ let C_affine = G :: normalize_batch ( & comm. C ) ;
399
399
400
- let L_repr = L . iter ( ) . map ( |x| x. into_repr ( ) ) . collect :: < Vec < _ > > ( ) ;
401
- let C_LZ = VariableBaseMSM :: multi_scalar_mul ( C_affine . as_ref ( ) , L_repr . as_ref ( ) ) ;
400
+ let C_LZ = VariableBaseMSM :: msm ( C_affine . as_ref ( ) , L . as_ref ( ) ) . unwrap ( ) ;
402
401
403
402
self
404
403
. proof
@@ -429,10 +428,7 @@ mod tests {
429
428
use ark_std:: One ;
430
429
use ark_std:: UniformRand ;
431
430
432
- fn evaluate_with_LR < G : ProjectiveCurve > (
433
- Z : & [ G :: ScalarField ] ,
434
- r : & [ G :: ScalarField ] ,
435
- ) -> G :: ScalarField {
431
+ fn evaluate_with_LR < G : CurveGroup > ( Z : & [ G :: ScalarField ] , r : & [ G :: ScalarField ] ) -> G :: ScalarField {
436
432
let eq = EqPolynomial :: < G :: ScalarField > :: new ( r. to_vec ( ) ) ;
437
433
let ( L , R ) = eq. compute_factored_evals ( ) ;
438
434
@@ -458,7 +454,7 @@ mod tests {
458
454
check_polynomial_evaluation_helper :: < G1Projective > ( )
459
455
}
460
456
461
- fn check_polynomial_evaluation_helper < G : ProjectiveCurve > ( ) {
457
+ fn check_polynomial_evaluation_helper < G : CurveGroup > ( ) {
462
458
// Z = [1, 2, 1, 4]
463
459
let Z = vec ! [
464
460
G :: ScalarField :: one( ) ,
@@ -551,7 +547,7 @@ mod tests {
551
547
check_memoized_chis_helper :: < G1Projective > ( )
552
548
}
553
549
554
- fn check_memoized_chis_helper < G : ProjectiveCurve > ( ) {
550
+ fn check_memoized_chis_helper < G : CurveGroup > ( ) {
555
551
let mut prng = test_rng ( ) ;
556
552
557
553
let s = 10 ;
@@ -608,7 +604,7 @@ mod tests {
608
604
check_polynomial_commit_helper :: < G1Projective > ( )
609
605
}
610
606
611
- fn check_polynomial_commit_helper < G : ProjectiveCurve > ( ) {
607
+ fn check_polynomial_commit_helper < G : CurveGroup > ( ) {
612
608
let Z = vec ! [
613
609
G :: ScalarField :: one( ) ,
614
610
G :: ScalarField :: from( 2u64 ) ,
0 commit comments