@@ -18,7 +18,7 @@ use crate::{
18
18
traits:: {
19
19
commitment:: { CommitmentEngineTrait , CommitmentTrait } ,
20
20
evaluation:: EvaluationEngineTrait ,
21
- Group , ROTrait , TranscriptEngineTrait ,
21
+ AbsorbInROTrait , Group , ROTrait , TranscriptEngineTrait ,
22
22
} ,
23
23
Commitment , CommitmentKey , CompressedCommitment ,
24
24
} ;
@@ -83,7 +83,6 @@ impl<G: Group, EE: EvaluationEngineTrait<G>> VerifierKey<G, EE> {
83
83
84
84
impl < G : Group , EE : EvaluationEngineTrait < G > > SimpleDigestible for VerifierKey < G , EE > { }
85
85
86
- #[ allow( unused) ]
87
86
/// LookupSNARK
88
87
pub struct LookupSNARK < G : Group , EE : EvaluationEngineTrait < G > > {
89
88
a : PhantomData < ( G , EE ) > ,
@@ -187,8 +186,6 @@ where
187
186
final_table. iter ( ) . map ( |( _, value, _) | * value) . collect ( ) ;
188
187
let final_counters: Vec < <G as Group >:: Scalar > =
189
188
final_table. iter ( ) . map ( |( _, _, counter) | * counter) . collect ( ) ;
190
- // TODO add comm_final_value, comm_final_counter to gamma challange
191
- // which means we need to move final_values, final_counters commitment at earlier
192
189
let comm_init_value = pk. comm_init_value ;
193
190
let ( comm_final_value, comm_final_counter) = rayon:: join (
194
191
|| G :: CE :: commit ( ck, & final_values) ,
@@ -560,7 +557,6 @@ where
560
557
} )
561
558
}
562
559
563
- #[ allow( unused) ]
564
560
fn verify_challenge < G2 : Group > (
565
561
comm_final_value : <<G as Group >:: CE as CommitmentEngineTrait < G > >:: Commitment ,
566
562
comm_final_counter : <<G as Group >:: CE as CommitmentEngineTrait < G > >:: Commitment ,
@@ -571,35 +567,19 @@ where
571
567
G : Group < Base = <G2 as Group >:: Scalar > ,
572
568
G2 : Group < Base = <G as Group >:: Scalar > ,
573
569
{
574
- // verify fingerprint
575
- let ro_consts = <<G2 as Group >:: RO as ROTrait <
576
- <G2 as Group >:: Base ,
577
- <G2 as Group >:: Scalar ,
578
- > >:: Constants :: default ( ) ;
579
-
580
- let (
581
- ( comm_final_value_cordx, comm_final_value_cordy, comm_final_value_infinity) ,
582
- ( comm_final_counter_cordx, comm_final_counter_cordy, comm_final_counter_infinity) ,
583
- ) = rayon:: join (
584
- || comm_final_value. to_coordinates ( ) ,
585
- || comm_final_counter. to_coordinates ( ) ,
586
- ) ;
570
+ // verify fingerprint challenge
571
+ let ro_consts =
572
+ <<G as Group >:: RO as ROTrait < <G as Group >:: Base , <G as Group >:: Scalar > >:: Constants :: default ( ) ;
573
+
574
+ // final_value and final_counter
587
575
588
- let mut hasher = <G2 as Group >:: RO :: new ( ro_consts, 7 ) ;
576
+ let mut hasher = <G as Group >:: RO :: new ( ro_consts, 7 ) ;
577
+ let fingerprint_intermediate_gamma: G2 :: Scalar =
578
+ scalar_as_base :: < G > ( fingerprint_intermediate_gamma) ;
589
579
hasher. absorb ( fingerprint_intermediate_gamma) ;
590
- hasher. absorb ( scalar_as_base :: < G2 > ( comm_final_value_cordx) ) ;
591
- hasher. absorb ( scalar_as_base :: < G2 > ( comm_final_value_cordy) ) ;
592
- hasher. absorb ( scalar_as_base :: < G2 > ( G2 :: Scalar :: from ( u64:: from (
593
- comm_final_value_infinity,
594
- ) ) ) ) ;
595
- hasher. absorb ( scalar_as_base :: < G2 > ( comm_final_counter_cordx) ) ;
596
- hasher. absorb ( scalar_as_base :: < G2 > ( comm_final_counter_cordy) ) ;
597
- hasher. absorb ( scalar_as_base :: < G2 > ( G2 :: Scalar :: from ( u64:: from (
598
- comm_final_counter_infinity,
599
- ) ) ) ) ;
600
-
601
- let hash_bits = hasher. squeeze ( NUM_CHALLENGE_BITS ) ;
602
- let computed_gamma = scalar_as_base :: < G2 > ( hash_bits) ;
580
+ comm_final_value. absorb_in_ro ( & mut hasher) ;
581
+ comm_final_counter. absorb_in_ro ( & mut hasher) ;
582
+ let computed_gamma = hasher. squeeze ( NUM_CHALLENGE_BITS ) ;
603
583
if fingerprint_gamma != computed_gamma {
604
584
println ! (
605
585
"fingerprint_gamma {:?} != computed_gamma {:?},,,fingerprint_intermediate_gamma" ,
@@ -614,7 +594,7 @@ where
614
594
pub fn verify < G2 : Group > (
615
595
& self ,
616
596
vk : & VerifierKey < G , EE > ,
617
- _fingerprint_intermediate_gamma : G :: Scalar ,
597
+ fingerprint_intermediate_gamma : G :: Scalar ,
618
598
fingerprint_gamma : G :: Scalar ,
619
599
) -> Result < ( ) , NovaError >
620
600
where
@@ -625,12 +605,12 @@ where
625
605
let comm_final_counter = Commitment :: < G > :: decompress ( & self . comm_final_counter ) ?;
626
606
627
607
// TODO enable verify challenge
628
- // Self::verify_challenge::<G2>(
629
- // comm_final_value,
630
- // comm_final_counter,
631
- // fingerprint_intermediate_gamma,
632
- // fingerprint_gamma,
633
- // )?;
608
+ Self :: verify_challenge :: < G2 > (
609
+ comm_final_value,
610
+ comm_final_counter,
611
+ fingerprint_intermediate_gamma,
612
+ fingerprint_gamma,
613
+ ) ?;
634
614
635
615
let mut transcript = G :: TE :: new ( b"LookupSNARK" ) ;
636
616
let mut u_vec: Vec < PolyEvalInstance < G > > = Vec :: new ( ) ;
0 commit comments