@@ -189,7 +189,7 @@ where
189
189
}
190
190
191
191
debug_assert_eq ! ( Self :: commit( pp, poly) . unwrap( ) . 0 , comm. 0 ) ;
192
- debug_assert_eq ! ( poly. evaluate_BE ( point) , eval. 0 ) ;
192
+ debug_assert_eq ! ( poly. evaluate ( point) , eval. 0 ) ;
193
193
194
194
let ( quotients, remainder) = quotients ( poly, point) ;
195
195
debug_assert_eq ! ( remainder, eval. 0 ) ;
@@ -325,15 +325,15 @@ where
325
325
/// (n - k) variables at, respectively, point'' = (point_k + 1, point_{k+1}, ..., point_{n-1}) and
326
326
/// point' = (point_k, ..., point_{n-1}).
327
327
fn quotients < F : PrimeField > ( poly : & MultilinearPolynomial < F > , point : & [ F ] ) -> ( Vec < Vec < F > > , F ) {
328
- assert_eq ! ( poly. get_num_vars( ) , point. len( ) ) ;
328
+ let num_var = poly. get_num_vars ( ) ;
329
+ assert_eq ! ( num_var, point. len( ) ) ;
329
330
330
331
let mut remainder = poly. Z . to_vec ( ) ;
331
332
let mut quotients = point
332
- . iter ( )
333
+ . iter ( ) // assume polynomial variables come in LE form
333
334
. enumerate ( )
334
- . rev ( )
335
- . map ( |( num_var, x_i) | {
336
- let ( remainder_lo, remainder_hi) = remainder. split_at_mut ( 1 << num_var) ;
335
+ . map ( |( idx, x_i) | {
336
+ let ( remainder_lo, remainder_hi) = remainder. split_at_mut ( 1 << ( num_var - 1 - idx) ) ;
337
337
let mut quotient = vec ! [ F :: ZERO ; remainder_lo. len( ) ] ;
338
338
339
339
quotient
@@ -350,7 +350,7 @@ fn quotients<F: PrimeField>(poly: &MultilinearPolynomial<F>, point: &[F]) -> (Ve
350
350
* r_lo += ( * r_hi - r_lo as & _ ) * x_i;
351
351
} ) ;
352
352
353
- remainder. truncate ( 1 << num_var) ;
353
+ remainder. truncate ( 1 << ( num_var - 1 - idx ) ) ;
354
354
355
355
quotient
356
356
} )
@@ -361,8 +361,8 @@ fn quotients<F: PrimeField>(poly: &MultilinearPolynomial<F>, point: &[F]) -> (Ve
361
361
}
362
362
363
363
// TODO : move this somewhere else
364
- fn eval_and_quotient_scalars < F : Field > ( y : F , x : F , z : F , u : & [ F ] ) -> ( F , Vec < F > ) {
365
- let num_vars = u . len ( ) ;
364
+ fn eval_and_quotient_scalars < F : Field > ( y : F , x : F , z : F , point : & [ F ] ) -> ( F , Vec < F > ) {
365
+ let num_vars = point . len ( ) ;
366
366
367
367
let squares_of_x = iter:: successors ( Some ( x) , |& x| Some ( x. square ( ) ) )
368
368
. take ( num_vars + 1 )
@@ -397,7 +397,7 @@ fn eval_and_quotient_scalars<F: Field>(y: F, x: F, z: F, u: &[F]) -> (F, Vec<F>)
397
397
. zip ( squares_of_x)
398
398
. zip ( & vs)
399
399
. zip ( & vs[ 1 ..] )
400
- . zip ( u )
400
+ . zip ( point . iter ( ) . rev ( ) ) // assume variables come in LE form
401
401
. map (
402
402
|( ( ( ( ( power_of_y, offset_of_x) , square_of_x) , v_i) , v_j) , u_i) | {
403
403
-( power_of_y * offset_of_x + z * ( square_of_x * v_j - * u_i * v_i) )
@@ -437,18 +437,8 @@ where
437
437
// TODO: the following two lines will need to change base
438
438
let polynomial = MultilinearPolynomial :: new ( poly. to_vec ( ) ) ;
439
439
440
- // Nova evaluates in lower endian, the implementation assumes big endian
441
- let rev_point = point. iter ( ) . rev ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
442
-
443
440
let evaluation = ZMEvaluation ( * eval) ;
444
- ZMPCS :: open (
445
- pk,
446
- & commitment,
447
- & polynomial,
448
- & rev_point,
449
- & evaluation,
450
- transcript,
451
- )
441
+ ZMPCS :: open ( pk, & commitment, & polynomial, point, & evaluation, transcript)
452
442
}
453
443
454
444
fn verify (
@@ -462,18 +452,8 @@ where
462
452
let commitment = ZMCommitment :: from ( UVKZGCommitment :: from ( * comm) ) ;
463
453
let evaluation = ZMEvaluation ( * eval) ;
464
454
465
- // Nova evaluates in lower endian, the implementation assumes big endian
466
- let rev_point = point. iter ( ) . rev ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
467
-
468
455
// TODO: this clone is unsightly!
469
- ZMPCS :: verify (
470
- vk,
471
- transcript,
472
- & commitment,
473
- & rev_point,
474
- & evaluation,
475
- arg. clone ( ) ,
476
- ) ?;
456
+ ZMPCS :: verify ( vk, transcript, & commitment, point, & evaluation, arg. clone ( ) ) ?;
477
457
Ok ( ( ) )
478
458
}
479
459
}
@@ -527,7 +507,7 @@ mod test {
527
507
let point = iter:: from_fn ( || transcript. squeeze ( b"pt" ) . ok ( ) )
528
508
. take ( num_vars)
529
509
. collect :: < Vec < _ > > ( ) ;
530
- let eval = ZMEvaluation ( poly. evaluate_BE ( & point) ) ;
510
+ let eval = ZMEvaluation ( poly. evaluate ( & point) ) ;
531
511
532
512
let mut transcript_prover = Keccak256Transcript :: < E :: G1 > :: new ( b"test" ) ;
533
513
let proof = ZMPCS :: open ( & pp, & comm, & poly, & point, & eval, & mut transcript_prover) . unwrap ( ) ;
@@ -577,11 +557,11 @@ mod test {
577
557
}
578
558
let ( _quotients, remainder) = quotients ( & poly, & point) ;
579
559
assert_eq ! (
580
- poly. evaluate_BE ( & point) ,
560
+ poly. evaluate ( & point) ,
581
561
remainder,
582
562
"point: {:?}, \n eval: {:?}, remainder:{:?}" ,
583
563
point,
584
- poly. evaluate_BE ( & point) ,
564
+ poly. evaluate ( & point) ,
585
565
remainder
586
566
) ;
587
567
}
0 commit comments