Debian Codegraph @

src/multisig/multisig_clsag_context.h

raw symbols SCIP
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 // References
31 // - CLSAG (base signature scheme): https://eprint.iacr.org/2019/654
32 // - MuSig2 (style for multisig signing): https://eprint.iacr.org/2020/1261
33 ///
34
35
36 #pragma once
37
38 #include "ringct/rctTypes.h"
39
40 #include <vector>
41
42
43 namespace multisig {
44
45 namespace signing {
46
47 class CLSAG_context_t final {
48 private:
49 // is the CLSAG context initialized?
50 bool initialized;
51 // challenge components: c = H(domain-separator, {P}, {C}, C_offset, message, L, R)
52 rct::keyV c_params;
53 // indices in c_params where L and R will be
54 std::size_t c_params_L_offset;
55 std::size_t c_params_R_offset;
56 // musig2-style nonce combination factor components for multisig signing
57 // b = H(domain-separator, {P}, {C}, C_offset, message, {L_combined_alphas}, {R_combined_alphas}, I, D, {s_non_l}, l, k, n)
58 // - {P} = ring of one-time addresses
59 // - {C} = ring of amount commitments (1:1 with one-time addresses)
60 // - C_offset = pseudo-output commitment to offset all amount commitments with
61 // - message = message the CLSAG will sign
62 // - {L_combined_alphas} = set of summed-together public nonces from all multisig signers for this CLSAG's L component
63 // - {R_combined_alphas} = set of summed-together public nonces from all multisig signers for this CLSAG's R component
64 // - I = key image for one-time address at {P}[l]
65 // - D = auxiliary key image for the offsetted amount commitment '{C}[l] - C_offset'
66 // - {s_non_l} = fake responses for this proof
67 // - l = real signing index in {P} and '{C} - C_offset'
68 // - k = number of parallel nonces that each participant provides
69 // - n = number of ring members
70 rct::keyV b_params;
71 // indices in b_params where L and R 'alpha' components will be
72 std::size_t b_params_L_offset;
73 std::size_t b_params_R_offset;
74 // CLSAG 'concise' coefficients for {P} and '{C} - C_offset'
75 // mu_x = H(domain-separator, {P}, {C}, I, (1/8)*D, C_offset)
76 // - note: 'D' is stored in the form '(1/8)*D' in transaction data
77 rct::key mu_P;
78 rct::key mu_C;
79 // ring size
80 std::size_t n;
81 // aggregate key image: mu_P*I + mu_C*D
82 rct::geDsmp wH_l_precomp;
83 // aggregate ring members: mu_P*P_i + mu_C*(C_i - C_offset)
84 std::vector<rct::geDsmp> W_precomp;
85 // key image component base keys: H_p(P_i)
86 std::vector<rct::geDsmp> H_precomp;
87 // cache for later: generator 'G' in 'precomp' representation
88 rct::geDsmp G_precomp;
89 // real signing index in this CLSAG
90 std::size_t l;
91 // signature responses
92 rct::keyV s;
93 // number of signing nonces expected per signer
94 std::size_t num_alpha_components;
95 public:
96 CLSAG_context_t() : initialized{false} {}
97
98 // prepare CLSAG challenge context
99 bool init(
100 const rct::keyV& P,
101 const rct::keyV& C_nonzero,
102 const rct::key& C_offset,
103 const rct::key& message,
104 const rct::key& I,
105 const rct::key& D,
106 const unsigned int l,
107 const rct::keyV& s,
108 const std::size_t num_alpha_components
109 );
110
111 // get the local signer's combined musig2-style private nonce and compute the CLSAG challenge
112 bool combine_alpha_and_compute_challenge(
113 // set of summed-together musig2-style public nonces from all multisig signers for this CLSAG's L component
114 const rct::keyV& total_alpha_G,
115 // set of summed-together musig2-style public nonces from all multisig signers for this CLSAG's R component
116 const rct::keyV& total_alpha_H,
117 // local signer's private musig2-style nonces
118 const rct::keyV& alpha,
119 // local signer's final private nonce, using musig2-style combination with factor 'b'
120 // alpha_combined = sum_i(b^i * alpha[i])
121 rct::key& alpha_combined,
122 // CLSAG challenge to store in the proof
123 rct::key& c_0,
124 // final CLSAG challenge to respond to (need this to make multisig partial signatures)
125 rct::key& c
126 );
127
128 // getter for CLSAG 'concise' coefficients
129 bool get_mu(
130 rct::key& mu_P,
131 rct::key& mu_C
132 ) const;
133 };
134
135 } //namespace signing
136
137 } //namespace multisig