.. index:: single: blake2_core(Key,DigestSize)
.. _blake2_core/2:

.. rst-class:: right

**category**

``blake2_core(Key,DigestSize)``
===============================

* ``Key`` - A list of key bytes. Use the empty list for unkeyed hashing.
* ``DigestSize`` - Number of digest bytes to generate.


Common BLAKE2 hash function core.

| **Availability:** 
|    ``logtalk_load(hashes(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-08-02

| **Compilation flags:**
|    ``static``


| **Implements:**
|    ``public`` :ref:`hash_digest_protocol <hash_digest_protocol/0>`
|    ``public`` :ref:`hash_state_protocol <hash_state_protocol/0>`
| **Uses:**
|    :ref:`hash_common_32 <hash_common_32/0>`
|    :ref:`list <list/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|     :ref:`hash_digest_protocol/0::block_size/1`  :ref:`hash_digest_protocol/0::digest/2`  :ref:`hash_digest_protocol/0::digest_size/1`  :ref:`hash_state_protocol/0::final_hash_state/2`  :ref:`hash_protocol/0::hash/2`  :ref:`hash_state_protocol/0::new_hash_state/1`  :ref:`hash_state_protocol/0::update_hash_state/3`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

(no local declarations; see entity ancestors if any)

Protected predicates
--------------------

.. index:: blake2_max_digest_size/1
.. _blake2_core/2::blake2_max_digest_size/1:

``blake2_max_digest_size/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns the maximum digest size in bytes for the BLAKE2 variant.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_max_digest_size(MaxDigestSize)``
| **Mode and number of proofs:**
|    ``blake2_max_digest_size(--integer)`` - ``one``


------------

.. index:: blake2_max_key_size/1
.. _blake2_core/2::blake2_max_key_size/1:

``blake2_max_key_size/1``
^^^^^^^^^^^^^^^^^^^^^^^^^

Returns the maximum key size in bytes for the BLAKE2 variant.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_max_key_size(MaxKeySize)``
| **Mode and number of proofs:**
|    ``blake2_max_key_size(--integer)`` - ``one``


------------

.. index:: blake2_block_size/1
.. _blake2_core/2::blake2_block_size/1:

``blake2_block_size/1``
^^^^^^^^^^^^^^^^^^^^^^^

Returns the block size in bytes for the BLAKE2 variant.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_block_size(BlockSize)``
| **Mode and number of proofs:**
|    ``blake2_block_size(--integer)`` - ``one``


------------

.. index:: blake2_round_count/1
.. _blake2_core/2::blake2_round_count/1:

``blake2_round_count/1``
^^^^^^^^^^^^^^^^^^^^^^^^

Returns the number of compression rounds for the BLAKE2 variant.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_round_count(RoundCount)``
| **Mode and number of proofs:**
|    ``blake2_round_count(--integer)`` - ``one``


------------

.. index:: blake2_initial_state/2
.. _blake2_core/2::blake2_initial_state/2:

``blake2_initial_state/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^

Computes the initial hash state from the parameter word.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_initial_state(ParameterWord,InitialState)``
| **Mode and number of proofs:**
|    ``blake2_initial_state(+integer,--list(integer))`` - ``one``


------------

.. index:: blake2_working_vector/4
.. _blake2_core/2::blake2_working_vector/4:

``blake2_working_vector/4``
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Initializes the compression working vector from the hash state, byte counter, and final block flag.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_working_vector(State,Total,Final,WorkingVector)``
| **Mode and number of proofs:**
|    ``blake2_working_vector(+list(integer),+integer,+boolean,--list(integer))`` - ``one``


------------

.. index:: blake2_block_words/2
.. _blake2_core/2::blake2_block_words/2:

``blake2_block_words/2``
^^^^^^^^^^^^^^^^^^^^^^^^

Decodes a block of bytes into the message words used by the compression function.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_block_words(Block,MessageWords)``
| **Mode and number of proofs:**
|    ``blake2_block_words(+list(byte),--list(integer))`` - ``one``


------------

.. index:: blake2_g/8
.. _blake2_core/2::blake2_g/8:

``blake2_g/8``
^^^^^^^^^^^^^^

Applies the BLAKE2 G mixing function to four indexed words of the working vector and two message words.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_g(WorkingVector0,AIndex,BIndex,CIndex,DIndex,X,Y,WorkingVector)``
| **Mode and number of proofs:**
|    ``blake2_g(+list(integer),+integer,+integer,+integer,+integer,+integer,+integer,--list(integer))`` - ``one``


------------

.. index:: blake2_finalize/4
.. _blake2_core/2::blake2_finalize/4:

``blake2_finalize/4``
^^^^^^^^^^^^^^^^^^^^^

Finalizes the hash state by combining it with the compression working vector.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_finalize(HashState,WorkingVector,Index,FinalState)``
| **Mode and number of proofs:**
|    ``blake2_finalize(+list(integer),+list(integer),+integer,--list(integer))`` - ``one``


------------

.. index:: blake2_state_bytes/2
.. _blake2_core/2::blake2_state_bytes/2:

``blake2_state_bytes/2``
^^^^^^^^^^^^^^^^^^^^^^^^

Encodes the hash state words as little-endian bytes.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``blake2_state_bytes(State,Bytes)``
| **Mode and number of proofs:**
|    ``blake2_state_bytes(+list(integer),--list(byte))`` - ``one``


------------

.. index:: replace_nth0/4
.. _blake2_core/2::replace_nth0/4:

``replace_nth0/4``
^^^^^^^^^^^^^^^^^^

Replaces the element at the zero-based index in a list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``replace_nth0(Index,List0,Element,List)``
| **Mode and number of proofs:**
|    ``replace_nth0(+integer,+list,+term,--list)`` - ``one``


------------

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

