Skip to content

Commit 9864cd9

Browse files
authored
Update documentation to match the paper (#33)
Update the documented steps and sections from the paper.
1 parent 722da6d commit 9864cd9

File tree

6 files changed

+63
-58
lines changed

6 files changed

+63
-58
lines changed

src/hp_as/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ pub mod constraints;
2929
pub(crate) const CHALLENGE_SIZE: usize = 128;
3030

3131
/// An accumulation scheme for the Hadamard product relation.
32-
/// The construction is described in detail in Section 8 of [\[BCLMS20\]][bclms20].
32+
/// The construction is described in detail in Section 7 of [\[BCLMS20\]][bclms20].
3333
///
3434
/// The implementation substitutes power challenges with multiple independent challenges when
3535
/// possible to lower constraint costs for the verifier.
36-
/// See Remark 10.1 in [\[BCLMS20\]][bclms20] for more details.
36+
/// See Remark 9.1 in [\[BCLMS20\]][bclms20] for more details.
3737
///
3838
/// [bclms20]: https://eprint.iacr.org/2020/1618
3939
///

src/ipa_pc_as/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(self) const CHALLENGE_POINT_SIZE: usize = 184;
4848
///
4949
/// The implementation substitutes power challenges with multiple independent challenges when
5050
/// possible to lower constraint costs for the verifier.
51-
/// See Remark 10.1 in [\[BCLMS20\]][bclms20] for more details.
51+
/// See Remark 9.1 in [\[BCLMS20\]][bclms20] for more details.
5252
///
5353
/// [ipa-pc]: ark_poly_commit::ipa_pc::InnerProductArgPC
5454
/// [\[BCMS20\]]: https://eprint.iacr.org/2020/499

src/r1cs_nark_as/constraints/mod.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -464,35 +464,22 @@ where
464464
input_instances.push(default_input_instance.as_ref().unwrap());
465465
}
466466

467-
// Step 1 of the scheme's accumulation verifier, as detailed in BCLMS20.
468-
let num_addends = input_instances.len()
469-
+ old_accumulator_instances.len()
470-
+ if make_zk_enabled { 1 } else { 0 };
471-
472-
let (beta_challenges_fe, beta_challenges_bits) = Self::compute_beta_challenges(
473-
num_addends,
474-
&verifier_key.as_matrices_hash,
475-
&old_accumulator_instances,
476-
&input_instances,
477-
proof.randomness.as_ref(),
478-
as_sponge,
479-
)?;
480-
481-
// Step 2 of the scheme's accumulation verifier, as detailed in BCLMS20.
467+
// Steps 1-2 of the scheme's accumulation verifier, as detailed in BCLMS20.
482468
let (all_blinded_comm_a, all_blinded_comm_b, all_blinded_comm_c, all_blinded_comm_prod) =
483469
Self::compute_blinded_commitments(
484470
&verifier_key.nark_matrices_hash,
485471
&input_instances,
486472
nark_sponge,
487473
)?;
488474

475+
// Step 3 of the scheme's accumulation verifier, as detailed in BCLMS20.
489476
let hp_input_instances = Self::compute_hp_input_instances(
490477
&all_blinded_comm_a,
491478
&all_blinded_comm_b,
492479
&all_blinded_comm_prod,
493480
);
494481

495-
// Step 3 of the scheme's accumulation verifier, as detailed in BCLMS20.
482+
// Step 4 of the scheme's accumulation verifier, as detailed in BCLMS20.
496483
let hp_accumulator_instances = old_accumulator_instances
497484
.iter()
498485
.map(|instance| &instance.hp_instance);
@@ -507,7 +494,21 @@ where
507494
Some(hp_sponge),
508495
)?;
509496

510-
// Steps 5-6 of the scheme's accumulation verifier, as detailed in BCLMS20.
497+
// Step 5 of the scheme's accumulation verifier, as detailed in BCLMS20.
498+
let num_addends = input_instances.len()
499+
+ old_accumulator_instances.len()
500+
+ if make_zk_enabled { 1 } else { 0 };
501+
502+
let (beta_challenges_fe, beta_challenges_bits) = Self::compute_beta_challenges(
503+
num_addends,
504+
&verifier_key.as_matrices_hash,
505+
&old_accumulator_instances,
506+
&input_instances,
507+
proof.randomness.as_ref(),
508+
as_sponge,
509+
)?;
510+
511+
// Step 6 of the scheme's accumulation verifier, as detailed in BCLMS20.
511512
let (r1cs_input, comm_a, comm_b, comm_c) = Self::compute_accumulator_instance_components(
512513
&input_instances,
513514
&all_blinded_comm_a,

src/r1cs_nark_as/mod.rs

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
4141
pub(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,

src/r1cs_nark_as/r1cs_nark/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type R1CSResult<T> = Result<T, SynthesisError>;
2727
pub(crate) const PROTOCOL_NAME: &[u8] = b"R1CS-NARK-2020";
2828

2929
/// A simple non-interactive argument of knowledge for R1CS.
30-
/// The construction is described in detail in Section 9 of [\[BCLMS20\]][bclms20].
30+
/// The construction is described in detail in Section 8 of [\[BCLMS20\]][bclms20].
3131
///
3232
/// [bclms20]: https://eprint.iacr.org/2020/1618
3333
pub struct R1CSNark<G, S>

src/trivial_pc_as/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ pub(self) const CHALLENGE_POINT_SIZE: usize = 184;
3333

3434
/// An accumulation scheme for a trivial homomorphic commitment schemes.
3535
/// This implementation is specialized for [`TrivialPC`][trivial-pc].
36-
/// The construction is described in detail in Section 7 of [\[BCLMS20\]][bclms20].
36+
/// The construction is described in detail in Section A of [\[BCLMS20\]][bclms20].
3737
///
3838
/// The implementation substitutes power challenges with multiple independent challenges when
3939
/// possible to lower constraint costs for the verifier.
40-
/// See Remark 10.1 in [\[BCLMS20\]][bclms20] for more details.
40+
/// See Remark 9.1 in [\[BCLMS20\]][bclms20] for more details.
4141
///
4242
/// [trivial-pc]: ark_poly_commit::trivial_pc::TrivialPC
4343
/// [bclms20]: https://eprint.iacr.org/2020/1618

0 commit comments

Comments
 (0)