Skip to content

Commit

Permalink
KeccakState1 -> KeccakState
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Jul 1, 2024
1 parent e22c8f2 commit 93558ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions libcrux-ml-dsa/src/hash_functions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(non_snake_case)]

pub(crate) mod H {
use libcrux_sha3::portable::{incremental, shake256, KeccakState1};
use libcrux_sha3::portable::{incremental, shake256, KeccakState};

const BLOCK_SIZE: usize = 136;

Expand All @@ -13,23 +13,23 @@ pub(crate) mod H {
}

#[inline(always)]
pub(crate) fn new(seed: &[u8]) -> KeccakState1 {
pub(crate) fn new(seed: &[u8]) -> KeccakState {
let mut state = incremental::shake256_init();
incremental::shake256_absorb_final(&mut state, seed);

state
}

#[inline(always)]
pub(crate) fn squeeze_first_block(state: &mut KeccakState1) -> [u8; BLOCK_SIZE] {
pub(crate) fn squeeze_first_block(state: &mut KeccakState) -> [u8; BLOCK_SIZE] {
let mut out = [0u8; BLOCK_SIZE];
incremental::shake256_squeeze_first_block(state, &mut out);

out
}

#[inline(always)]
pub(crate) fn squeeze_next_block(state: &mut KeccakState1) -> [u8; BLOCK_SIZE] {
pub(crate) fn squeeze_next_block(state: &mut KeccakState) -> [u8; BLOCK_SIZE] {
let mut out = [0u8; BLOCK_SIZE];
incremental::shake256_squeeze_next_block(state, &mut out);

Expand Down
24 changes: 12 additions & 12 deletions libcrux-sha3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,26 +277,26 @@ pub mod portable {

/// Create a new SHAKE-256 state object.
#[inline(always)]
pub fn shake256_init() -> KeccakState1 {
KeccakState1 {
state: KeccakState::<1, u64>::new(),
pub fn shake256_init() -> KeccakState {
KeccakState {
state: GenericState::<1, u64>::new(),
}
}
/// Absorb some data for SHAKE-256 for the last time
#[inline(always)]
pub fn shake256_absorb_final(s: &mut KeccakState1, data0: &[u8]) {
pub fn shake256_absorb_final(s: &mut KeccakState, data0: &[u8]) {
absorb_final::<1, u64, 136, 0x1fu8>(&mut s.state, [data0]);
}

/// Squeeze the first SHAKE-256 block
#[inline(always)]
pub fn shake256_squeeze_first_block(s: &mut KeccakState1, out0: &mut [u8]) {
pub fn shake256_squeeze_first_block(s: &mut KeccakState, out0: &mut [u8]) {
squeeze_first_block::<1, u64, 136>(&mut s.state, [out0])
}

/// Squeeze the next SHAKE-256 block
#[inline(always)]
pub fn shake256_squeeze_next_block(s: &mut KeccakState1, out0: &mut [u8]) {
pub fn shake256_squeeze_next_block(s: &mut KeccakState, out0: &mut [u8]) {
squeeze_next_block::<1, u64, 136>(&mut s.state, [out0])
}
}
Expand Down Expand Up @@ -480,8 +480,8 @@ pub mod neon {
// XXX: These functions could alternatively implement the same with
// the portable implementation
// {
// let s0 = KeccakState1::new();
// let s1 = KeccakState1::new();
// let s0 = KeccakState::new();
// let s1 = KeccakState::new();
// [s0, s1]
// }
#[cfg(feature = "simd128")]
Expand Down Expand Up @@ -848,10 +848,10 @@ pub mod avx2 {
// }
// #[cfg(not(any(feature = "simd128", feature = "simd256")))]
// {
// let s0 = KeccakState1::new();
// let s1 = KeccakState1::new();
// let s2 = KeccakState1::new();
// let s3 = KeccakState1::new();
// let s0 = KeccakState::new();
// let s1 = KeccakState::new();
// let s2 = KeccakState::new();
// let s3 = KeccakState::new();
// [s0, s1, s2, s3]
// }
#[cfg(feature = "simd256")]
Expand Down

0 comments on commit 93558ba

Please sign in to comment.