Skip to content

Commit c86debd

Browse files
committed
Remove zk
1 parent 5f86ada commit c86debd

File tree

3 files changed

+26
-87
lines changed

3 files changed

+26
-87
lines changed

spartan_parallel/src/nizk/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ impl<S: SpartanExtensionField> EqualityProof<S> {
7676
_v1: &S,
7777
s1: &S,
7878
_v2: &S,
79-
s2: &S,
8079
) -> EqualityProof<S> {
8180
<Transcript as ProofTranscript<S>>::append_protocol_name(
8281
transcript,
@@ -86,7 +85,7 @@ impl<S: SpartanExtensionField> EqualityProof<S> {
8685
// produce a random Scalar
8786
let r = random_tape.random_scalar(b"r");
8887
let c: S = transcript.challenge_scalar(b"c");
89-
let z = c * (*s1 - *s2) + r;
88+
let z = c * *s1 + r;
9089

9190
EqualityProof { z }
9291
}
@@ -193,10 +192,8 @@ impl<S: SpartanExtensionField> DotProductProof<S> {
193192
transcript: &mut Transcript,
194193
random_tape: &mut RandomTape<S>,
195194
x_vec: &[S],
196-
blind_x: &S,
197195
a_vec: &[S],
198196
_y: &S,
199-
blind_y: &S,
200197
) -> DotProductProof<S> {
201198
<Transcript as ProofTranscript<S>>::append_protocol_name(
202199
transcript,
@@ -220,8 +217,8 @@ impl<S: SpartanExtensionField> DotProductProof<S> {
220217
.map(|i| c * x_vec[i] + d_vec[i])
221218
.collect::<Vec<S>>();
222219

223-
let z_delta = c * *blind_x + r_delta;
224-
let z_beta = c * *blind_y + r_beta;
220+
let z_delta = c + r_delta;
221+
let z_beta = c + r_beta;
225222

226223
DotProductProof { z, z_delta, z_beta }
227224
}

spartan_parallel/src/r1csproof.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::math::Math;
66
use super::nizk::{EqualityProof, KnowledgeProof, ProductProof};
77
use super::r1csinstance::R1CSInstance;
88
use super::random::RandomTape;
9-
use super::sumcheck::ZKSumcheckInstanceProof;
9+
use super::sumcheck::R1CSSumcheckInstanceProof;
1010
use super::timer::Timer;
1111
use super::transcript::ProofTranscript;
1212
use crate::scalar::SpartanExtensionField;
@@ -17,8 +17,8 @@ use std::cmp::min;
1717

1818
#[derive(Serialize, Deserialize, Debug)]
1919
pub struct R1CSProof<S: SpartanExtensionField> {
20-
sc_proof_phase1: ZKSumcheckInstanceProof<S>,
21-
sc_proof_phase2: ZKSumcheckInstanceProof<S>,
20+
sc_proof_phase1: R1CSSumcheckInstanceProof<S>,
21+
sc_proof_phase2: R1CSSumcheckInstanceProof<S>,
2222
pok_claims_phase2: (KnowledgeProof<S>, ProductProof<S>),
2323
proof_eq_sc_phase1: EqualityProof<S>,
2424
proof_eq_sc_phase2: EqualityProof<S>,
@@ -41,15 +41,14 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
4141
evals_Cz: &mut DensePolynomialPqx<S>,
4242
transcript: &mut Transcript,
4343
random_tape: &mut RandomTape<S>,
44-
) -> (ZKSumcheckInstanceProof<S>, Vec<S>, Vec<S>, S) {
44+
) -> (R1CSSumcheckInstanceProof<S>, Vec<S>, Vec<S>) {
4545
let comb_func = |poly_A_comp: &S, poly_B_comp: &S, poly_C_comp: &S, poly_D_comp: &S| -> S {
4646
*poly_A_comp * (*poly_B_comp * *poly_C_comp - *poly_D_comp)
4747
};
4848

49-
let (sc_proof_phase_one, r, claims, blind_claim_postsc) =
50-
ZKSumcheckInstanceProof::<S>::prove_cubic_with_additive_term_disjoint_rounds(
49+
let (sc_proof_phase_one, r, claims) =
50+
R1CSSumcheckInstanceProof::<S>::prove_cubic_with_additive_term_disjoint_rounds(
5151
&S::field_zero(), // claim is zero
52-
&S::field_zero(), // blind for claim is also zero
5352
num_rounds,
5453
num_rounds_x_max,
5554
num_rounds_q_max,
@@ -67,7 +66,7 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
6766
random_tape,
6867
);
6968

70-
(sc_proof_phase_one, r, claims, blind_claim_postsc)
69+
(sc_proof_phase_one, r, claims)
7170
}
7271

7372
fn prove_phase_two(
@@ -85,14 +84,13 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
8584
evals_z: &mut DensePolynomialPqx<S>,
8685
transcript: &mut Transcript,
8786
random_tape: &mut RandomTape<S>,
88-
) -> (ZKSumcheckInstanceProof<S>, Vec<S>, Vec<S>, S) {
87+
) -> (R1CSSumcheckInstanceProof<S>, Vec<S>, Vec<S>) {
8988
let comb_func = |poly_A_comp: &S, poly_B_comp: &S, poly_C_comp: &S| -> S {
9089
*poly_A_comp * *poly_B_comp * *poly_C_comp
9190
};
92-
let (sc_proof_phase_two, r, claims, blind_claim_postsc) =
93-
ZKSumcheckInstanceProof::<S>::prove_cubic_disjoint_rounds(
91+
let (sc_proof_phase_two, r, claims) =
92+
R1CSSumcheckInstanceProof::<S>::prove_cubic_disjoint_rounds(
9493
claim,
95-
blind_claim,
9694
num_rounds,
9795
num_rounds_y_max,
9896
num_rounds_w,
@@ -108,7 +106,7 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
108106
random_tape,
109107
);
110108

111-
(sc_proof_phase_two, r, claims, blind_claim_postsc)
109+
(sc_proof_phase_two, r, claims)
112110
}
113111

114112
fn protocol_name() -> &'static [u8] {
@@ -235,7 +233,7 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
235233

236234
// Sumcheck 1: (Az * Bz - Cz) * eq(x, q, p) = 0
237235
let timer_tmp = Timer::new("prove_sum_check");
238-
let (sc_proof_phase1, rx, _claims_phase1, blind_claim_postsc1) = R1CSProof::prove_phase_one(
236+
let (sc_proof_phase1, rx, _claims_phase1) = R1CSProof::prove_phase_one(
239237
num_rounds_x + num_rounds_q + num_rounds_p,
240238
num_rounds_x,
241239
num_rounds_q,
@@ -303,7 +301,6 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
303301
&claim_post_phase1,
304302
&blind_expected_claim_postsc1,
305303
&claim_post_phase1,
306-
&blind_claim_postsc1,
307304
);
308305

309306
// Separate the result rx into rp, rq, and rx
@@ -380,7 +377,7 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
380377
let mut eq_p_rp_poly = DensePolynomial::new(EqPolynomial::new(rp).evals());
381378

382379
// Sumcheck 2: (rA + rB + rC) * Z * eq(p) = e
383-
let (sc_proof_phase2, ry, claims_phase2, blind_claim_postsc2) = R1CSProof::prove_phase_two(
380+
let (sc_proof_phase2, ry, claims_phase2) = R1CSProof::prove_phase_two(
384381
num_rounds_y + num_rounds_w + num_rounds_p,
385382
num_rounds_y,
386383
num_rounds_w,
@@ -553,7 +550,6 @@ impl<S: SpartanExtensionField> R1CSProof<S> {
553550
&claim_post_phase2,
554551
&blind_expected_claim_postsc2,
555552
&claim_post_phase2,
556-
&blind_claim_postsc2,
557553
);
558554

559555
timer_prove.stop();

spartan_parallel/src/sumcheck.rs

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ impl<S: SpartanExtensionField> SumcheckInstanceProof<S> {
7171
}
7272

7373
#[derive(Serialize, Deserialize, Debug)]
74-
pub struct ZKSumcheckInstanceProof<S: SpartanExtensionField> {
74+
pub struct R1CSSumcheckInstanceProof<S: SpartanExtensionField> {
7575
proofs: Vec<DotProductProof<S>>,
7676
}
7777

78-
impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
78+
impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
7979
pub fn new(proofs: Vec<DotProductProof<S>>) -> Self {
80-
ZKSumcheckInstanceProof { proofs }
80+
R1CSSumcheckInstanceProof { proofs }
8181
}
8282

8383
pub fn verify(
@@ -381,10 +381,9 @@ impl<S: SpartanExtensionField> SumcheckInstanceProof<S> {
381381
}
382382
}
383383

384-
impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
384+
impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
385385
pub fn prove_cubic_disjoint_rounds<F>(
386386
claim: &S,
387-
blind_claim: &S,
388387
num_rounds: usize,
389388
num_rounds_y_max: usize,
390389
num_rounds_w: usize,
@@ -398,7 +397,7 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
398397
comb_func: F,
399398
transcript: &mut Transcript,
400399
random_tape: &mut RandomTape<S>,
401-
) -> (Self, Vec<S>, Vec<S>, S)
400+
) -> (Self, Vec<S>, Vec<S>)
402401
where
403402
F: Fn(&S, &S, &S) -> S,
404403
{
@@ -408,11 +407,6 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
408407
// poly_A is the EQ polynomial of size P * W * Y_max
409408
assert_eq!(num_rounds, num_rounds_y_max + num_rounds_w + num_rounds_p);
410409

411-
let (blinds_poly, blinds_evals) = (
412-
random_tape.random_vector(b"blinds_poly", num_rounds),
413-
random_tape.random_vector(b"blinds_evals", num_rounds),
414-
);
415-
416410
let mut claim_per_round = *claim;
417411

418412
let mut r: Vec<S> = Vec::new();
@@ -577,18 +571,6 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
577571
// compute a weighted sum of the RHS
578572
let target = w[0] * claim_per_round + w[1] * eval;
579573

580-
let blind = {
581-
let blind_sc = if j == 0 {
582-
blind_claim
583-
} else {
584-
&blinds_evals[j - 1]
585-
};
586-
587-
let blind_eval = &blinds_evals[j];
588-
589-
w[0] * *blind_sc + w[1] * *blind_eval
590-
};
591-
592574
let a = {
593575
// the vector to use to decommit for sum-check test
594576
let a_sc = {
@@ -613,15 +595,7 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
613595
.collect::<Vec<S>>()
614596
};
615597

616-
let proof = DotProductProof::prove(
617-
transcript,
618-
random_tape,
619-
&poly.as_vec(),
620-
&blinds_poly[j],
621-
&a,
622-
&target,
623-
&blind,
624-
);
598+
let proof = DotProductProof::prove(transcript, random_tape, &poly.as_vec(), &a, &target);
625599

626600
(proof, eval)
627601
};
@@ -632,20 +606,18 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
632606
}
633607

634608
(
635-
ZKSumcheckInstanceProof::new(proofs),
609+
R1CSSumcheckInstanceProof::new(proofs),
636610
r,
637611
vec![
638612
poly_A[0],
639613
poly_B.index(0, 0, 0, 0),
640614
poly_C.index(0, 0, 0, 0),
641615
],
642-
blinds_evals[num_rounds - 1],
643616
)
644617
}
645618

646619
pub fn prove_cubic_with_additive_term_disjoint_rounds<F>(
647620
claim: &S,
648-
blind_claim: &S,
649621
num_rounds: usize,
650622
num_rounds_x_max: usize,
651623
num_rounds_q_max: usize,
@@ -661,7 +633,7 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
661633
comb_func: F,
662634
transcript: &mut Transcript,
663635
random_tape: &mut RandomTape<S>,
664-
) -> (Self, Vec<S>, Vec<S>, S)
636+
) -> (Self, Vec<S>, Vec<S>)
665637
where
666638
F: Fn(&S, &S, &S, &S) -> S,
667639
{
@@ -678,11 +650,6 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
678650
assert_eq!(poly_C.num_witness_secs, 1);
679651
assert_eq!(poly_D.num_witness_secs, 1);
680652

681-
let (blinds_poly, blinds_evals) = (
682-
random_tape.random_vector(b"blinds_poly", num_rounds),
683-
random_tape.random_vector(b"blinds_evals", num_rounds),
684-
);
685-
686653
let mut claim_per_round = *claim;
687654

688655
let mut r: Vec<S> = Vec::new();
@@ -864,18 +831,6 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
864831
// compute a weighted sum of the RHS
865832
let target = w[0] * claim_per_round + w[1] * eval;
866833

867-
let blind = {
868-
let blind_sc = if j == 0 {
869-
blind_claim
870-
} else {
871-
&blinds_evals[j - 1]
872-
};
873-
874-
let blind_eval = &blinds_evals[j];
875-
876-
w[0] * *blind_sc + w[1] * *blind_eval
877-
};
878-
879834
let a = {
880835
// the vector to use to decommit for sum-check test
881836
let a_sc = {
@@ -900,15 +855,7 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
900855
.collect::<Vec<S>>()
901856
};
902857

903-
let proof = DotProductProof::prove(
904-
transcript,
905-
random_tape,
906-
&poly.as_vec(),
907-
&blinds_poly[j],
908-
&a,
909-
&target,
910-
&blind,
911-
);
858+
let proof = DotProductProof::prove(transcript, random_tape, &poly.as_vec(), &a, &target);
912859

913860
(proof, eval)
914861
};
@@ -919,15 +866,14 @@ impl<S: SpartanExtensionField> ZKSumcheckInstanceProof<S> {
919866
}
920867

921868
(
922-
ZKSumcheckInstanceProof::new(proofs),
869+
R1CSSumcheckInstanceProof::new(proofs),
923870
r,
924871
vec![
925872
poly_Ap[0] * poly_Aq[0] * poly_Ax[0],
926873
poly_B.index(0, 0, 0, 0),
927874
poly_C.index(0, 0, 0, 0),
928875
poly_D.index(0, 0, 0, 0),
929876
],
930-
blinds_evals[num_rounds - 1],
931877
)
932878
}
933879
}

0 commit comments

Comments
 (0)