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 ripple {
7
8// Used to construct received proposals
10 PublicKey const& publicKey,
11 Slice const& signature,
12 uint256 const& suppression,
14 : publicKey_(publicKey)
15 , suppression_(suppression)
16 , proposal_(std::move(proposal))
17{
18 // The maximum allowed size of a signature is 72 bytes; we verify
19 // this elsewhere, but we want to be extra careful here:
20 XRPL_ASSERT(
21 signature.size() != 0 && signature.size() <= signature_.capacity(),
22 "ripple::RCLCxPeerPos::RCLCxPeerPos : valid signature size");
23
24 if (signature.size() != 0 && signature.size() <= signature_.capacity())
26}
27
28bool
30{
31 return verifyDigest(
33}
34
37{
38 auto ret = proposal().getJson();
39
40 if (publicKey().size())
41 ret[jss::peer_id] = toBase58(TokenType::NodePublic, publicKey());
42
43 return ret;
44}
45
48 uint256 const& proposeHash,
49 uint256 const& previousLedger,
50 std::uint32_t proposeSeq,
51 NetClock::time_point closeTime,
52 Slice const& publicKey,
53 Slice const& signature)
54{
55 Serializer s(512);
56 s.addBitString(proposeHash);
57 s.addBitString(previousLedger);
58 s.add32(proposeSeq);
59 s.add32(closeTime.time_since_epoch().count());
60 s.addVL(publicKey);
61 s.addVL(signature);
62
63 return s.getSHA512Half();
64}
65
66} // namespace ripple
Represents a JSON value.
Definition json_value.h:131
uint256 const & signingHash() const
The digest for this proposal, used for signing purposes.
Json::Value getJson() const
Get JSON representation for debugging.
A public key.
Definition PublicKey.h:43
Proposal const & proposal() const
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.
Json::Value getJson() const
JSON representation of proposal.
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
Slice signature() const
Signature of the proposal (not necessarily verified)
uint256 getSHA512Half() const
int addBitString(base_uint< Bits, Tag > const &v)
Definition Serializer.h:112
int addVL(Blob const &vector)
An immutable linear range of bytes.
Definition Slice.h:27
const_iterator begin() const noexcept
Definition Slice.h:130
const_iterator end() const noexcept
Definition Slice.h:142
std::size_t size() const noexcept
Returns the number of bytes in the storage.
Definition Slice.h:62
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:95
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.
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.
@ proposal
proposal for signing
STL namespace.
T time_since_epoch(T... args)