Monero
multisig_tx_builder_ringct.h
Go to the documentation of this file.
1 // Copyright (c) 2021, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 
30 #pragma once
31 
32 #include "ringct/rctTypes.h"
33 
34 #include <set>
35 #include <vector>
36 
37 namespace cryptonote {
38 
39 class transaction;
40 struct tx_source_entry;
41 struct tx_destination_entry;
42 struct account_keys;
43 
44 }
45 
46 namespace multisig {
47 
48 namespace signing {
49 
50 class CLSAG_context_t;
51 
52 // number of parallel signing nonces to use per signer (2 nonces as in musig2 and FROST)
53 constexpr std::size_t kAlphaComponents = 2;
54 
55 class tx_builder_ringct_t final {
56 private:
57  // the tx builder has been initialized
59  // the tx builder is 'reconstructing' a tx that has already been created using this object
61  // cached: mu_P*(local keys and sender-receiver secret and subaddress material) + mu_C*(commitment-to-zero secret)
62  // - these are only used for the initial building of a tx (not reconstructions)
64  // contexts for making CLSAG challenges with multisig nonces
65  std::vector<CLSAG_context_t> CLSAG_contexts;
66 public:
69 
70  // prepare an unsigned transaction (and get tx privkeys for outputs)
71  bool init(
72  const cryptonote::account_keys& account_keys,
73  const std::vector<std::uint8_t>& extra,
74  const std::uint32_t subaddr_account,
75  const std::set<std::uint32_t>& subaddr_minor_indices,
76  std::vector<cryptonote::tx_source_entry>& sources,
77  std::vector<cryptonote::tx_destination_entry>& destinations,
79  const rct::RCTConfig& rct_config,
80  const bool use_rct,
81  const bool reconstruction,
82  crypto::secret_key& tx_secret_key,
83  std::vector<crypto::secret_key>& tx_aux_secret_keys,
84  crypto::secret_key& tx_secret_key_entropy,
85  cryptonote::transaction& unsigned_tx
86  );
87 
88  // get the first partial signature for the specified input ('source')
89  bool first_partial_sign(
90  const std::size_t source,
91  const rct::keyV& total_alpha_G,
92  const rct::keyV& total_alpha_H,
93  const rct::keyV& alpha,
94  rct::key& c_0,
95  rct::key& s
96  );
97 
98  // get intermediate partial signatures for all the inputs
99  bool next_partial_sign(
100  const rct::keyM& total_alpha_G,
101  const rct::keyM& total_alpha_H,
102  const rct::keyM& alpha,
103  const rct::key& x,
104  rct::keyV& c_0,
105  rct::keyV& s
106  );
107 
108  // finalize an unsigned transaction (add challenges and real responses to incomplete CLSAG signatures)
109  static bool finalize_tx(
110  const std::vector<cryptonote::tx_source_entry>& sources,
111  const rct::keyV& c_0,
112  const rct::keyV& s,
113  cryptonote::transaction& unsigned_tx
114  );
115 };
116 
117 } //namespace signing
118 
119 } //namespace multisig
const CharType(& source)[N]
Definition: pointer.h:1147
tx_builder_ringct_t()
Definition: multisig_tx_builder_ringct.cpp:813
bool init(const cryptonote::account_keys &account_keys, const std::vector< std::uint8_t > &extra, const std::uint32_t subaddr_account, const std::set< std::uint32_t > &subaddr_minor_indices, std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations, const cryptonote::tx_destination_entry &change, const rct::RCTConfig &rct_config, const bool use_rct, const bool reconstruction, crypto::secret_key &tx_secret_key, std::vector< crypto::secret_key > &tx_aux_secret_keys, crypto::secret_key &tx_secret_key_entropy, cryptonote::transaction &unsigned_tx)
Definition: multisig_tx_builder_ringct.cpp:820
std::vector< CLSAG_context_t > CLSAG_contexts
Definition: multisig_tx_builder_ringct.h:65
const char * s
Definition: minissdp.c:596
static bool finalize_tx(const std::vector< cryptonote::tx_source_entry > &sources, const rct::keyV &c_0, const rct::keyV &s, cryptonote::transaction &unsigned_tx)
Definition: multisig_tx_builder_ringct.cpp:1028
std::vector< key > keyV
Definition: rctTypes.h:89
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
bool initialized
Definition: multisig_tx_builder_ringct.h:58
~tx_builder_ringct_t()
Definition: multisig_tx_builder_ringct.cpp:815
Definition: multisig_tx_builder_ringct.h:55
unsigned int uint32_t
Definition: stdint.h:126
bool reconstruction
Definition: multisig_tx_builder_ringct.h:60
Definition: rctTypes.h:79
Definition: account.h:40
constexpr std::size_t kAlphaComponents
Definition: multisig_tx_builder_ringct.h:53
std::vector< keyV > keyM
Definition: rctTypes.h:90
rct::keyV cached_w
Definition: multisig_tx_builder_ringct.h:63
Definition: rctTypes.h:308
Definition: cryptonote_tx_utils.h:74
Definition: multisig.cpp:45
bool first_partial_sign(const std::size_t source, const rct::keyV &total_alpha_G, const rct::keyV &total_alpha_H, const rct::keyV &alpha, rct::key &c_0, rct::key &s)
Definition: multisig_tx_builder_ringct.cpp:935
Definition: cryptonote_basic.h:204
bool next_partial_sign(const rct::keyM &total_alpha_G, const rct::keyM &total_alpha_H, const rct::keyM &alpha, const rct::key &x, rct::keyV &c_0, rct::keyV &s)
Definition: multisig_tx_builder_ringct.cpp:972