Skip to content

Commit

Permalink
fmt pass
Browse files Browse the repository at this point in the history
  • Loading branch information
AnarchistHoneybun committed Oct 11, 2024
1 parent 9959d43 commit 4ccdb85
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 0 additions & 2 deletions kupyna/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ impl KupynaH {
let state_matrix_cols = 8;
let state_matrix_rows = 16;



KupynaH {
state_size,
state_matrix_cols,
Expand Down
8 changes: 6 additions & 2 deletions kupyna/src/sub_units/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod t_xor_plus;

use t_xor_plus::{t_plus_l, t_xor_l};
use crate::KupynaH;
use t_xor_plus::{t_plus_l, t_xor_l};

const ROUNDS: usize = 14;

Expand All @@ -19,7 +19,11 @@ fn silo(message_block: &[u8], prev_vector: &[u8], hash_params: &KupynaH) -> Vec<
xor_bytes(&(xor_bytes(&t_xor_mp, &t_plus_m)), prev_vector)
}

pub(crate) fn plant(message_blocks: Vec<&[u8]>, init_vector: &[u8], hash_params: &KupynaH) -> Vec<u8> {
pub(crate) fn plant(
message_blocks: Vec<&[u8]>,
init_vector: &[u8],
hash_params: &KupynaH,
) -> Vec<u8> {
let mut last_vector = init_vector.to_vec();

for block in message_blocks {
Expand Down
7 changes: 2 additions & 5 deletions kupyna/src/sub_units/t_xor_plus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const REDUCTION_POLYNOMIAL: u16 = 0x011d;

type Matrix = Vec<Vec<u8>>;

use tables::{MDS_MATRIX, SBOXES};
use crate::KupynaH;
use tables::{MDS_MATRIX, SBOXES};

pub(crate) fn block_to_matrix(block: &[u8], hash_params: &KupynaH) -> Matrix {
let rows = hash_params.state_matrix_rows;
Expand All @@ -28,11 +28,10 @@ pub(crate) fn block_to_matrix(block: &[u8], hash_params: &KupynaH) -> Matrix {
}

fn matrix_to_block(matrix: Matrix) -> Vec<u8> {

let rows = matrix.len();
let cols = matrix[0].len();

let mut block = vec![0u8; rows*cols];
let mut block = vec![0u8; rows * cols];
for i in 0..rows {
for j in 0..cols {
block[i * cols + j] = matrix[i][j];
Expand Down Expand Up @@ -73,7 +72,6 @@ pub(crate) fn s_box_layer(mut state: Matrix, hash_params: &KupynaH) -> Matrix {
}

pub(crate) fn rotate_rows(mut state: Matrix, hash_params: &KupynaH) -> Matrix {

let rows = hash_params.state_matrix_rows;
let cols = hash_params.state_matrix_cols;

Expand Down Expand Up @@ -114,7 +112,6 @@ fn multiply_gf(mut x: u8, mut y: u8) -> u8 {
}

pub(crate) fn mix_columns(state: Matrix, hash_params: &KupynaH) -> Matrix {

let rows = hash_params.state_matrix_rows;
let cols = hash_params.state_matrix_cols;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::KupynaH;
use crate::sub_units::t_xor_plus::*;
use crate::KupynaH;

fn setup_hash_params() -> KupynaH {
KupynaH::default()
Expand Down
2 changes: 1 addition & 1 deletion kupyna/src/sub_units/t_xor_plus/tests/test_xor_plus.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::KupynaH;
use crate::sub_units::t_xor_plus::{t_plus_l, t_xor_l};
use crate::KupynaH;

fn setup_hash_params() -> KupynaH {
KupynaH::default()
Expand Down

0 comments on commit 4ccdb85

Please sign in to comment.