rippled
Loading...
Searching...
No Matches
HashPrefix.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_PROTOCOL_HASHPREFIX_H_INCLUDED
21#define RIPPLE_PROTOCOL_HASHPREFIX_H_INCLUDED
22
23#include <xrpl/beast/hash/hash_append.h>
24
25#include <cstdint>
26
27namespace ripple {
28
29namespace detail {
30
31constexpr std::uint32_t
32make_hash_prefix(char a, char b, char c)
33{
34 return (static_cast<std::uint32_t>(a) << 24) +
35 (static_cast<std::uint32_t>(b) << 16) +
36 (static_cast<std::uint32_t>(c) << 8);
37}
38
39} // namespace detail
40
58
60 txNode = detail::make_hash_prefix('S', 'N', 'D'),
61
63 leafNode = detail::make_hash_prefix('M', 'L', 'N'),
64
66 innerNode = detail::make_hash_prefix('M', 'I', 'N'),
67
70
72 txSign = detail::make_hash_prefix('S', 'T', 'X'),
73
76
78 validation = detail::make_hash_prefix('V', 'A', 'L'),
79
81 proposal = detail::make_hash_prefix('P', 'R', 'P'),
82
84 manifest = detail::make_hash_prefix('M', 'A', 'N'),
85
88
90 credential = detail::make_hash_prefix('C', 'R', 'D'),
91
93 batch = detail::make_hash_prefix('B', 'C', 'H'),
94};
95
96template <class Hasher>
97void
98hash_append(Hasher& h, HashPrefix const& hp) noexcept
99{
100 using beast::hash_append;
101 hash_append(h, static_cast<std::uint32_t>(hp));
102}
103
104} // namespace ripple
105
106#endif
std::enable_if_t< is_contiguously_hashable< T, Hasher >::value > hash_append(Hasher &h, T const &t) noexcept
Logically concatenate input data to a Hasher.
constexpr std::uint32_t make_hash_prefix(char a, char b, char c)
Definition HashPrefix.h:32
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
void hash_append(Hasher &h, Slice const &v)
Definition Slice.h:199
HashPrefix
Prefix for hashing functions.
Definition HashPrefix.h:55
@ leafNode
account state
@ txSign
inner transaction to sign
@ txNode
transaction plus metadata
@ credential
Credentials signature.
@ manifest
Manifest.
@ ledgerMaster
ledger master data for signing
@ txMultiSign
inner transaction to multi-sign
@ transactionID
transaction plus signature to give transaction ID
@ validation
validation for signing
@ proposal
proposal for signing
@ innerNode
inner node in V1 tree
@ paymentChannelClaim
Payment Channel Claim.