Bitcoin Core 32.99.0
P2P Digital Currency
signet.h
Go to the documentation of this file.
1// Copyright (c) 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_KERNEL_SIGNET_H
6#define BITCOIN_KERNEL_SIGNET_H
7
8#include <hash.h>
10#include <uint256.h>
11#include <util/strencodings.h>
12
13#include <algorithm>
14#include <cstdint>
15#include <vector>
16
17namespace kernel {
18using namespace util::hex_literals;
19
20inline const std::vector<uint8_t> SIGNET_DEFAULT_CHALLENGE{
21 "512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae"_hex_v_u8};
22
27inline MessageStartChars GetSignetMessageStart(const std::vector<uint8_t>& signet_challenge)
28{
29 HashWriter h{};
30 h << signet_challenge;
31 const uint256 hash = h.GetHash();
32 MessageStartChars msg_start;
33 std::copy_n(hash.begin(), 4, msg_start.begin());
34 return msg_start;
35}
36} // namespace kernel
37
38#endif // BITCOIN_KERNEL_SIGNET_H
A writer stream (for serialization) that computes a 256-bit hash.
Definition: hash.h:109
constexpr unsigned char * begin()
Definition: uint256.h:101
256-bit opaque blob.
Definition: uint256.h:196
std::array< uint8_t, 4 > MessageStartChars
MessageStartChars GetSignetMessageStart(const std::vector< uint8_t > &signet_challenge)
Return the message start bytes for a signet: the first four bytes of the double-SHA256 hash of the se...
Definition: signet.h:27
const std::vector< uint8_t > SIGNET_DEFAULT_CHALLENGE
Definition: signet.h:20
""_hex is a compile-time user-defined literal returning a std::array<std::byte>, equivalent to ParseH...
Definition: strencodings.h:386