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#include <cstdint>
25
26namespace ripple {
27
28namespace detail {
29
30constexpr std::uint32_t
31make_hash_prefix(char a, char b, char c)
32{
33 return (static_cast<std::uint32_t>(a) << 24) +
34 (static_cast<std::uint32_t>(b) << 16) +
35 (static_cast<std::uint32_t>(c) << 8);
36}
37
38} // namespace detail
39
57
59 txNode = detail::make_hash_prefix('S', 'N', 'D'),
60
62 leafNode = detail::make_hash_prefix('M', 'L', 'N'),
63
65 innerNode = detail::make_hash_prefix('M', 'I', 'N'),
66
69
71 txSign = detail::make_hash_prefix('S', 'T', 'X'),
72
75
77 validation = detail::make_hash_prefix('V', 'A', 'L'),
78
80 proposal = detail::make_hash_prefix('P', 'R', 'P'),
81
83 manifest = detail::make_hash_prefix('M', 'A', 'N'),
84
87
89 credential = detail::make_hash_prefix('C', 'R', 'D'),
90};
91
92template <class Hasher>
93void
94hash_append(Hasher& h, HashPrefix const& hp) noexcept
95{
97 hash_append(h, static_cast<std::uint32_t>(hp));
98}
99
100} // namespace ripple
101
102#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.
Definition: hash_append.h:236
constexpr std::uint32_t make_hash_prefix(char a, char b, char c)
Definition: HashPrefix.h:31
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
void hash_append(Hasher &h, Slice const &v)
Definition: Slice.h:198
HashPrefix
Prefix for hashing functions.
Definition: HashPrefix.h:54
@ 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.