Template Struct ChaChaState
Defined in File chacha_simd.hpp
Struct Documentation
-
template<class Arch, std::uint8_t R>
struct ChaChaState SIMD state for the ChaCha generator. Contains the matrix state, SIMD block cache, and all generation logic.
- Template Parameters:
Arch – The xsimd architecture type.
R – Number of ChaCha rounds.
Public Types
-
using input_word = std::uint64_t
-
using matrix_word = std::uint32_t
-
using matrix_type = std::array<matrix_word, MATRIX_WORDCOUNT>
-
using simd_type = xsimd::batch<matrix_word, Arch>
-
using working_state_type = std::array<simd_type, MATRIX_WORDCOUNT>
-
using cache_block_type = std::array<simd_type, BLOCK_SEGMENTCOUNT>
-
using cache_batch_type = std::array<cache_block_type, SIMD_WIDTH>
Public Functions
-
inline explicit ChaChaState(const std::array<matrix_word, KEY_WORDCOUNT> key, const input_word counter, const input_word nonce)
-
inline matrix_type getState(bool prev) const noexcept
-
inline matrix_type next_block() noexcept
Public Members
-
matrix_type m_state
-
std::array<cache_batch_type, CACHE_BATCHCOUNT> m_cache
-
std::uint8_t m_cache_index = CACHE_BLOCKCOUNT
Public Static Functions
-
static inline constexpr std::uint8_t cache_batchcount() noexcept
Public Static Attributes
-
static constexpr auto MATRIX_WORDCOUNT = std::uint8_t{16}
-
static constexpr auto KEY_WORDCOUNT = std::uint8_t{8}
-
static constexpr std::uint8_t SIMD_WIDTH_SHIFT = SIMD_WIDTH > 0 ? static_cast<std::uint8_t>(std::countr_zero(static_cast<unsigned int>(SIMD_WIDTH))) : 0
-
static constexpr std::uint8_t SIMD_WIDTH_MASK = SIMD_WIDTH > 0 ? std::uint8_t(SIMD_WIDTH - 1) : 0
-
static constexpr std::uint8_t BLOCK_SEGMENTCOUNT = SIMD_WIDTH > 0 ? static_cast<std::uint8_t>(MATRIX_WORDCOUNT / SIMD_WIDTH) : 0
-
static constexpr auto CACHE_BATCHCOUNT = cache_batchcount()
-
static constexpr auto CACHE_BLOCKCOUNT = std::uint8_t{CACHE_BATCHCOUNT * SIMD_WIDTH}