Address various clippy warnings/errors in zcash_proofs
This commit is contained in:
parent
3a8efd9e67
commit
91541675e2
|
@ -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<E: JubjubEngine> MontgomeryPoint<E> {
|
|||
/// on the curve. Useful for constants and
|
||||
/// window table lookups.
|
||||
pub fn interpret_unchecked(x: Num<E>, y: Num<E>) -> Self {
|
||||
MontgomeryPoint { x: x, y: y }
|
||||
MontgomeryPoint { x, y }
|
||||
}
|
||||
|
||||
/// Performs an affine point addition, not defined for
|
||||
|
|
|
@ -9,7 +9,7 @@ fn get_constant_bools(person: &Personalization) -> Vec<Boolean> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ impl<'a, E: JubjubEngine> Circuit<E> 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::<Bls12>::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::<Bls12>::new();
|
||||
|
||||
let instance = Output {
|
||||
params: params,
|
||||
params,
|
||||
value_commitment: Some(value_commitment.clone()),
|
||||
payment_address: Some(payment_address.clone()),
|
||||
commitment_randomness: Some(commitment_randomness),
|
||||
|
|
|
@ -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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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::<LittleEndian>().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();
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct OutputNote {
|
|||
}
|
||||
|
||||
impl OutputNote {
|
||||
pub fn compute<'a, E, CS>(
|
||||
pub fn compute<E, CS>(
|
||||
mut cs: CS,
|
||||
a_pk: Option<PayingKey>,
|
||||
value: &NoteValue,
|
||||
|
@ -41,6 +41,6 @@ impl OutputNote {
|
|||
&r,
|
||||
)?;
|
||||
|
||||
Ok(OutputNote { cm: cm })
|
||||
Ok(OutputNote { cm })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ impl<R: Read> HashReader<R> {
|
|||
/// Construct a new `HashReader` given an existing `reader` by value.
|
||||
pub fn new(reader: R) -> Self {
|
||||
HashReader {
|
||||
reader: reader,
|
||||
reader,
|
||||
hasher: State::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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::<Bls12> {
|
||||
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::<Bls12>(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::<Bls12> {
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue