rippled
Loading...
Searching...
No Matches
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 <xrpl/basics/Slice.h>
23#include <xrpl/protocol/PublicKey.h>
24#include <xrpl/protocol/SecretKey.h>
25#include <xrpl/protocol/XChainAttestations.h>
26
27namespace ripple {
28namespace test {
29namespace jtx {
30
31Buffer
33 PublicKey const& pk,
34 SecretKey const& sk,
36 AccountID const& sendingAccount,
37 STAmount const& sendingAmount,
38 AccountID const& rewardAccount,
39 bool wasLockingChainSend,
40 std::uint64_t claimID,
41 std::optional<AccountID> const& dst)
42{
44 bridge,
45 sendingAccount,
46 sendingAmount,
47 rewardAccount,
48 wasLockingChainSend,
49 claimID,
50 dst);
51 return sign(pk, sk, makeSlice(toSign));
52}
53
56 PublicKey const& pk,
57 SecretKey const& sk,
59 AccountID const& sendingAccount,
60 STAmount const& sendingAmount,
61 STAmount const& rewardAmount,
62 AccountID const& rewardAccount,
63 bool wasLockingChainSend,
64 std::uint64_t createCount,
65 AccountID const& dst)
66{
68 bridge,
69 sendingAccount,
70 sendingAmount,
71 rewardAmount,
72 rewardAccount,
73 wasLockingChainSend,
74 createCount,
75 dst);
76 return sign(pk, sk, makeSlice(toSign));
77}
78
79} // namespace jtx
80} // namespace test
81} // namespace ripple
Like std::vector<char> but better.
Definition Buffer.h:36
A public key.
Definition PublicKey.h:61
A secret key.
Definition SecretKey.h:38
Json::Value bridge(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
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:32
void sign(Json::Value &jv, Account const &account)
Sign automatically.
Definition utility.cpp:47
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:55
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
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:244
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)
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)