@@ -40,13 +40,18 @@ pub(crate) const PROTOCOL_NAME: &[u8] = b"AS-FOR-R1CS-NARK-2020";
4040/// Size of squeezed challenges in terms of number of bits.
4141pub ( self ) const CHALLENGE_SIZE : usize = 128 ;
4242
43- /// An accumulation scheme for a NARK for R1CS.
44- /// This implementation is specialized for [`r1cs_nark`].
45- /// The construction is described in detail in Section 9 of [\[BCLMS20\]][bclms20].
43+ /// An accumulation scheme for a NARK for R1CS, specialized for [`r1cs_nark`].
44+ /// The construction is described in detail in Section 8 of [\[BCLMS20\]][bclms20].
45+ ///
46+ /// The implementation differs from the construction in the paper in that the full R1CS input is
47+ /// included in the accumulator instance, rather than its commitment. The construction in the paper
48+ /// commits to the R1CS input to bound the public input size for the paper's PCD construction.
49+ /// However, the PCD implementation will hash the inputs, so the committing to the R1CS input for
50+ /// the accumulator instance is no longer necessary.
4651///
4752/// The implementation substitutes power challenges with multiple independent challenges when
4853/// possible to lower constraint costs for the verifier.
49- /// See Remark 10 .1 in [\[BCLMS20\]][bclms20] for more details.
54+ /// See Remark 9 .1 in [\[BCLMS20\]][bclms20] for more details.
5055///
5156/// [bclms20]: https://eprint.iacr.org/2020/1618
5257///
@@ -782,8 +787,8 @@ where
782787 }
783788 }
784789
785- // Step 7 of the scheme's accumulation prover, as detailed in BCLMS20.
786- // We perform Step 7 here because the optional rng will be consumed later in the method, so
790+ // Step 4 of the scheme's accumulation prover, as detailed in BCLMS20.
791+ // We perform Step 4 here because the optional rng will be consumed later in the method, so
787792 // we use it here first.
788793 let ( proof_randomness, prover_witness_randomness) = if make_zk_enabled {
789794 // If make_zk, then rng should exist here.
@@ -805,24 +810,25 @@ where
805810 ( None , None )
806811 } ;
807812
808- // Step 2 of the scheme's accumulation prover, as detailed in BCLMS20.
813+ // Step 1 of the scheme's accumulation prover, as detailed in BCLMS20.
809814 let ( all_blinded_comm_a, all_blinded_comm_b, all_blinded_comm_c, all_blinded_comm_prod) =
810815 Self :: compute_blinded_commitments (
811816 & prover_key. nark_pk . index_info . matrices_hash ,
812817 & input_instances,
813818 nark_sponge,
814819 ) ;
815820
821+ // Step 2 of the scheme's accumulation prover, as detailed in BCLMS20.
816822 let combined_hp_input_instances = Self :: compute_hp_input_instances (
817823 & all_blinded_comm_a,
818824 & all_blinded_comm_b,
819825 & all_blinded_comm_prod,
820826 ) ;
821827
822- // Step 3 of the scheme's accumulation prover, as detailed in BCLMS20.
823828 let combined_hp_input_witnesses =
824829 Self :: compute_hp_input_witnesses ( prover_key, & input_instances, & input_witnesses) ;
825830
831+ // Step 3 of the scheme's accumulation prover, as detailed in BCLMS20.
826832 let combined_hp_inputs_iter = combined_hp_input_instances
827833 . iter ( )
828834 . zip ( & combined_hp_input_witnesses)
@@ -833,7 +839,6 @@ where
833839 } ,
834840 ) ;
835841
836- // Steps 4-5 of the scheme's accumulation prover, as detailed in BCLMS20.
837842 let hp_accumulators_iter = old_accumulator_instances
838843 . iter ( )
839844 . zip ( & old_accumulator_witnesses)
@@ -844,7 +849,6 @@ where
844849 } ,
845850 ) ;
846851
847- // Step 6 of the scheme's accumulation prover, as detailed in BCLMS20.
848852 let ( hp_accumulator, hp_proof) = ASForHadamardProducts :: < G , S > :: prove (
849853 & prover_key. nark_pk . ck ,
850854 combined_hp_inputs_iter,
@@ -858,9 +862,9 @@ where
858862 Some ( hp_sponge) ,
859863 ) ?;
860864
861- // Step 7 was previously executed above.
865+ // Step 4 was previously executed above.
862866
863- // Step 8 of the scheme's accumulation prover, as detailed in BCLMS20.
867+ // Step 5 of the scheme's accumulation prover, as detailed in BCLMS20.
864868 let num_addends = input_instances. len ( )
865869 + old_accumulator_instances. len ( )
866870 + if make_zk_enabled { 1 } else { 0 } ;
@@ -874,7 +878,7 @@ where
874878 as_sponge,
875879 ) ;
876880
877- // Step 9 of the scheme's accumulation prover, as detailed in BCLMS20.
881+ // Step 6 of the scheme's accumulation prover, as detailed in BCLMS20.
878882 let ( r1cs_input, comm_a, comm_b, comm_c) = Self :: compute_accumulator_instance_components (
879883 & input_instances,
880884 & all_blinded_comm_a,
@@ -893,7 +897,7 @@ where
893897 hp_instance : hp_accumulator. instance . clone ( ) ,
894898 } ;
895899
896- // Step 10 of the scheme's accumulation prover, as detailed in BCLMS20.
900+ // Step 7 of the scheme's accumulation prover, as detailed in BCLMS20.
897901 let ( r1cs_blinded_witness, randomness) = Self :: compute_accumulator_witness_components (
898902 & input_witnesses,
899903 & old_accumulator_witnesses,
@@ -907,7 +911,7 @@ where
907911 randomness,
908912 } ;
909913
910- // Steps 11-12 of the scheme's accumulation prover, as detailed in BCLMS20.
914+ // Step 8 of the scheme's accumulation prover, as detailed in BCLMS20.
911915 let accumulator = Accumulator :: < _ , _ , Self > {
912916 instance : combined_acc_instance,
913917 witness : combined_acc_witness,
@@ -963,40 +967,26 @@ where
963967 input_instances. push ( default_input_instance. as_ref ( ) . unwrap ( ) ) ;
964968 }
965969
966- // Step 1 of the scheme's accumulation verifier, as detailed in BCLMS20.
967- let num_addends = input_instances. len ( )
968- + old_accumulator_instances. len ( )
969- + if make_zk_enabled { 1 } else { 0 } ;
970-
971- let beta_challenges = Self :: compute_beta_challenges (
972- num_addends,
973- & verifier_key. as_matrices_hash ,
974- & old_accumulator_instances,
975- & input_instances,
976- & proof. randomness ,
977- as_sponge,
978- ) ;
979-
980- // Step 2 of the scheme's accumulation verifier, as detailed in BCLMS20.
970+ // Steps 1-2 of the scheme's accumulation verifier, as detailed in BCLMS20.
981971 let ( all_blinded_comm_a, all_blinded_comm_b, all_blinded_comm_c, all_blinded_comm_prod) =
982972 Self :: compute_blinded_commitments (
983973 & verifier_key. nark_matrices_hash ,
984974 & input_instances,
985975 nark_sponge,
986976 ) ;
987977
978+ // Step 3 of the scheme's accumulation verifier, as detailed in BCLMS20.
988979 let hp_input_instances = Self :: compute_hp_input_instances (
989980 & all_blinded_comm_a,
990981 & all_blinded_comm_b,
991982 & all_blinded_comm_prod,
992983 ) ;
993984
994- // Step 3 of the scheme's accumulation verifier, as detailed in BCLMS20.
985+ // Step 4 of the scheme's accumulation verifier, as detailed in BCLMS20.
995986 let hp_accumulator_instances = old_accumulator_instances
996987 . iter ( )
997988 . map ( |instance| & instance. hp_instance ) ;
998989
999- // Step 4 of the scheme's accumulation verifier, as detailed in BCLMS20.
1000990 let hp_verify = ASForHadamardProducts :: < G , S > :: verify (
1001991 & verifier_key. num_constraints ,
1002992 & hp_input_instances,
@@ -1006,7 +996,21 @@ where
1006996 Some ( hp_sponge) ,
1007997 ) ?;
1008998
1009- // Steps 5-6 of the scheme's accumulation verifier, as detailed in BCLMS20.
999+ // Step 5 of the scheme's accumulation verifier, as detailed in BCLMS20.
1000+ let num_addends = input_instances. len ( )
1001+ + old_accumulator_instances. len ( )
1002+ + if make_zk_enabled { 1 } else { 0 } ;
1003+
1004+ let beta_challenges = Self :: compute_beta_challenges (
1005+ num_addends,
1006+ & verifier_key. as_matrices_hash ,
1007+ & old_accumulator_instances,
1008+ & input_instances,
1009+ & proof. randomness ,
1010+ as_sponge,
1011+ ) ;
1012+
1013+ // Step 6 of the scheme's accumulation verifier, as detailed in BCLMS20.
10101014 let ( r1cs_input, comm_a, comm_b, comm_c) = Self :: compute_accumulator_instance_components (
10111015 & input_instances,
10121016 & all_blinded_comm_a,
@@ -1063,7 +1067,7 @@ where
10631067 & witness. r1cs_blinded_witness ,
10641068 ) ;
10651069
1066- // Steps 4-6 of the scheme's accumulation decider, as detailed in BCLMS20.
1070+ // Steps 4-7 of the scheme's accumulation decider, as detailed in BCLMS20.
10671071 let ( sigma_a, sigma_b, sigma_c) = if let Some ( randomness) = witness. randomness . as_ref ( ) {
10681072 (
10691073 Some ( randomness. sigma_a ) ,
@@ -1097,7 +1101,7 @@ where
10971101 && comm_c. eq ( & instance. comm_c ) ;
10981102
10991103 Ok ( comm_check
1100- // Step 7 of the scheme's accumulation decider, as detailed in BCLMS20.
1104+ // Step 8 of the scheme's accumulation decider, as detailed in BCLMS20.
11011105 && ASForHadamardProducts :: < G , S > :: decide ( & decider_key. ck ,
11021106 AccumulatorRef :: < _ , _ , ASForHadamardProducts < G , S > > {
11031107 instance : & instance. hp_instance ,
0 commit comments