Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_CRYPTO_SHA3_H6#define BITCOIN_CRYPTO_SHA3_H8#include <cstddef>9#include <cstdint>10#include <span>12//! The Keccak-f[1600] transform.13void KeccakF(uint64_t (&st)[25]);15class SHA3_25616{17private:18uint64_t m_state[25] = {0};19unsigned char m_buffer[8];20unsigned m_bufsize = 0;21unsigned m_pos = 0;23//! Sponge rate in bits.24static constexpr unsigned RATE_BITS = 1088;26//! Sponge rate expressed as a multiple of the buffer size.27static constexpr unsigned RATE_BUFFERS = RATE_BITS / (8 * sizeof(m_buffer));29static_assert(RATE_BITS % (8 * sizeof(m_buffer)) == 0, "Rate must be a multiple of 8 bytes");31public:32static constexpr size_t OUTPUT_SIZE = 32;34SHA3_256() = default;35SHA3_256& Write(std::span<const unsigned char> data);36SHA3_256& Finalize(std::span<unsigned char> output);37SHA3_256& Reset();38};40#endif // BITCOIN_CRYPTO_SHA3_H