Skip to content

Commit

Permalink
removed clippy warnings for manual range check + default trait impl
Browse files Browse the repository at this point in the history
  • Loading branch information
AnarchistHoneybun committed Oct 13, 2024
1 parent c9e8641 commit 17a57ba
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions kupyna/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ pub struct KupynaH {
hash_size: usize,
}

impl Default for KupynaH {
fn default() -> Self {
KupynaH::new(512)
}
}

impl KupynaH {
pub fn new(hash_size: usize) -> Self {
let mut state_size: usize = 0;
let mut rounds: usize = 0;

if hash_size >= 8 && hash_size <= 256 {
if (8..=256).contains(&hash_size) {
state_size = 512;
rounds = 10;
} else if hash_size > 256 && hash_size <= 512 {
} else if (257..=512).contains(&hash_size) {
state_size = 1024;
rounds = 14;
}
Expand All @@ -35,16 +41,6 @@ impl KupynaH {
}
}

pub fn default() -> Self {
KupynaH {
state_size: 1024,
state_matrix_cols: 8,
state_matrix_rows: 16,
rounds: 14,
hash_size: 512,
}
}

pub fn hash(&self, message: Vec<u8>, length: Option<usize>) -> Result<Vec<u8>, &'static str> {
let mut message = message;
let message_length: usize;
Expand Down

0 comments on commit 17a57ba

Please sign in to comment.