0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
bitcoin-bitcoin-core/src/crypto/sha3.h
Hennadii Stepanov 306ccd4927
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
- 2021: f47dda2c58
- 2020: fa0074e2d8
- 2019: aaaaad6ac9
2022-12-24 23:49:50 +00:00

41 lines
1.1 KiB
C++

// Copyright (c) 2020-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CRYPTO_SHA3_H
#define BITCOIN_CRYPTO_SHA3_H
#include <span.h>
#include <cstdlib>
#include <stdint.h>
//! The Keccak-f[1600] transform.
void KeccakF(uint64_t (&st)[25]);
class SHA3_256
{
private:
uint64_t m_state[25] = {0};
unsigned char m_buffer[8];
unsigned m_bufsize = 0;
unsigned m_pos = 0;
//! Sponge rate in bits.
static constexpr unsigned RATE_BITS = 1088;
//! Sponge rate expressed as a multiple of the buffer size.
static constexpr unsigned RATE_BUFFERS = RATE_BITS / (8 * sizeof(m_buffer));
static_assert(RATE_BITS % (8 * sizeof(m_buffer)) == 0, "Rate must be a multiple of 8 bytes");
public:
static constexpr size_t OUTPUT_SIZE = 32;
SHA3_256() {}
SHA3_256& Write(Span<const unsigned char> data);
SHA3_256& Finalize(Span<unsigned char> output);
SHA3_256& Reset();
};
#endif // BITCOIN_CRYPTO_SHA3_H