Skip to content

Commit c6e1140

Browse files
Merge pull request #7 from scroll-tech/matthias/make-clippy-happy
Make clippy happy
2 parents 6bc33af + 90068ec commit c6e1140

File tree

12 files changed

+244
-333
lines changed

12 files changed

+244
-333
lines changed

NOTICE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This repository includes the following third-party open-source code.
22

3-
* The code in `src/scalar/ristretto255.rs` is derived from [bls12-381](https://github.com/zkcrypto/bls12_381).
3+
* The code in `src/scalar/ristretto255.rs` is derived from [bls12-381](https://github.com/zkcrypto/bls12_381).
44
Specifically, from [src/bls12_381/scalar.rs](https://github.com/zkcrypto/bls12_381/blob/master/src/scalar.rs) and [src/bls12_381/util.rs](https://github.com/zkcrypto/bls12_381/blob/master/src/util.rs), which has the following copyright and license.
55

66
Permission is hereby granted, free of charge, to any
@@ -41,7 +41,7 @@ Specifically, from [src/bls12_381/scalar.rs](https://github.com/zkcrypto/bls12_3
4141
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
4242

4343
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
44-
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4545

4646
========================================================================
4747

@@ -70,4 +70,4 @@ Specifically, from [src/bls12_381/scalar.rs](https://github.com/zkcrypto/bls12_3
7070

7171
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7272

73-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

examples/interface.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct CompileTimeKnowledge {
5353
block_num_vir_ops: Vec<usize>,
5454
max_ts_width: usize,
5555

56+
#[allow(clippy::type_complexity)]
5657
args: Vec<
5758
Vec<(
5859
Vec<(usize, [u8; 32])>,

src/custom_dense_mlpoly.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ pub fn rev_bits(q: usize, max_num_proofs: usize) -> usize {
3737
(0..max_num_proofs.log_2())
3838
.rev()
3939
.map(|i| q / (i.pow2()) % 2 * (max_num_proofs / i.pow2() / 2))
40-
.fold(0, |a, b| a + b)
40+
.sum::<usize>()
4141
}
4242

4343
impl DensePolynomialPqx {
4444
// Assume z_mat is of form (p, q_rev, x), construct DensePoly
4545
pub fn new(
46-
z_mat: &Vec<Vec<Vec<Vec<Scalar>>>>,
46+
z_mat: Vec<Vec<Vec<Vec<Scalar>>>>,
4747
num_proofs: Vec<usize>,
4848
max_num_proofs: usize,
4949
num_inputs: Vec<usize>,
@@ -58,14 +58,14 @@ impl DensePolynomialPqx {
5858
num_witness_secs,
5959
num_inputs,
6060
max_num_inputs,
61-
Z: z_mat.clone(),
61+
Z: z_mat,
6262
}
6363
}
6464

6565
// Assume z_mat is in its standard form of (p, q, x)
6666
// Reverse q and x and convert it to (p, q_rev, x_rev)
6767
pub fn new_rev(
68-
z_mat: &Vec<Vec<Vec<Vec<Scalar>>>>,
68+
z_mat: Vec<Vec<Vec<Vec<Scalar>>>>,
6969
num_proofs: Vec<usize>,
7070
max_num_proofs: usize,
7171
num_inputs: Vec<usize>,
@@ -111,7 +111,7 @@ impl DensePolynomialPqx {
111111
}
112112

113113
pub fn len(&self) -> usize {
114-
return self.num_instances * self.max_num_proofs * self.max_num_inputs;
114+
self.num_instances * self.max_num_proofs * self.max_num_inputs
115115
}
116116

117117
// Given (p, q_rev, x_rev) return Z[p][q_rev][x_rev]
@@ -121,9 +121,9 @@ impl DensePolynomialPqx {
121121
&& w < self.Z[p][q_rev].len()
122122
&& x_rev < self.Z[p][q_rev][w].len()
123123
{
124-
return self.Z[p][q_rev][w][x_rev];
124+
self.Z[p][q_rev][w][x_rev]
125125
} else {
126-
return ZERO;
126+
ZERO
127127
}
128128
}
129129

@@ -137,31 +137,31 @@ impl DensePolynomialPqx {
137137
match mode {
138138
MODE_P => {
139139
if p + self.num_instances / 2 < self.Z.len() {
140-
return self.Z[p + self.num_instances / 2][q_rev][w][x_rev];
140+
self.Z[p + self.num_instances / 2][q_rev][w][x_rev]
141141
} else {
142-
return ZERO;
142+
ZERO
143143
}
144144
}
145145
MODE_Q => {
146-
return if self.num_proofs[p] == 1 {
146+
if self.num_proofs[p] == 1 {
147147
ZERO
148148
} else {
149149
self.Z[p][q_rev + self.num_proofs[p] / 2][w][x_rev]
150-
};
150+
}
151151
}
152152
MODE_W => {
153153
if w + self.num_witness_secs / 2 < self.Z[p][q_rev].len() {
154-
return self.Z[p][q_rev][w + self.num_witness_secs / 2][x_rev];
154+
self.Z[p][q_rev][w + self.num_witness_secs / 2][x_rev]
155155
} else {
156-
return ZERO;
156+
ZERO
157157
}
158158
}
159159
MODE_X => {
160-
return if self.num_inputs[p] == 1 {
160+
if self.num_inputs[p] == 1 {
161161
ZERO
162162
} else {
163163
self.Z[p][q_rev][w][x_rev + self.num_inputs[p] / 2]
164-
};
164+
}
165165
}
166166
_ => {
167167
panic!(
@@ -329,7 +329,7 @@ impl DensePolynomialPqx {
329329
cl.bound_poly_vars_rw(r_w);
330330
cl.bound_poly_vars_rq(r_q);
331331
cl.bound_poly_vars_rp(r_p);
332-
return cl.index(0, 0, 0, 0);
332+
cl.index(0, 0, 0, 0)
333333
}
334334

335335
// Convert to a (p, q_rev, x_rev) regular dense poly of form (p, q, x)

src/dense_mlpoly.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,17 @@ impl DensePolynomial {
283283
cons_len: usize,
284284
proof_len: usize,
285285
instance_len: usize,
286-
num_proofs: &Vec<usize>,
286+
num_proofs: &[usize],
287287
) {
288288
let n = self.len() / 2;
289289
assert_eq!(n, cons_len * proof_len * instance_len);
290290

291-
for p in 0..instance_len {
291+
for (p, &num_proof) in num_proofs.iter().enumerate() {
292292
// Certain p, q combinations within the boolean hypercube always evaluate to 0
293293
let max_q = if proof_len != proof_space {
294294
proof_len
295295
} else {
296-
num_proofs[p]
296+
num_proof
297297
};
298298
for q in 0..max_q {
299299
for x in 0..cons_len {
@@ -311,7 +311,7 @@ impl DensePolynomial {
311311
// Use "num_proofs" to record how many "q"s need to process for each "p"
312312
pub fn bound_poly_var_front_rq(
313313
&mut self,
314-
r_q: &Vec<Scalar>,
314+
r_q: &[Scalar],
315315
mut max_proof_space: usize,
316316
instance_space: usize,
317317
cons_space: usize,
@@ -324,16 +324,16 @@ impl DensePolynomial {
324324
n /= 2;
325325
max_proof_space /= 2;
326326

327-
for p in 0..instance_space {
328-
if num_proofs[p] == 1 {
327+
for (p, num_proof) in num_proofs.iter_mut().enumerate() {
328+
if *num_proof == 1 {
329329
// q = 0
330330
for x in 0..cons_space {
331331
let i = p * cons_space + x;
332332
self.Z[i] = (Scalar::one() - r) * self.Z[i];
333333
}
334334
} else {
335-
num_proofs[p] /= 2;
336-
let step = max_proof_space / num_proofs[p];
335+
*num_proof /= 2;
336+
let step = max_proof_space / *num_proof;
337337
for q in (0..max_proof_space).step_by(step) {
338338
for x in 0..cons_space {
339339
let i = q * instance_space * cons_space + p * cons_space + x;
@@ -606,7 +606,7 @@ impl PolyEvalProof {
606606
random_tape,
607607
&LZ,
608608
&LZ_blind,
609-
&R,
609+
R,
610610
&Zc_list[i],
611611
blind_Zr,
612612
);
@@ -622,7 +622,7 @@ impl PolyEvalProof {
622622
}
623623

624624
pub fn verify_plain_batched_points(
625-
proof_list: &Vec<PolyEvalProof>,
625+
proof_list: &[PolyEvalProof],
626626
gens: &PolyCommitmentGens,
627627
transcript: &mut Transcript,
628628
r_list: Vec<Vec<Scalar>>, // point at which the polynomial is evaluated
@@ -678,7 +678,7 @@ impl PolyEvalProof {
678678

679679
proof_list[i]
680680
.proof
681-
.verify(R.len(), &gens.gens, transcript, &R, &C_LZ, &C_Zc)?
681+
.verify(R.len(), &gens.gens, transcript, R, &C_LZ, &C_Zc)?
682682
}
683683

684684
Ok(())
@@ -687,10 +687,10 @@ impl PolyEvalProof {
687687
// Evaluation on multiple instances, each at different point
688688
// Size of each instance might be different, but all are larger than the evaluation point
689689
pub fn prove_batched_instances(
690-
poly_list: &Vec<DensePolynomial>, // list of instances
690+
poly_list: &[DensePolynomial], // list of instances
691691
blinds_opt: Option<&PolyCommitmentBlinds>,
692692
r_list: Vec<&Vec<Scalar>>, // point at which the polynomial is evaluated
693-
Zr_list: &Vec<Scalar>, // evaluation of \widetilde{Z}(r) on each instance
693+
Zr_list: &[Scalar], // evaluation of \widetilde{Z}(r) on each instance
694694
blind_Zr_opt: Option<&Scalar>, // specifies a blind for Zr
695695
gens: &PolyCommitmentGens,
696696
transcript: &mut Transcript,
@@ -780,13 +780,13 @@ impl PolyEvalProof {
780780
}
781781

782782
pub fn verify_plain_batched_instances(
783-
proof_list: &Vec<PolyEvalProof>,
783+
proof_list: &[PolyEvalProof],
784784
gens: &PolyCommitmentGens,
785785
transcript: &mut Transcript,
786786
r_list: Vec<&Vec<Scalar>>, // point at which the polynomial is evaluated
787-
Zr_list: &Vec<Scalar>, // commitment to \widetilde{Z}(r) of each instance
788-
comm_list: &Vec<PolyCommitment>, // commitment of each instance
789-
num_vars_list: &Vec<usize>, // size of each polynomial
787+
Zr_list: &[Scalar], // commitment to \widetilde{Z}(r) of each instance
788+
comm_list: &[PolyCommitment], // commitment of each instance
789+
num_vars_list: &[usize], // size of each polynomial
790790
) -> Result<(), ProofVerifyError> {
791791
transcript.append_protocol_name(PolyEvalProof::protocol_name());
792792
assert_eq!(comm_list.len(), r_list.len());
@@ -859,13 +859,13 @@ impl PolyEvalProof {
859859
// Like prove_batched_instances, but r is divided into rq ++ ry
860860
// Each polynomial is supplemented with num_proofs and num_inputs
861861
pub fn prove_batched_instances_disjoint_rounds(
862-
poly_list: &Vec<&DensePolynomial>,
863-
num_proofs_list: &Vec<usize>,
864-
num_inputs_list: &Vec<usize>,
862+
poly_list: &[&DensePolynomial],
863+
num_proofs_list: &[usize],
864+
num_inputs_list: &[usize],
865865
blinds_opt: Option<&PolyCommitmentBlinds>,
866866
rq: &[Scalar],
867867
ry: &[Scalar],
868-
Zr_list: &Vec<Scalar>,
868+
Zr_list: &[Scalar],
869869
blind_Zr_opt: Option<&Scalar>,
870870
gens: &PolyCommitmentGens,
871871
transcript: &mut Transcript,
@@ -893,7 +893,7 @@ impl PolyEvalProof {
893893
if let Some(index) = index_map.get(&(num_proofs, num_inputs)) {
894894
c *= c_base;
895895
let L = &L_list[*index].to_vec();
896-
let LZ = poly.bound(&L);
896+
let LZ = poly.bound(L);
897897
LZ_list[*index] = (0..LZ.len())
898898
.map(|j| LZ_list[*index][j] + c * LZ[j])
899899
.collect();
@@ -960,15 +960,15 @@ impl PolyEvalProof {
960960
}
961961

962962
pub fn verify_batched_instances_disjoint_rounds(
963-
proof_list: &Vec<PolyEvalProof>,
964-
num_proofs_list: &Vec<usize>,
965-
num_inputs_list: &Vec<usize>,
963+
proof_list: &[PolyEvalProof],
964+
num_proofs_list: &[usize],
965+
num_inputs_list: &[usize],
966966
gens: &PolyCommitmentGens,
967967
transcript: &mut Transcript,
968968
rq: &[Scalar],
969969
ry: &[Scalar],
970-
Zr_list: &Vec<RistrettoPoint>,
971-
comm_list: &Vec<&PolyCommitment>,
970+
Zr_list: &[RistrettoPoint],
971+
comm_list: &[&PolyCommitment],
972972
) -> Result<(), ProofVerifyError> {
973973
transcript.append_protocol_name(PolyEvalProof::protocol_name());
974974

@@ -1045,8 +1045,8 @@ impl PolyEvalProof {
10451045
// Treat the polynomial(s) as univariate and open on a single point
10461046
pub fn prove_uni_batched_instances(
10471047
poly_list: &Vec<&DensePolynomial>,
1048-
r: &Scalar, // point at which the polynomial is evaluated
1049-
Zr: &Vec<Scalar>, // evaluation of \widetilde{Z}(r)
1048+
r: &Scalar, // point at which the polynomial is evaluated
1049+
Zr: &[Scalar], // evaluation of \widetilde{Z}(r)
10501050
gens: &PolyCommitmentGens,
10511051
transcript: &mut Transcript,
10521052
random_tape: &mut RandomTape,
@@ -1106,7 +1106,7 @@ impl PolyEvalProof {
11061106
L_map.get(&num_vars).unwrap()
11071107
};
11081108

1109-
let LZ = poly.bound(&L);
1109+
let LZ = poly.bound(L);
11101110
LZ_comb = (0..R_size)
11111111
.map(|i| LZ_comb[i] + if i < LZ.len() { c * LZ[i] } else { zero })
11121112
.collect();
@@ -1133,9 +1133,9 @@ impl PolyEvalProof {
11331133
&self,
11341134
gens: &PolyCommitmentGens,
11351135
transcript: &mut Transcript,
1136-
r: &Scalar, // point at which the polynomial is evaluated
1137-
C_Zr: &Vec<RistrettoPoint>, // commitment to \widetilde{Z}(r)
1138-
comm_list: &Vec<&PolyCommitment>,
1136+
r: &Scalar, // point at which the polynomial is evaluated
1137+
C_Zr: &[RistrettoPoint], // commitment to \widetilde{Z}(r)
1138+
comm_list: &[&PolyCommitment],
11391139
poly_size: Vec<usize>,
11401140
) -> Result<(), ProofVerifyError> {
11411141
transcript.append_protocol_name(PolyEvalProof::protocol_name());

0 commit comments

Comments
 (0)