From 5626cd74e3bfde29eee2b9ad73e54371a1a861fd Mon Sep 17 00:00:00 2001 From: smtmfft Date: Fri, 20 Oct 2023 15:23:56 +0000 Subject: [PATCH] fix clippy --- halo2_gadgets/benches/sha256.rs | 12 ++++++------ .../sha256/table16/compression/compression_util.rs | 4 ++-- .../sha256/table16/message_schedule/schedule_util.rs | 6 +++--- .../sha256/table16/message_schedule/subregion2.rs | 2 +- .../sha256/table16/message_schedule/subregion3.rs | 2 +- halo2_gadgets/src/sha256/table16/util.rs | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/halo2_gadgets/benches/sha256.rs b/halo2_gadgets/benches/sha256.rs index 0e14d61946..4afceacd82 100644 --- a/halo2_gadgets/benches/sha256.rs +++ b/halo2_gadgets/benches/sha256.rs @@ -90,18 +90,18 @@ fn bench(name: &str, k: u32, c: &mut Criterion) { // Initialize the polynomial commitment parameters let params_path = Path::new("./benches/sha256_assets/sha256_params"); - if File::open(¶ms_path).is_err() { + if File::open(params_path).is_err() { let params: ParamsIPA = ParamsIPA::new(k); let mut buf = Vec::new(); params.write(&mut buf).expect("Failed to write params"); - let mut file = File::create(¶ms_path).expect("Failed to create sha256_params"); + let mut file = File::create(params_path).expect("Failed to create sha256_params"); file.write_all(&buf[..]) .expect("Failed to write params to file"); } - let params_fs = File::open(¶ms_path).expect("couldn't load sha256_params"); + let params_fs = File::open(params_path).expect("couldn't load sha256_params"); let params: ParamsIPA = ParamsIPA::read::<_>(&mut BufReader::new(params_fs)).expect("Failed to read params"); @@ -128,7 +128,7 @@ fn bench(name: &str, k: u32, c: &mut Criterion) { // Create a proof let proof_path = Path::new("./benches/sha256_assets/sha256_proof"); - if File::open(&proof_path).is_err() { + if File::open(proof_path).is_err() { let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]); create_proof::, ProverIPA<_>, _, _, _, _>( ¶ms, @@ -140,11 +140,11 @@ fn bench(name: &str, k: u32, c: &mut Criterion) { ) .expect("proof generation should not fail"); let proof: Vec = transcript.finalize(); - let mut file = File::create(&proof_path).expect("Failed to create sha256_proof"); + let mut file = File::create(proof_path).expect("Failed to create sha256_proof"); file.write_all(&proof[..]).expect("Failed to write proof"); } - let mut proof_fs = File::open(&proof_path).expect("couldn't load sha256_proof"); + let mut proof_fs = File::open(proof_path).expect("couldn't load sha256_proof"); let mut proof = Vec::::new(); proof_fs .read_to_end(&mut proof) diff --git a/halo2_gadgets/src/sha256/table16/compression/compression_util.rs b/halo2_gadgets/src/sha256/table16/compression/compression_util.rs index 324fe8f695..99706023df 100644 --- a/halo2_gadgets/src/sha256/table16/compression/compression_util.rs +++ b/halo2_gadgets/src/sha256/table16/compression/compression_util.rs @@ -111,7 +111,7 @@ pub fn get_round_row(round_idx: RoundIdx) -> usize { RoundIdx::Init => 0, RoundIdx::Main(MainRoundIdx(idx)) => { assert!(idx < 64); - (idx as usize) * SUBREGION_MAIN_WORD + idx * SUBREGION_MAIN_WORD } } } @@ -783,7 +783,7 @@ impl CompressionConfig { || "h_prime_carry", a_9, row + 1, - || h_prime_carry.map(|value| pallas::Base::from(value as u64)), + || h_prime_carry.map(pallas::Base::from), )?; let h_prime: Value<[bool; 32]> = h_prime.map(|w| i2lebsp(w.into())); diff --git a/halo2_gadgets/src/sha256/table16/message_schedule/schedule_util.rs b/halo2_gadgets/src/sha256/table16/message_schedule/schedule_util.rs index 79a9fa2621..d8bf48eeba 100644 --- a/halo2_gadgets/src/sha256/table16/message_schedule/schedule_util.rs +++ b/halo2_gadgets/src/sha256/table16/message_schedule/schedule_util.rs @@ -40,20 +40,20 @@ pub fn get_word_row(word_idx: usize) -> usize { if word_idx == 0 { 0 } else if (1..=13).contains(&word_idx) { - SUBREGION_0_ROWS + SUBREGION_1_WORD * (word_idx - 1) as usize + SUBREGION_0_ROWS + SUBREGION_1_WORD * (word_idx - 1) } else if (14..=48).contains(&word_idx) { SUBREGION_0_ROWS + SUBREGION_1_ROWS + SUBREGION_2_WORD * (word_idx - 14) + 1 } else if (49..=61).contains(&word_idx) { SUBREGION_0_ROWS + SUBREGION_1_ROWS + SUBREGION_2_ROWS - + SUBREGION_3_WORD * (word_idx - 49) as usize + + SUBREGION_3_WORD * (word_idx - 49) } else { SUBREGION_0_ROWS + SUBREGION_1_ROWS + SUBREGION_2_ROWS + SUBREGION_3_ROWS - + DECOMPOSE_0_ROWS * (word_idx - 62) as usize + + DECOMPOSE_0_ROWS * (word_idx - 62) } } diff --git a/halo2_gadgets/src/sha256/table16/message_schedule/subregion2.rs b/halo2_gadgets/src/sha256/table16/message_schedule/subregion2.rs index 43e96c934f..9733b46039 100644 --- a/halo2_gadgets/src/sha256/table16/message_schedule/subregion2.rs +++ b/halo2_gadgets/src/sha256/table16/message_schedule/subregion2.rs @@ -261,7 +261,7 @@ impl MessageScheduleConfig { || format!("carry_{}", new_word_idx), a_9, get_word_row(new_word_idx - 16) + 1, - || carry.map(|carry| pallas::Base::from(carry as u64)), + || carry.map(pallas::Base::from), )?; let (word, halves) = self.assign_word_and_halves(region, word, new_word_idx)?; w.push(MessageWord(word)); diff --git a/halo2_gadgets/src/sha256/table16/message_schedule/subregion3.rs b/halo2_gadgets/src/sha256/table16/message_schedule/subregion3.rs index b23046e42e..aebe1945d9 100644 --- a/halo2_gadgets/src/sha256/table16/message_schedule/subregion3.rs +++ b/halo2_gadgets/src/sha256/table16/message_schedule/subregion3.rs @@ -177,7 +177,7 @@ impl MessageScheduleConfig { || format!("carry_{}", new_word_idx), a_9, get_word_row(new_word_idx - 16) + 1, - || carry.map(|carry| pallas::Base::from(carry as u64)), + || carry.map(pallas::Base::from), )?; let (word, halves) = self.assign_word_and_halves(region, word, new_word_idx)?; w.push(MessageWord(word)); diff --git a/halo2_gadgets/src/sha256/table16/util.rs b/halo2_gadgets/src/sha256/table16/util.rs index 6a790d3797..d3da5317ca 100644 --- a/halo2_gadgets/src/sha256/table16/util.rs +++ b/halo2_gadgets/src/sha256/table16/util.rs @@ -110,7 +110,7 @@ pub fn sum_with_carry(words: Vec<(Value, Value)>) -> (Value, Valu sum_lo.zip(sum_hi).map(|(lo, hi)| lo + (1 << 16) * hi) }; - let carry = sum.map(|sum| (sum >> 32) as u64); + let carry = sum.map(|sum| (sum >> 32)); let sum = sum.map(|sum| sum as u32); (sum, carry)