Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
smtmfft committed Oct 20, 2023
1 parent a516540 commit 5626cd7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions halo2_gadgets/benches/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params_path).is_err() {
if File::open(params_path).is_err() {
let params: ParamsIPA<EqAffine> = ParamsIPA::new(k);
let mut buf = Vec::new();

params.write(&mut buf).expect("Failed to write params");
let mut file = File::create(&params_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(&params_path).expect("couldn't load sha256_params");
let params_fs = File::open(params_path).expect("couldn't load sha256_params");
let params: ParamsIPA<EqAffine> =
ParamsIPA::read::<_>(&mut BufReader::new(params_fs)).expect("Failed to read params");

Expand All @@ -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::<IPACommitmentScheme<_>, ProverIPA<_>, _, _, _, _>(
&params,
Expand All @@ -140,11 +140,11 @@ fn bench(name: &str, k: u32, c: &mut Criterion) {
)
.expect("proof generation should not fail");
let proof: Vec<u8> = 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::<u8>::new();
proof_fs
.read_to_end(&mut proof)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion halo2_gadgets/src/sha256/table16/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn sum_with_carry(words: Vec<(Value<u16>, Value<u16>)>) -> (Value<u32>, 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)
Expand Down

0 comments on commit 5626cd7

Please sign in to comment.