Skip to content

Commit

Permalink
chore: Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
storojs72 committed Sep 23, 2024
1 parent 04fa3d1 commit ce4b853
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion core/src/stark/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl<F: PrimeField32> RiscvAir<F> {
chips.push(RiscvAir::ProgramMemory(program_memory_init));
let byte = ByteChip::default();
chips.push(RiscvAir::ByteLookup(byte));
let blake_2s_round = Blake2sRoundChip::default();
let blake_2s_round = Blake2sRoundChip::new();
chips.push(RiscvAir::Blake2sRound(blake_2s_round));

chips
Expand Down
6 changes: 3 additions & 3 deletions core/src/syscall/precompiles/blake2s/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ where
);
}

let v1_shuffle_lookup = vec![1, 2, 3, 0];
let v2_shuffle_lookup = vec![2, 3, 0, 1];
let v3_shuffle_lookup = vec![3, 0, 1, 2];
let v1_shuffle_lookup = [1, 2, 3, 0];
let v2_shuffle_lookup = [2, 3, 0, 1];
let v3_shuffle_lookup = [3, 0, 1, 2];

for i in 0..4usize {
// 1x
Expand Down
27 changes: 13 additions & 14 deletions core/src/syscall/precompiles/blake2s/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,30 @@ fn rotate_right_const(a: [u32; 4], n: u32) -> [u32; 4] {
a[3].rotate_right(n),
]
}
fn quarter_round(v: &mut Vec<[u32; 4]>, rd: u32, rb: u32, m: [u32; 4]) {
fn quarter_round(v: &mut [[u32; 4]], rd: u32, rb: u32, m: [u32; 4]) {
v[0] = wrapping_add_u32x4(wrapping_add_u32x4(v[0], v[1]), m); // m.from_le (?)
v[3] = rotate_right_const(xor_u32x4(v[3], v[0]), rd);
v[2] = wrapping_add_u32x4(v[2], v[3]);
v[1] = rotate_right_const(xor_u32x4(v[1], v[2]), rb);
}
fn shuffle(v: &mut Vec<[u32; 4]>) {
fn shuffle(v: &mut [[u32; 4]]) {
v[1] = shuffle_left_1_u32x4(v[1]);
v[2] = shuffle_left_2_u32x4(v[2]);
v[3] = shuffle_left_3_u32x4(v[3]);
}
fn unshuffle(v: &mut Vec<[u32; 4]>) {
fn unshuffle(v: &mut [[u32; 4]]) {
v[1] = shuffle_right_1_u32x4(v[1]);
v[2] = shuffle_right_2_u32x4(v[2]);
v[3] = shuffle_right_3_u32x4(v[3]);
}

#[allow(dead_code)]
fn gather(m: [u32; 16], i0: usize, i1: usize, i2: usize, i3: usize) -> [u32; 4] {
[m[i0], m[i1], m[i2], m[i3]]
}
fn round(v: &mut Vec<[u32; 4]>, m: [u32; 16], s: [usize; 16]) {

#[allow(dead_code)]
fn round(v: &mut [[u32; 4]], m: [u32; 16], s: [usize; 16]) {
let r1 = 16;
let r2 = 12;
let r3 = 8;
Expand Down Expand Up @@ -235,7 +239,7 @@ mod tests {
let b_ptr = 200200200;

let a = rand::thread_rng().gen::<[u32; 16]>();
let mut a_clone = a.clone();
let mut a_clone = a;
let mut b = rand::thread_rng().gen::<[u32; 24]>();
for item in b[0..24].iter_mut() {
*item = 0;
Expand Down Expand Up @@ -264,14 +268,9 @@ mod tests {

#[test]
fn test_blake2s_round_function() {
fn test_inner(
input: &mut Vec<[u32; 4]>,
m: [u32; 16],
s: [usize; 16],
output: Vec<[u32; 4]>,
) {
fn test_inner(input: &mut [[u32; 4]], m: [u32; 16], s: [usize; 16], output: &[[u32; 4]]) {
round(input, m, s);
assert_eq!(input.clone(), output);
assert_eq!(input.to_vec(), output.to_vec());
}

let mut v: Vec<[u32; 4]> = vec![
Expand All @@ -294,7 +293,7 @@ mod tests {
&mut v,
m,
s,
vec![
&vec![
[0x82a01b5d, 0x248bd8f5, 0x1da4b59a, 0xb37b2bd3],
[0x515f5af4, 0x0301095b, 0xb151a3c2, 0x5e17f96f],
[0xc561666d, 0x0f291605, 0x990c6d13, 0x76fff6f1],
Expand Down Expand Up @@ -322,7 +321,7 @@ mod tests {
&mut v,
m,
s,
vec![
&vec![
[0x071e8a60, 0x071e8a60, 0x071e8a60, 0x071e8a60],
[0x072df44c, 0x072df44c, 0x072df44c, 0x072df44c],
[0x522ca035, 0x522ca035, 0x522ca035, 0x522ca035],
Expand Down
8 changes: 4 additions & 4 deletions core/src/syscall/precompiles/blake2s/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ impl<F: PrimeField32> MachineAir<F> for Blake2sRoundChip {
cols.b[i].populate(event.channel, event.b_reads[i], &mut new_byte_lookup_events);
}

let mut v0_outer = vec![0u32; 4];
let mut v1_outer = vec![0u32; 4];
let mut v2_outer = vec![0u32; 4];
let mut v3_outer = vec![0u32; 4];
let mut v0_outer = [0u32; 4];
let mut v1_outer = [0u32; 4];
let mut v2_outer = [0u32; 4];
let mut v3_outer = [0u32; 4];

// 1x (m0, R1, R2)
for i in 0..4usize {
Expand Down

0 comments on commit ce4b853

Please sign in to comment.