diff --git a/zcash_proofs/src/circuit/ecc.rs b/zcash_proofs/src/circuit/ecc.rs index 4c07829..76b837d 100644 --- a/zcash_proofs/src/circuit/ecc.rs +++ b/zcash_proofs/src/circuit/ecc.rs @@ -41,16 +41,16 @@ where { let chunk_a = chunk .get(0) - .map(|e| e.clone()) - .unwrap_or(Boolean::constant(false)); + .cloned() + .unwrap_or_else(|| Boolean::constant(false)); let chunk_b = chunk .get(1) - .map(|e| e.clone()) - .unwrap_or(Boolean::constant(false)); + .cloned() + .unwrap_or_else(|| Boolean::constant(false)); let chunk_c = chunk .get(2) - .map(|e| e.clone()) - .unwrap_or(Boolean::constant(false)); + .cloned() + .unwrap_or_else(|| Boolean::constant(false)); let (x, y) = lookup3_xy( cs.namespace(|| format!("window table lookup {}", i)), @@ -58,7 +58,7 @@ where window, )?; - let p = EdwardsPoint { x: x, y: y }; + let p = EdwardsPoint { x, y }; if result.is_none() { result = Some(p); @@ -570,7 +570,7 @@ impl MontgomeryPoint { /// on the curve. Useful for constants and /// window table lookups. pub fn interpret_unchecked(x: Num, y: Num) -> Self { - MontgomeryPoint { x: x, y: y } + MontgomeryPoint { x, y } } /// Performs an affine point addition, not defined for diff --git a/zcash_proofs/src/circuit/pedersen_hash.rs b/zcash_proofs/src/circuit/pedersen_hash.rs index 326d3ce..e77d28b 100644 --- a/zcash_proofs/src/circuit/pedersen_hash.rs +++ b/zcash_proofs/src/circuit/pedersen_hash.rs @@ -9,7 +9,7 @@ fn get_constant_bools(person: &Personalization) -> Vec { person .get_bits() .into_iter() - .map(|e| Boolean::constant(e)) + .map(Boolean::constant) .collect() } @@ -65,7 +65,7 @@ where segment_windows = &segment_windows[1..]; - if segment_windows.len() == 0 { + if segment_windows.is_empty() { break; } diff --git a/zcash_proofs/src/circuit/sapling.rs b/zcash_proofs/src/circuit/sapling.rs index 0554ff4..d43a628 100644 --- a/zcash_proofs/src/circuit/sapling.rs +++ b/zcash_proofs/src/circuit/sapling.rs @@ -150,7 +150,7 @@ impl<'a, E: JubjubEngine> Circuit for Spend<'a, E> { // Witness nsk as bits let nsk = boolean::field_into_boolean_vec_le( cs.namespace(|| "nsk"), - self.proof_generation_key.as_ref().map(|k| k.nsk.clone()), + self.proof_generation_key.as_ref().map(|k| k.nsk), )?; // NB: We don't ensure that the bit representation of nsk @@ -642,7 +642,7 @@ fn test_input_circuit_with_bls12_381() { let mut cs = TestConstraintSystem::::new(); let instance = Spend { - params: params, + params, value_commitment: Some(value_commitment.clone()), proof_generation_key: Some(proof_generation_key.clone()), payment_address: Some(payment_address.clone()), @@ -738,7 +738,7 @@ fn test_output_circuit_with_bls12_381() { let mut cs = TestConstraintSystem::::new(); let instance = Output { - params: params, + params, value_commitment: Some(value_commitment.clone()), payment_address: Some(payment_address.clone()), commitment_randomness: Some(commitment_randomness), diff --git a/zcash_proofs/src/circuit/sprout/input.rs b/zcash_proofs/src/circuit/sprout/input.rs index ad6091f..a2726d4 100644 --- a/zcash_proofs/src/circuit/sprout/input.rs +++ b/zcash_proofs/src/circuit/sprout/input.rs @@ -54,7 +54,7 @@ impl InputNote { // Witness into the merkle tree let mut cur = cm.clone(); - for (i, layer) in auth_path.into_iter().enumerate() { + for (i, layer) in auth_path.iter().enumerate() { let cs = &mut cs.namespace(|| format!("layer {}", i)); let cur_is_right = AllocatedBit::alloc( @@ -112,7 +112,7 @@ impl InputNote { ); } - Ok(InputNote { mac: mac, nf: nf }) + Ok(InputNote { mac, nf }) } } diff --git a/zcash_proofs/src/circuit/sprout/mod.rs b/zcash_proofs/src/circuit/sprout/mod.rs index 358e1bb..f72d792 100644 --- a/zcash_proofs/src/circuit/sprout/mod.rs +++ b/zcash_proofs/src/circuit/sprout/mod.rs @@ -234,10 +234,7 @@ impl NoteValue { )?); } - Ok(NoteValue { - value: value, - bits: bits, - }) + Ok(NoteValue { value, bits }) } /// Encodes the bits of the value into little-endian @@ -247,7 +244,7 @@ impl NoteValue { .chunks(8) .flat_map(|v| v.iter().rev()) .cloned() - .map(|e| Boolean::from(e)) + .map(Boolean::from) .collect() } @@ -379,11 +376,11 @@ fn test_sprout_constraints() { let a_sk = Some(SpendingKey(get_u256(&mut test_vector))); inputs.push(JSInput { - value: value, - a_sk: a_sk, - rho: rho, - r: r, - auth_path: auth_path, + value, + a_sk, + rho, + r, + auth_path, }); } @@ -395,11 +392,7 @@ fn test_sprout_constraints() { get_u256(&mut test_vector); let r = Some(CommitmentRandomness(get_u256(&mut test_vector))); - outputs.push(JSOutput { - value: value, - a_pk: a_pk, - r: r, - }); + outputs.push(JSOutput { value, a_pk, r }); } let vpub_old = Some(test_vector.read_u64::().unwrap()); @@ -415,13 +408,13 @@ fn test_sprout_constraints() { let mac2 = get_u256(&mut test_vector); let js = JoinSplit { - vpub_old: vpub_old, - vpub_new: vpub_new, - h_sig: h_sig, - phi: phi, - inputs: inputs, - outputs: outputs, - rt: rt, + vpub_old, + vpub_new, + h_sig, + phi, + inputs, + outputs, + rt, }; js.synthesize(&mut cs).unwrap(); diff --git a/zcash_proofs/src/circuit/sprout/output.rs b/zcash_proofs/src/circuit/sprout/output.rs index a9a1e48..73a9851 100644 --- a/zcash_proofs/src/circuit/sprout/output.rs +++ b/zcash_proofs/src/circuit/sprout/output.rs @@ -11,7 +11,7 @@ pub struct OutputNote { } impl OutputNote { - pub fn compute<'a, E, CS>( + pub fn compute( mut cs: CS, a_pk: Option, value: &NoteValue, @@ -41,6 +41,6 @@ impl OutputNote { &r, )?; - Ok(OutputNote { cm: cm }) + Ok(OutputNote { cm }) } } diff --git a/zcash_proofs/src/hashreader.rs b/zcash_proofs/src/hashreader.rs index dbe686f..f8487b8 100644 --- a/zcash_proofs/src/hashreader.rs +++ b/zcash_proofs/src/hashreader.rs @@ -11,7 +11,7 @@ impl HashReader { /// Construct a new `HashReader` given an existing `reader` by value. pub fn new(reader: R) -> Self { HashReader { - reader: reader, + reader, hasher: State::new(), } } diff --git a/zcash_proofs/src/sapling/prover.rs b/zcash_proofs/src/sapling/prover.rs index 283e76b..e5116c6 100644 --- a/zcash_proofs/src/sapling/prover.rs +++ b/zcash_proofs/src/sapling/prover.rs @@ -65,7 +65,7 @@ impl SaplingProvingContext { // Accumulate the value commitment randomness in the context { - let mut tmp = rcv.clone(); + let mut tmp = rcv; tmp.add_assign(&self.bsk); // Update the context @@ -74,7 +74,7 @@ impl SaplingProvingContext { // Construct the value commitment let value_commitment = ValueCommitment:: { - value: value, + value, randomness: rcv, }; @@ -96,7 +96,7 @@ impl SaplingProvingContext { // Let's compute the nullifier while we have the position let note = Note { - value: value, + value, g_d: diversifier .g_d::(params) .expect("was a valid diversifier before"), @@ -200,7 +200,7 @@ impl SaplingProvingContext { // Accumulate the value commitment randomness in the context { - let mut tmp = rcv.clone(); + let mut tmp = rcv; tmp.negate(); // Outputs subtract from the total. tmp.add_assign(&self.bsk); @@ -210,7 +210,7 @@ impl SaplingProvingContext { // Construct the value commitment for the proof instance let value_commitment = ValueCommitment:: { - value: value, + value, randomness: rcv, }; @@ -220,7 +220,7 @@ impl SaplingProvingContext { value_commitment: Some(value_commitment.clone()), payment_address: Some(payment_address.clone()), commitment_randomness: Some(rcm), - esk: Some(esk.clone()), + esk: Some(esk), }; // Create proof