Bitcoin Core
22.99.0
P2P Digital Currency
src
crypto
sha3.h
Go to the documentation of this file.
1
// Copyright (c) 2020 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_CRYPTO_SHA3_H
6
#define BITCOIN_CRYPTO_SHA3_H
7
8
#include <
span.h
>
9
10
#include <stdint.h>
11
#include <stdlib.h>
12
14
void
KeccakF
(uint64_t (&st)[25]);
15
16
class
SHA3_256
17
{
18
private
:
19
uint64_t
m_state
[25] = {0};
20
unsigned
char
m_buffer
[8];
21
unsigned
m_bufsize
= 0;
22
unsigned
m_pos
= 0;
23
25
static
constexpr
unsigned
RATE_BITS
= 1088;
26
28
static
constexpr
unsigned
RATE_BUFFERS
=
RATE_BITS
/ (8 *
sizeof
(
m_buffer
));
29
30
static_assert(
RATE_BITS
% (8 *
sizeof
(
m_buffer
)) == 0,
"Rate must be a multiple of 8 bytes"
);
31
32
public
:
33
static
constexpr
size_t
OUTPUT_SIZE
= 32;
34
35
SHA3_256
() {}
36
SHA3_256
&
Write
(
Span<const unsigned char>
data);
37
SHA3_256
&
Finalize
(
Span<unsigned char>
output);
38
SHA3_256
&
Reset
();
39
};
40
41
#endif // BITCOIN_CRYPTO_SHA3_H
SHA3_256::OUTPUT_SIZE
static constexpr size_t OUTPUT_SIZE
Definition:
sha3.h:33
SHA3_256::m_buffer
unsigned char m_buffer[8]
Definition:
sha3.h:20
SHA3_256::m_bufsize
unsigned m_bufsize
Definition:
sha3.h:21
SHA3_256
Definition:
sha3.h:16
SHA3_256::Reset
SHA3_256 & Reset()
Definition:
sha3.cpp:155
Span< const unsigned char >
SHA3_256::m_state
uint64_t m_state[25]
Definition:
sha3.h:19
SHA3_256::m_pos
unsigned m_pos
Definition:
sha3.h:22
span.h
SHA3_256::SHA3_256
SHA3_256()
Definition:
sha3.h:35
SHA3_256::Write
SHA3_256 & Write(Span< const unsigned char > data)
Definition:
sha3.cpp:111
SHA3_256::RATE_BUFFERS
static constexpr unsigned RATE_BUFFERS
Sponge rate expressed as a multiple of the buffer size.
Definition:
sha3.h:28
SHA3_256::Finalize
SHA3_256 & Finalize(Span< unsigned char > output)
Definition:
sha3.cpp:141
KeccakF
void KeccakF(uint64_t(&st)[25])
The Keccak-f[1600] transform.
Definition:
sha3.cpp:23
SHA3_256::RATE_BITS
static constexpr unsigned RATE_BITS
Sponge rate in bits.
Definition:
sha3.h:25
Generated on Fri Feb 18 2022 20:03:17 for Bitcoin Core by
1.8.17