WalletDB {
/// Given a wallet database connection, obtain a handle for the write operations
/// for that database. This operation may eagerly initialize and cache sqlite
/// prepared statements that are used in write operations.
- pub fn get_update_ops<'a>(&'a self) -> Result, SqliteClientError> {
+ pub fn get_update_ops(&self) -> Result, SqliteClientError> {
Ok(
DataConnStmtCache {
wallet_db: self,
@@ -220,6 +220,7 @@ impl WalletRead for WalletDB {
wallet::get_commitment_tree(self, block_height)
}
+ #[allow(clippy::type_complexity)]
fn get_witnesses(
&self,
block_height: BlockHeight,
@@ -317,10 +318,7 @@ impl<'a, P: consensus::Parameters> WalletRead for DataConnStmtCache<'a, P> {
self.wallet_db.get_balance_at(account, anchor_height)
}
- fn get_memo_as_utf8(
- &self,
- id_note: Self::NoteRef,
- ) -> Result, Self::Error> {
+ fn get_memo_as_utf8(&self, id_note: Self::NoteRef) -> Result , Self::Error> {
self.wallet_db.get_memo_as_utf8(id_note)
}
@@ -331,6 +329,7 @@ impl<'a, P: consensus::Parameters> WalletRead for DataConnStmtCache<'a, P> {
self.wallet_db.get_commitment_tree(block_height)
}
+ #[allow(clippy::type_complexity)]
fn get_witnesses(
&self,
block_height: BlockHeight,
@@ -571,14 +570,14 @@ mod tests {
let rseed = generate_random_rseed(&network(), height, &mut rng);
let note = Note {
g_d: to.diversifier().g_d().unwrap(),
- pk_d: to.pk_d().clone(),
+ pk_d: *to.pk_d(),
value: value.into(),
rseed,
};
let encryptor = SaplingNoteEncryption::new(
Some(extfvk.fvk.ovk),
note.clone(),
- to.clone(),
+ to,
Memo::default(),
&mut rng,
);
@@ -631,7 +630,7 @@ mod tests {
ctx.outputs.push({
let note = Note {
g_d: to.diversifier().g_d().unwrap(),
- pk_d: to.pk_d().clone(),
+ pk_d: *to.pk_d(),
value: value.into(),
rseed,
};
@@ -659,7 +658,7 @@ mod tests {
let rseed = generate_random_rseed(&network(), height, &mut rng);
let note = Note {
g_d: change_addr.diversifier().g_d().unwrap(),
- pk_d: change_addr.pk_d().clone(),
+ pk_d: *change_addr.pk_d(),
value: (in_value - value).into(),
rseed,
};
diff --git a/zcash_client_sqlite/src/wallet.rs b/zcash_client_sqlite/src/wallet.rs
index 7b438d57c..014448146 100644
--- a/zcash_client_sqlite/src/wallet.rs
+++ b/zcash_client_sqlite/src/wallet.rs
@@ -565,7 +565,9 @@ pub fn put_received_note<'a, P, T: ShieldedOutput>(
// It isn't there, so insert our note into the database.
stmts.stmt_insert_received_note.execute_named(&sql_args)?;
- Ok(NoteId::ReceivedNoteId(stmts.wallet_db.conn.last_insert_rowid()))
+ Ok(NoteId::ReceivedNoteId(
+ stmts.wallet_db.conn.last_insert_rowid(),
+ ))
} else {
// It was there, so grab its row number.
stmts
diff --git a/zcash_client_sqlite/src/wallet/transact.rs b/zcash_client_sqlite/src/wallet/transact.rs
index d109aaa56..16b547aff 100644
--- a/zcash_client_sqlite/src/wallet/transact.rs
+++ b/zcash_client_sqlite/src/wallet/transact.rs
@@ -416,12 +416,8 @@ mod tests {
}
// Mine block 11 so that the second note becomes verified
- let (cb, _) = fake_compact_block(
- sapling_activation_height() + 10,
- cb.hash(),
- extfvk.clone(),
- value,
- );
+ let (cb, _) =
+ fake_compact_block(sapling_activation_height() + 10, cb.hash(), extfvk, value);
insert_into_cache(&db_cache, &cb);
scan_cached_blocks(&tests::network(), &db_cache, &mut db_write, None).unwrap();
@@ -460,7 +456,7 @@ mod tests {
let (cb, _) = fake_compact_block(
sapling_activation_height(),
BlockHash([0; 32]),
- extfvk.clone(),
+ extfvk,
value,
);
insert_into_cache(&db_cache, &cb);
diff --git a/zcash_extensions/src/transparent/demo.rs b/zcash_extensions/src/transparent/demo.rs
index 7dad127dd..2f3e5a99a 100644
--- a/zcash_extensions/src/transparent/demo.rs
+++ b/zcash_extensions/src/transparent/demo.rs
@@ -702,19 +702,14 @@ mod tests {
.create_note(110000, Rseed::BeforeZip212(jubjub::Fr::random(&mut rng)))
.unwrap();
let cm1 = Node::new(note1.cmu().to_repr());
- let mut tree = CommitmentTree::new();
+ let mut tree = CommitmentTree::empty();
// fake that the note appears in some previous
// shielded output
tree.append(cm1).unwrap();
let witness1 = IncrementalWitness::from_tree(&tree);
builder_a
- .add_sapling_spend(
- extsk.clone(),
- *to.diversifier(),
- note1.clone(),
- witness1.path().unwrap(),
- )
+ .add_sapling_spend(extsk, *to.diversifier(), note1, witness1.path().unwrap())
.unwrap();
let mut db_a = DemoBuilder {
diff --git a/zcash_primitives/src/group_hash.rs b/zcash_primitives/src/group_hash.rs
index da1a54e14..5a9f06a09 100644
--- a/zcash_primitives/src/group_hash.rs
+++ b/zcash_primitives/src/group_hash.rs
@@ -11,6 +11,7 @@ use blake2s_simd::Params;
/// Produces a random point in the Jubjub curve.
/// The point is guaranteed to be prime order
/// and not the identity.
+#[allow(clippy::assertions_on_constants)]
pub fn group_hash(tag: &[u8], personalization: &[u8]) -> Option {
assert_eq!(personalization.len(), 8);
diff --git a/zcash_primitives/src/merkle_tree.rs b/zcash_primitives/src/merkle_tree.rs
index 0a2f13477..6258d2299 100644
--- a/zcash_primitives/src/merkle_tree.rs
+++ b/zcash_primitives/src/merkle_tree.rs
@@ -57,7 +57,7 @@ pub struct CommitmentTree {
impl CommitmentTree {
/// Creates an empty tree.
- pub fn new() -> Self {
+ pub fn empty() -> Self {
CommitmentTree {
left: None,
right: None,
@@ -66,6 +66,7 @@ impl CommitmentTree {
}
/// Reads a `CommitmentTree` from its serialized form.
+ #[allow(clippy::redundant_closure)]
pub fn read(mut reader: R) -> io::Result {
let left = Optional::read(&mut reader, |r| Node::read(r))?;
let right = Optional::read(&mut reader, |r| Node::read(r))?;
@@ -203,7 +204,7 @@ impl CommitmentTree {
///
/// let mut rng = OsRng;
///
-/// let mut tree = CommitmentTree::::new();
+/// let mut tree = CommitmentTree::::empty();
///
/// tree.append(Node::new(bls12_381::Scalar::random(&mut rng).to_repr()));
/// tree.append(Node::new(bls12_381::Scalar::random(&mut rng).to_repr()));
@@ -237,6 +238,7 @@ impl IncrementalWitness {
}
/// Reads an `IncrementalWitness` from its serialized form.
+ #[allow(clippy::redundant_closure)]
pub fn read(mut reader: R) -> io::Result {
let tree = CommitmentTree::read(&mut reader)?;
let filled = Vector::read(&mut reader, |r| Node::read(r))?;
@@ -348,7 +350,7 @@ impl IncrementalWitness {
if self.cursor_depth == 0 {
self.filled.push(node);
} else {
- let mut cursor = CommitmentTree::new();
+ let mut cursor = CommitmentTree::empty();
cursor
.append_inner(node, depth)
.expect("cursor should not be full");
@@ -550,7 +552,7 @@ mod tests {
impl TestCommitmentTree {
fn new() -> Self {
- TestCommitmentTree(CommitmentTree::new())
+ TestCommitmentTree(CommitmentTree::empty())
}
pub fn read(reader: R) -> io::Result {
@@ -618,7 +620,7 @@ mod tests {
#[test]
fn sapling_empty_root() {
let mut tmp = [0u8; 32];
- CommitmentTree::::new()
+ CommitmentTree::::empty()
.root()
.write(&mut tmp[..])
.expect("length is 32 bytes");
@@ -630,7 +632,7 @@ mod tests {
#[test]
fn empty_commitment_tree_roots() {
- let tree = CommitmentTree::::new();
+ let tree = CommitmentTree::::empty();
let mut tmp = [0u8; 32];
for (i, &expected) in HEX_EMPTY_ROOTS.iter().enumerate().skip(1) {
tree.root_inner(i, PathFiller::empty())
diff --git a/zcash_primitives/src/note_encryption.rs b/zcash_primitives/src/note_encryption.rs
index d0ec8c293..aabd8d8d0 100644
--- a/zcash_primitives/src/note_encryption.rs
+++ b/zcash_primitives/src/note_encryption.rs
@@ -635,6 +635,7 @@ pub fn try_sapling_output_recovery_with_ock(
/// `PaymentAddress` to which the note was sent.
///
/// Implements section 4.17.3 of the Zcash Protocol Specification.
+#[allow(clippy::too_many_arguments)]
pub fn try_sapling_output_recovery(
params: &P,
height: BlockHeight,
diff --git a/zcash_primitives/src/prover.rs b/zcash_primitives/src/prover.rs
index 567b961f4..1bec62829 100644
--- a/zcash_primitives/src/prover.rs
+++ b/zcash_primitives/src/prover.rs
@@ -22,6 +22,7 @@ pub trait TxProver {
/// the context for later use.
///
/// [`SpendDescription`]: crate::transaction::components::SpendDescription
+ #[allow(clippy::too_many_arguments)]
fn spend_proof(
&self,
ctx: &mut Self::SaplingProvingContext,
diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs
index 051d29218..240172b75 100644
--- a/zcash_primitives/src/transaction/builder.rs
+++ b/zcash_primitives/src/transaction/builder.rs
@@ -296,6 +296,7 @@ impl TransparentInputs {
}
#[cfg(feature = "zfuture")]
+#[allow(clippy::type_complexity)]
struct TzeInputInfo<'a, BuildCtx> {
prevout: TzeOut,
builder: Box Result<(u32, Vec), Error> + 'a>,
@@ -1043,7 +1044,7 @@ mod tests {
.create_note(50000, Rseed::BeforeZip212(jubjub::Fr::random(&mut rng)))
.unwrap();
let cmu1 = Node::new(note1.cmu().to_repr());
- let mut tree = CommitmentTree::new();
+ let mut tree = CommitmentTree::empty();
tree.append(cmu1).unwrap();
let witness1 = IncrementalWitness::from_tree(&tree);
@@ -1136,7 +1137,7 @@ mod tests {
.create_note(50999, Rseed::BeforeZip212(jubjub::Fr::random(&mut rng)))
.unwrap();
let cmu1 = Node::new(note1.cmu().to_repr());
- let mut tree = CommitmentTree::new();
+ let mut tree = CommitmentTree::empty();
tree.append(cmu1).unwrap();
let mut witness1 = IncrementalWitness::from_tree(&tree);
diff --git a/zcash_primitives/src/zip32.rs b/zcash_primitives/src/zip32.rs
index b06e471a4..c326b1393 100644
--- a/zcash_primitives/src/zip32.rs
+++ b/zcash_primitives/src/zip32.rs
@@ -1042,7 +1042,7 @@ mod tests {
match xfvk.dk.diversifier(di) {
Ok((l, d)) if l == di => assert_eq!(d.0, tv.d0.unwrap()),
Ok((_, _)) => assert!(tv.d0.is_none()),
- Err(_) => panic!(),
+ Err(()) => panic!(),
}
// d1
@@ -1050,7 +1050,7 @@ mod tests {
match xfvk.dk.diversifier(di) {
Ok((l, d)) if l == di => assert_eq!(d.0, tv.d1.unwrap()),
Ok((_, _)) => assert!(tv.d1.is_none()),
- Err(_) => panic!(),
+ Err(()) => panic!(),
}
// d2
@@ -1058,7 +1058,7 @@ mod tests {
match xfvk.dk.diversifier(di) {
Ok((l, d)) if l == di => assert_eq!(d.0, tv.d2.unwrap()),
Ok((_, _)) => assert!(tv.d2.is_none()),
- Err(_) => panic!(),
+ Err(()) => panic!(),
}
// dmax
diff --git a/zcash_proofs/benches/sapling.rs b/zcash_proofs/benches/sapling.rs
index 86f33a17a..c31dec269 100644
--- a/zcash_proofs/benches/sapling.rs
+++ b/zcash_proofs/benches/sapling.rs
@@ -39,12 +39,9 @@ fn criterion_benchmark(c: &mut Criterion) {
randomness: jubjub::Fr::random(&mut rng),
};
- let nsk = jubjub::Fr::random(&mut rng);
- let ak = jubjub::SubgroupPoint::random(&mut rng);
-
let proof_generation_key = ProofGenerationKey {
- ak: ak.clone(),
- nsk: nsk.clone(),
+ ak: jubjub::SubgroupPoint::random(&mut rng),
+ nsk: jubjub::Fr::random(&mut rng),
};
let viewing_key = proof_generation_key.to_viewing_key();
diff --git a/zcash_proofs/src/circuit/ecc.rs b/zcash_proofs/src/circuit/ecc.rs
index 6bde76d67..5167fa5de 100644
--- a/zcash_proofs/src/circuit/ecc.rs
+++ b/zcash_proofs/src/circuit/ecc.rs
@@ -632,6 +632,7 @@ mod test {
use bellman::gadgets::boolean::{AllocatedBit, Boolean};
#[test]
+ #[allow(clippy::many_single_char_names)]
fn test_into_edwards() {
let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x3d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
@@ -680,7 +681,7 @@ mod test {
let p = jubjub::ExtendedPoint::random(&mut rng);
let mut cs = TestConstraintSystem::new();
- let q = EdwardsPoint::witness(&mut cs, Some(p.clone())).unwrap();
+ let q = EdwardsPoint::witness(&mut cs, Some(p)).unwrap();
let p = p.to_affine();
@@ -744,7 +745,7 @@ mod test {
AllocatedBit::alloc(cs.namespace(|| format!("scalar bit {}", i)), Some(b))
.unwrap()
})
- .map(|v| Boolean::from(v))
+ .map(Boolean::from)
.collect::>();
let q = fixed_base_multiplication(
@@ -795,7 +796,7 @@ mod test {
AllocatedBit::alloc(cs.namespace(|| format!("scalar bit {}", i)), Some(b))
.unwrap()
})
- .map(|v| Boolean::from(v))
+ .map(Boolean::from)
.collect::>();
let q = p.mul(cs.namespace(|| "scalar mul"), &s_bits).unwrap();
@@ -1080,7 +1081,7 @@ mod test {
// generator for the prime subgroup
let g_prime = g * largest_small_subgroup_order;
- check_small_order_from_p(g_prime.clone(), false);
+ check_small_order_from_p(g_prime, false);
let prime_subgroup_order_minus_1 = prime_subgroup_order - jubjub::Fr::one();
let should_not_be_zero = g_prime * prime_subgroup_order_minus_1;
@@ -1093,7 +1094,7 @@ mod test {
// generator for the small order subgroup
let g_small = g * prime_subgroup_order_minus_1;
let g_small = g_small + g;
- check_small_order_from_p(g_small.clone(), true);
+ check_small_order_from_p(g_small, true);
// g_small does have order 8
let largest_small_subgroup_order_minus_1 = largest_small_subgroup_order - jubjub::Fr::one();
diff --git a/zcash_proofs/src/circuit/pedersen_hash.rs b/zcash_proofs/src/circuit/pedersen_hash.rs
index 2ba02f969..685cb8d80 100644
--- a/zcash_proofs/src/circuit/pedersen_hash.rs
+++ b/zcash_proofs/src/circuit/pedersen_hash.rs
@@ -132,10 +132,10 @@ mod test {
let convert_segment = 2; // Conversion to Edwards
let add_segments = 6; // Edwards addition
- return (chunks) * lookup_chunk - precomputed_booleans
+ (chunks) * lookup_chunk - precomputed_booleans
+ segments * convert_segment
+ all_but_last_segments * ((63 - 1) * add_chunks + add_segments)
- + (last_chunks - 1) * add_chunks;
+ + (last_chunks - 1) * add_chunks
}
#[test]
diff --git a/zcash_proofs/src/circuit/sapling.rs b/zcash_proofs/src/circuit/sapling.rs
index 885ceb27f..57d5b468e 100644
--- a/zcash_proofs/src/circuit/sapling.rs
+++ b/zcash_proofs/src/circuit/sapling.rs
@@ -534,12 +534,9 @@ fn test_input_circuit_with_bls12_381() {
randomness: jubjub::Fr::random(&mut rng),
};
- let nsk = jubjub::Fr::random(&mut rng);
- let ak = jubjub::SubgroupPoint::random(&mut rng);
-
let proof_generation_key = ProofGenerationKey {
- ak: ak.clone(),
- nsk: nsk.clone(),
+ ak: jubjub::SubgroupPoint::random(&mut rng),
+ nsk: jubjub::Fr::random(&mut rng),
};
let viewing_key = proof_generation_key.to_viewing_key();
@@ -571,14 +568,14 @@ fn test_input_circuit_with_bls12_381() {
jubjub::ExtendedPoint::from(value_commitment.commitment()).to_affine();
let note = Note {
value: value_commitment.value,
- g_d: g_d.clone(),
- pk_d: payment_address.pk_d().clone(),
- rseed: Rseed::BeforeZip212(commitment_randomness.clone()),
+ g_d,
+ pk_d: *payment_address.pk_d(),
+ rseed: Rseed::BeforeZip212(commitment_randomness),
};
let mut position = 0u64;
let cmu = note.cmu();
- let mut cur = cmu.clone();
+ let mut cur = cmu;
for (i, val) in auth_path.clone().into_iter().enumerate() {
let (uncle, b) = val.unwrap();
@@ -706,12 +703,9 @@ fn test_input_circuit_with_bls12_381_external_test_vectors() {
randomness: jubjub::Fr::from_str(&(1000 * (i + 1)).to_string()).unwrap(),
};
- let nsk = jubjub::Fr::random(&mut rng);
- let ak = jubjub::SubgroupPoint::random(&mut rng);
-
let proof_generation_key = ProofGenerationKey {
- ak: ak.clone(),
- nsk: nsk.clone(),
+ ak: jubjub::SubgroupPoint::random(&mut rng),
+ nsk: jubjub::Fr::random(&mut rng),
};
let viewing_key = proof_generation_key.to_viewing_key();
@@ -751,14 +745,14 @@ fn test_input_circuit_with_bls12_381_external_test_vectors() {
);
let note = Note {
value: value_commitment.value,
- g_d: g_d.clone(),
- pk_d: payment_address.pk_d().clone(),
- rseed: Rseed::BeforeZip212(commitment_randomness.clone()),
+ g_d,
+ pk_d: *payment_address.pk_d(),
+ rseed: Rseed::BeforeZip212(commitment_randomness),
};
let mut position = 0u64;
let cmu = note.cmu();
- let mut cur = cmu.clone();
+ let mut cur = cmu;
for (i, val) in auth_path.clone().into_iter().enumerate() {
let (uncle, b) = val.unwrap();
@@ -858,10 +852,7 @@ fn test_output_circuit_with_bls12_381() {
let nsk = jubjub::Fr::random(&mut rng);
let ak = jubjub::SubgroupPoint::random(&mut rng);
- let proof_generation_key = ProofGenerationKey {
- ak: ak.clone(),
- nsk: nsk.clone(),
- };
+ let proof_generation_key = ProofGenerationKey { ak, nsk };
let viewing_key = proof_generation_key.to_viewing_key();
@@ -890,7 +881,7 @@ fn test_output_circuit_with_bls12_381() {
value_commitment: Some(value_commitment.clone()),
payment_address: Some(payment_address.clone()),
commitment_randomness: Some(commitment_randomness),
- esk: Some(esk.clone()),
+ esk: Some(esk),
};
instance.synthesize(&mut cs).unwrap();
diff --git a/zcash_proofs/src/circuit/sprout/input.rs b/zcash_proofs/src/circuit/sprout/input.rs
index bb24e9e2f..9dcede334 100644
--- a/zcash_proofs/src/circuit/sprout/input.rs
+++ b/zcash_proofs/src/circuit/sprout/input.rs
@@ -13,6 +13,7 @@ pub struct InputNote {
}
impl InputNote {
+ #[allow(clippy::too_many_arguments)]
pub fn compute(
mut cs: CS,
a_sk: Option,
diff --git a/zcash_proofs/src/circuit/sprout/mod.rs b/zcash_proofs/src/circuit/sprout/mod.rs
index 0b167b1b9..97ad21db4 100644
--- a/zcash_proofs/src/circuit/sprout/mod.rs
+++ b/zcash_proofs/src/circuit/sprout/mod.rs
@@ -347,14 +347,14 @@ fn test_sprout_constraints() {
fn get_u256(mut reader: R) -> [u8; 32] {
let mut result = [0u8; 32];
- for i in 0..32 {
- result[i] = reader.read_u8().unwrap();
+ for b in &mut result {
+ *b = reader.read_u8().unwrap();
}
result
}
- while test_vector.len() != 0 {
+ while !test_vector.is_empty() {
let mut cs = TestConstraintSystem::::new();
let phi = Some(get_u256(&mut test_vector));
@@ -374,8 +374,10 @@ fn test_sprout_constraints() {
auth_path[i] = Some((sibling, false));
}
let mut position = test_vector.read_u64::().unwrap();
- for i in 0..TREE_DEPTH {
- auth_path[i].as_mut().map(|p| p.1 = (position & 1) == 1);
+ for sibling in &mut auth_path {
+ if let Some(p) = sibling {
+ p.1 = (position & 1) == 1;
+ }
position >>= 1;
}
diff --git a/zcash_proofs/src/circuit/sprout/prfs.rs b/zcash_proofs/src/circuit/sprout/prfs.rs
index 240538a9f..6329283f3 100644
--- a/zcash_proofs/src/circuit/sprout/prfs.rs
+++ b/zcash_proofs/src/circuit/sprout/prfs.rs
@@ -3,6 +3,7 @@ use bellman::gadgets::sha256::sha256_block_no_padding;
use bellman::{ConstraintSystem, SynthesisError};
use ff::PrimeField;
+#[allow(clippy::many_single_char_names)]
fn prf(
cs: CS,
a: bool,
diff --git a/zcash_proofs/src/constants.rs b/zcash_proofs/src/constants.rs
index bb83fad89..0aa82344b 100644
--- a/zcash_proofs/src/constants.rs
+++ b/zcash_proofs/src/constants.rs
@@ -90,6 +90,7 @@ pub fn generate_circuit_generator(mut gen: jubjub::SubgroupPoint) -> FixedGenera
/// Returns the coordinates of this point's Montgomery curve representation, or `None` if
/// it is the point at infinity.
+#[allow(clippy::many_single_char_names)]
pub(crate) fn to_montgomery_coords(g: ExtendedPoint) -> Option<(Scalar, Scalar)> {
let g = g.to_affine();
let (x, y) = (g.get_u(), g.get_v());
diff --git a/zcash_proofs/src/lib.rs b/zcash_proofs/src/lib.rs
index 0daf4e8f4..733f9c3ff 100644
--- a/zcash_proofs/src/lib.rs
+++ b/zcash_proofs/src/lib.rs
@@ -65,10 +65,9 @@ pub fn default_params_folder() -> Option {
#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))]
pub fn download_parameters() -> Result<(), minreq::Error> {
// Ensure that the default Zcash parameters location exists.
- let params_dir = default_params_folder().ok_or(io::Error::new(
- io::ErrorKind::Other,
- "Could not load default params folder",
- ))?;
+ let params_dir = default_params_folder().ok_or_else(|| {
+ io::Error::new(io::ErrorKind::Other, "Could not load default params folder")
+ })?;
std::fs::create_dir_all(¶ms_dir)?;
let fetch_params = |name: &str, expected_hash: &str| -> Result<(), minreq::Error> {
@@ -111,17 +110,19 @@ pub fn download_parameters() -> Result<(), minreq::Error> {
Ok(())
}
+pub struct ZcashParameters {
+ pub spend_params: Parameters,
+ pub spend_vk: PreparedVerifyingKey,
+ pub output_params: Parameters,
+ pub output_vk: PreparedVerifyingKey,
+ pub sprout_vk: Option>,
+}
+
pub fn load_parameters(
spend_path: &Path,
output_path: &Path,
sprout_path: Option<&Path>,
-) -> (
- Parameters,
- PreparedVerifyingKey,
- Parameters,
- PreparedVerifyingKey,
- Option>,
-) {
+) -> ZcashParameters {
// Load from each of the paths
let spend_fs = File::open(spend_path).expect("couldn't load Sapling spend parameters file");
let output_fs = File::open(output_path).expect("couldn't load Sapling output parameters file");
@@ -142,13 +143,7 @@ pub fn parse_parameters(
spend_fs: R,
output_fs: R,
sprout_fs: Option,
-) -> (
- Parameters,
- PreparedVerifyingKey,
- Parameters,
- PreparedVerifyingKey,
- Option>,
-) {
+) -> ZcashParameters {
let mut spend_fs = hashreader::HashReader::new(spend_fs);
let mut output_fs = hashreader::HashReader::new(output_fs);
let mut sprout_fs = sprout_fs.map(hashreader::HashReader::new);
@@ -201,5 +196,11 @@ pub fn parse_parameters(
let output_vk = prepare_verifying_key(&output_params.vk);
let sprout_vk = sprout_vk.map(|vk| prepare_verifying_key(&vk));
- (spend_params, spend_vk, output_params, output_vk, sprout_vk)
+ ZcashParameters {
+ spend_params,
+ spend_vk,
+ output_params,
+ output_vk,
+ sprout_vk,
+ }
}
diff --git a/zcash_proofs/src/prover.rs b/zcash_proofs/src/prover.rs
index 2c6fd2716..7aceebd55 100644
--- a/zcash_proofs/src/prover.rs
+++ b/zcash_proofs/src/prover.rs
@@ -45,12 +45,11 @@ impl LocalTxProver {
/// This function will panic if the paths do not point to valid parameter files with
/// the expected hashes.
pub fn new(spend_path: &Path, output_path: &Path) -> Self {
- let (spend_params, spend_vk, output_params, _, _) =
- load_parameters(spend_path, output_path, None);
+ let p = load_parameters(spend_path, output_path, None);
LocalTxProver {
- spend_params,
- spend_vk,
- output_params,
+ spend_params: p.spend_params,
+ spend_vk: p.spend_vk,
+ output_params: p.output_params,
}
}
@@ -70,13 +69,12 @@ impl LocalTxProver {
/// This function will panic if the byte arrays do not contain valid parameters with
/// the expected hashes.
pub fn from_bytes(spend_param_bytes: &[u8], output_param_bytes: &[u8]) -> Self {
- let (spend_params, spend_vk, output_params, _, _) =
- parse_parameters(spend_param_bytes, output_param_bytes, None);
+ let p = parse_parameters(spend_param_bytes, output_param_bytes, None);
LocalTxProver {
- spend_params,
- spend_vk,
- output_params,
+ spend_params: p.spend_params,
+ spend_vk: p.spend_vk,
+ output_params: p.output_params,
}
}
@@ -128,13 +126,12 @@ impl LocalTxProver {
#[cfg_attr(docsrs, doc(cfg(feature = "bundled-prover")))]
pub fn bundled() -> Self {
let (spend_buf, output_buf) = wagyu_zcash_parameters::load_sapling_parameters();
- let (spend_params, spend_vk, output_params, _, _) =
- parse_parameters(&spend_buf[..], &output_buf[..], None);
+ let p = parse_parameters(&spend_buf[..], &output_buf[..], None);
LocalTxProver {
- spend_params,
- spend_vk,
- output_params,
+ spend_params: p.spend_params,
+ spend_vk: p.spend_vk,
+ output_params: p.output_params,
}
}
}
diff --git a/zcash_proofs/src/sapling/prover.rs b/zcash_proofs/src/sapling/prover.rs
index abea98544..ee1cb64ed 100644
--- a/zcash_proofs/src/sapling/prover.rs
+++ b/zcash_proofs/src/sapling/prover.rs
@@ -44,6 +44,7 @@ impl SaplingProvingContext {
/// Create the value commitment, re-randomized key, and proof for a Sapling
/// SpendDescription, while accumulating its value commitment randomness
/// inside the context for later use.
+ #[allow(clippy::too_many_arguments)]
pub fn spend_proof(
&mut self,
proof_generation_key: ProofGenerationKey,
diff --git a/zcash_proofs/src/sapling/verifier.rs b/zcash_proofs/src/sapling/verifier.rs
index 8fb14a13c..0f3b23c3d 100644
--- a/zcash_proofs/src/sapling/verifier.rs
+++ b/zcash_proofs/src/sapling/verifier.rs
@@ -34,6 +34,7 @@ impl SaplingVerificationContext {
/// Perform consensus checks on a Sapling SpendDescription, while
/// accumulating its value commitment inside the context for later use.
+ #[allow(clippy::too_many_arguments)]
pub fn check_spend(
&mut self,
cv: jubjub::ExtendedPoint,
diff --git a/zcash_proofs/src/sprout.rs b/zcash_proofs/src/sprout.rs
index 475e2fb0a..e3fcdd9a4 100644
--- a/zcash_proofs/src/sprout.rs
+++ b/zcash_proofs/src/sprout.rs
@@ -15,6 +15,7 @@ const GROTH_PROOF_SIZE: usize = 48 // π_A
pub const WITNESS_PATH_SIZE: usize = 1 + 33 * TREE_DEPTH + 8;
/// Sprout JoinSplit proof generation.
+#[allow(clippy::too_many_arguments)]
pub fn create_proof(
phi: [u8; 32],
rt: [u8; 32],
@@ -133,6 +134,7 @@ pub fn create_proof(
}
/// Sprout JoinSplit proof verification.
+#[allow(clippy::too_many_arguments)]
pub fn verify_proof(
proof: &[u8; GROTH_PROOF_SIZE],
rt: &[u8; 32],