rippled
attester.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2022 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 #include <test/jtx/attester.h>
21 
22 #include <ripple/basics/Slice.h>
23 #include <ripple/protocol/PublicKey.h>
24 #include <ripple/protocol/STXChainBridge.h>
25 #include <ripple/protocol/SecretKey.h>
26 #include <ripple/protocol/XChainAttestations.h>
27 
28 namespace ripple {
29 namespace test {
30 namespace jtx {
31 
32 Buffer
34  PublicKey const& pk,
35  SecretKey const& sk,
36  STXChainBridge const& bridge,
37  AccountID const& sendingAccount,
38  STAmount const& sendingAmount,
39  AccountID const& rewardAccount,
40  bool wasLockingChainSend,
41  std::uint64_t claimID,
42  std::optional<AccountID> const& dst)
43 {
44  auto const toSign = Attestations::AttestationClaim::message(
45  bridge,
46  sendingAccount,
47  sendingAmount,
48  rewardAccount,
49  wasLockingChainSend,
50  claimID,
51  dst);
52  return sign(pk, sk, makeSlice(toSign));
53 }
54 
55 Buffer
57  PublicKey const& pk,
58  SecretKey const& sk,
59  STXChainBridge const& bridge,
60  AccountID const& sendingAccount,
61  STAmount const& sendingAmount,
62  STAmount const& rewardAmount,
63  AccountID const& rewardAccount,
64  bool wasLockingChainSend,
65  std::uint64_t createCount,
66  AccountID const& dst)
67 {
69  bridge,
70  sendingAccount,
71  sendingAmount,
72  rewardAmount,
73  rewardAccount,
74  wasLockingChainSend,
75  createCount,
76  dst);
77  return sign(pk, sk, makeSlice(toSign));
78 }
79 
80 } // namespace jtx
81 } // namespace test
82 } // namespace ripple
ripple::makeSlice
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Definition: Slice.h:241
ripple::test::jtx::sign_create_account_attestation
Buffer sign_create_account_attestation(PublicKey const &pk, SecretKey const &sk, STXChainBridge const &bridge, AccountID const &sendingAccount, STAmount const &sendingAmount, STAmount const &rewardAmount, AccountID const &rewardAccount, bool wasLockingChainSend, std::uint64_t createCount, AccountID const &dst)
Definition: attester.cpp:56
ripple::Attestations::AttestationClaim::message
static std::vector< std::uint8_t > message(STXChainBridge const &bridge, AccountID const &sendingAccount, STAmount const &sendingAmount, AccountID const &rewardAccount, bool wasLockingChainSend, std::uint64_t claimID, std::optional< AccountID > const &dst)
Definition: XChainAttestations.cpp:215
ripple::Buffer
Like std::vector<char> but better.
Definition: Buffer.h:35
ripple::test::jtx::sign
void sign(Json::Value &jv, Account const &account)
Sign automatically.
Definition: utility.cpp:46
ripple::test::jtx::bridge
Json::Value bridge(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
Definition: xchain_bridge.cpp:40
ripple::test::jtx::sign_claim_attestation
Buffer sign_claim_attestation(PublicKey const &pk, SecretKey const &sk, STXChainBridge const &bridge, AccountID const &sendingAccount, STAmount const &sendingAmount, AccountID const &rewardAccount, bool wasLockingChainSend, std::uint64_t claimID, std::optional< AccountID > const &dst)
Definition: attester.cpp:33
ripple::base_uint< 160, detail::AccountIDTag >
ripple::PublicKey
A public key.
Definition: PublicKey.h:61
ripple::STAmount
Definition: STAmount.h:46
std::uint64_t
ripple::SecretKey
A secret key.
Definition: SecretKey.h:36
ripple::STXChainBridge
Definition: STXChainBridge.h:32
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Attestations::AttestationCreateAccount::message
static std::vector< std::uint8_t > message(STXChainBridge const &bridge, AccountID const &sendingAccount, STAmount const &sendingAmount, STAmount const &rewardAmount, AccountID const &rewardAccount, bool wasLockingChainSend, std::uint64_t createCount, AccountID const &dst)
Definition: XChainAttestations.cpp:359
std::optional