|
| 1 | +/** |
| 2 | + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) |
| 3 | + * |
| 4 | + * This file is part of libbitcoin. |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Affero General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Affero General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Affero General Public License |
| 17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | +#ifndef LIBBITCOIN_SYSTEM_CHAIN_SILENT_PAYMENT_HPP |
| 20 | +#define LIBBITCOIN_SYSTEM_CHAIN_SILENT_PAYMENT_HPP |
| 21 | + |
| 22 | +#include <optional> |
| 23 | +#include <bitcoin/system/chain/block.hpp> |
| 24 | +#include <bitcoin/system/chain/input.hpp> |
| 25 | +#include <bitcoin/system/chain/transaction.hpp> |
| 26 | +#include <bitcoin/system/crypto/secp256k1.hpp> |
| 27 | +#include <bitcoin/system/define.hpp> |
| 28 | + |
| 29 | +namespace libbitcoin { |
| 30 | +namespace system { |
| 31 | +namespace chain { |
| 32 | +namespace silent_payment { |
| 33 | + |
| 34 | +struct BC_API output |
| 35 | +{ |
| 36 | + uint32_t index{}; |
| 37 | + ec_xonly key{}; |
| 38 | +}; |
| 39 | + |
| 40 | +struct BC_API record |
| 41 | +{ |
| 42 | + ec_compressed tweak_key{}; |
| 43 | + std_vector<output> outputs{}; |
| 44 | +}; |
| 45 | + |
| 46 | +struct BC_API match |
| 47 | +{ |
| 48 | + uint32_t index{}; |
| 49 | + ec_secret tweak{}; |
| 50 | + std::optional<uint32_t> label{}; |
| 51 | +}; |
| 52 | + |
| 53 | +struct BC_API scan_context |
| 54 | +{ |
| 55 | + ec_secret scan_secret{}; |
| 56 | + ec_compressed spend_public{}; |
| 57 | + ec_uncompressed spend_point{}; |
| 58 | + std_vector<uint32_t> labels{}; |
| 59 | + secret_list label_tweaks{}; |
| 60 | + uncompressed_list label_points_uncompressed{}; |
| 61 | + bool valid{}; |
| 62 | +}; |
| 63 | + |
| 64 | +typedef std_vector<record> records; |
| 65 | +typedef std_vector<match> matches; |
| 66 | + |
| 67 | +BC_API bool to_even_compressed(ec_compressed& out, |
| 68 | + const ec_xonly& point) NOEXCEPT; |
| 69 | +BC_API bool label_tweak(ec_secret& out, const ec_secret& scan_secret, |
| 70 | + uint32_t label) NOEXCEPT; |
| 71 | +BC_API bool is_excluded_segwit_future(const input& in) NOEXCEPT; |
| 72 | +BC_API bool is_nums_internal_key(const input& in) NOEXCEPT; |
| 73 | +BC_API bool extract_shared_secret_key(ec_compressed& out, |
| 74 | + const input& in) NOEXCEPT; |
| 75 | +BC_API bool compute_input_hash(ec_secret& out, const transaction& tx, |
| 76 | + const ec_compressed& sum) NOEXCEPT; |
| 77 | +BC_API bool compute_scan_record(record& out, |
| 78 | + const transaction& tx) NOEXCEPT; |
| 79 | +BC_API bool compute_scan_records(records& out, const block& block) NOEXCEPT; |
| 80 | +BC_API bool create_scan_context(scan_context& out, |
| 81 | + const ec_secret& scan_secret, const ec_compressed& spend_public, |
| 82 | + const std_vector<uint32_t>& labels) NOEXCEPT; |
| 83 | +BC_API bool scan_outputs(matches& out, const ec_secret& scan_secret, |
| 84 | + const ec_compressed& spend_public, const std_vector<uint32_t>& labels, |
| 85 | + const ec_compressed& tweak_key, |
| 86 | + const std_vector<output>& outputs) NOEXCEPT; |
| 87 | +BC_API bool scan_outputs(matches& out, const scan_context& context, |
| 88 | + const ec_compressed& tweak_key, |
| 89 | + const std_vector<output>& outputs) NOEXCEPT; |
| 90 | +BC_API bool scan_outputs(matches& out, const scan_context& context, |
| 91 | + const ec_uncompressed& tweak_key, |
| 92 | + const std_vector<output>& outputs) NOEXCEPT; |
| 93 | +BC_API bool match_outputs(bool& out, const scan_context& context, |
| 94 | + const ec_compressed& tweak_key, |
| 95 | + const std_vector<output>& outputs) NOEXCEPT; |
| 96 | +BC_API bool match_outputs(bool& out, const scan_context& context, |
| 97 | + const ec_uncompressed& tweak_key, |
| 98 | + const std_vector<output>& outputs) NOEXCEPT; |
| 99 | + |
| 100 | +} // namespace silent_payment |
| 101 | +} // namespace chain |
| 102 | +} // namespace system |
| 103 | +} // namespace libbitcoin |
| 104 | + |
| 105 | +#endif |
0 commit comments