rippled
Loading...
Searching...
No Matches
RCLCxPeerPos.cpp
1#include <xrpld/app/consensus/RCLCxPeerPos.h>
2
3#include <xrpl/protocol/Serializer.h>
4#include <xrpl/protocol/jss.h>
5
6namespace xrpl {
7
8// Used to construct received proposals
10 PublicKey const& publicKey,
11 Slice const& signature,
12 uint256 const& suppression,
14 : publicKey_(publicKey), suppression_(suppression), proposal_(std::move(proposal))
15{
16 // The maximum allowed size of a signature is 72 bytes; we verify
17 // this elsewhere, but we want to be extra careful here:
18 XRPL_ASSERT(
19 signature.size() != 0 && signature.size() <= signature_.capacity(),
20 "xrpl::RCLCxPeerPos::RCLCxPeerPos : valid signature size");
21
22 if (signature.size() != 0 && signature.size() <= signature_.capacity())
24}
25
26bool
31
34{
35 auto ret = proposal().getJson();
36
37 if (publicKey().size())
38 ret[jss::peer_id] = toBase58(TokenType::NodePublic, publicKey());
39
40 return ret;
41}
42
45 uint256 const& proposeHash,
46 uint256 const& previousLedger,
47 std::uint32_t proposeSeq,
48 NetClock::time_point closeTime,
49 Slice const& publicKey,
50 Slice const& signature)
51{
52 Serializer s(512);
53 s.addBitString(proposeHash);
54 s.addBitString(previousLedger);
55 s.add32(proposeSeq);
56 s.add32(closeTime.time_since_epoch().count());
57 s.addVL(publicKey);
58 s.addVL(signature);
59
60 return s.getSHA512Half();
61}
62
63} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Json::Value getJson() const
Get JSON representation for debugging.
uint256 const & signingHash() const
The digest for this proposal, used for signing purposes.
A public key.
Definition PublicKey.h:42
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
Slice signature() const
Signature of the proposal (not necessarily verified)
boost::container::static_vector< std::uint8_t, 72 > signature_
RCLCxPeerPos(PublicKey const &publicKey, Slice const &signature, uint256 const &suppress, Proposal &&proposal)
Constructor.
bool checkSign() const
Verify the signing hash of the proposal.
Proposal const & proposal() const
Json::Value getJson() const
JSON representation of proposal.
int addBitString(base_uint< Bits, Tag > const &v)
Definition Serializer.h:105
uint256 getSHA512Half() const
int addVL(Blob const &vector)
An immutable linear range of bytes.
Definition Slice.h:26
const_iterator begin() const noexcept
Definition Slice.h:126
std::size_t size() const noexcept
Returns the number of bytes in the storage.
Definition Slice.h:60
const_iterator end() const noexcept
Definition Slice.h:138
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool verifyDigest(PublicKey const &publicKey, uint256 const &digest, Slice const &sig, bool mustBeFullyCanonical=true) noexcept
Verify a secp256k1 signature on the digest of a message.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:92
@ proposal
proposal for signing
uint256 proposalUniqueId(uint256 const &proposeHash, uint256 const &previousLedger, std::uint32_t proposeSeq, NetClock::time_point closeTime, Slice const &publicKey, Slice const &signature)
Calculate a unique identifier for a signed proposal.
T time_since_epoch(T... args)