1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-09 11:46:08 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
d.a 9fb7fca315
Merge a8ae6b4fa2 into 4ec3be8bfa 2024-04-06 12:03:55 +08:00
Jack O'Connor 4ec3be8bfa format the state matrix better in reference_impl.rs 2024-03-20 15:44:05 -07:00
K a8ae6b4fa2
Update lib.rs
Minor performance improvements.
2022-12-04 20:46:15 +02:00
2 changed files with 24 additions and 33 deletions

View File

@ -78,23 +78,14 @@ fn compress(
block_len: u32,
flags: u32,
) -> [u32; 16] {
let counter_low = counter as u32;
let counter_high = (counter >> 32) as u32;
#[rustfmt::skip]
let mut state = [
chaining_value[0],
chaining_value[1],
chaining_value[2],
chaining_value[3],
chaining_value[4],
chaining_value[5],
chaining_value[6],
chaining_value[7],
IV[0],
IV[1],
IV[2],
IV[3],
counter as u32,
(counter >> 32) as u32,
block_len,
flags,
chaining_value[0], chaining_value[1], chaining_value[2], chaining_value[3],
chaining_value[4], chaining_value[5], chaining_value[6], chaining_value[7],
IV[0], IV[1], IV[2], IV[3],
counter_low, counter_high, block_len, flags,
];
let mut block = *block_words;

View File

@ -509,23 +509,23 @@ impl ChunkState {
// Try to avoid buffering as much as possible, by compressing directly from
// the input slice when full blocks are available.
fn update(&mut self, mut input: &[u8]) -> &mut Self {
if self.buf_len > 0 {
self.fill_buf(&mut input);
if !input.is_empty() {
debug_assert_eq!(self.buf_len as usize, BLOCK_LEN);
let block_flags = self.flags | self.start_flag(); // borrowck
self.platform.compress_in_place(
&mut self.cv,
&self.buf,
BLOCK_LEN as u8,
self.chunk_counter,
block_flags,
);
self.buf_len = 0;
self.buf = [0; BLOCK_LEN];
self.blocks_compressed += 1;
}
}
if !input.is_empty() && self.buf_len > 0 {
self.fill_buf(&mut input);
debug_assert_eq!(self.buf_len as usize, BLOCK_LEN);
let block_flags = self.flags | self.start_flag();
self.platform.compress_in_place(
&mut self.cv,
&self.buf,
BLOCK_LEN as u8,
self.chunk_counter,
block_flags,
);
self.buf_len = 0;
self.buf = [0; BLOCK_LEN];
self.blocks_compressed += 1;
}
}
while input.len() > BLOCK_LEN {
debug_assert_eq!(self.buf_len, 0);