Skip to content

Commit d8d0733

Browse files
committed
hopefully better mac compiling
1 parent f9be757 commit d8d0733

File tree

5 files changed

+26
-24
lines changed

5 files changed

+26
-24
lines changed

src/carrot_core/account_secrets.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,39 +51,39 @@ void make_carrot_provespend_key(const crypto::secret_key &s_master,
5151
{
5252
// k_ps = H_n(s_m)
5353
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_PROVE_SPEND_KEY>();
54-
derive_scalar(transcript.data(), transcript.size, &s_master, to_bytes(k_prove_spend_out));
54+
derive_scalar(transcript.data(), transcript.size(), &s_master, to_bytes(k_prove_spend_out));
5555
}
5656
//-------------------------------------------------------------------------------------------------------------------
5757
void make_carrot_viewbalance_secret(const crypto::secret_key &s_master,
5858
crypto::secret_key &s_view_balance_out)
5959
{
6060
// s_vb = H_32(s_m)
6161
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_VIEW_BALANCE_SECRET>();
62-
derive_bytes_32(transcript.data(), transcript.size, &s_master, to_bytes(s_view_balance_out));
62+
derive_bytes_32(transcript.data(), transcript.size(), &s_master, to_bytes(s_view_balance_out));
6363
}
6464
//-------------------------------------------------------------------------------------------------------------------
6565
void make_carrot_generateimage_key(const crypto::secret_key &s_view_balance,
6666
crypto::secret_key &k_generate_image_out)
6767
{
6868
// k_gi = H_n(s_vb)
6969
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_GENERATE_IMAGE_KEY>();
70-
derive_scalar(transcript.data(), transcript.size, &s_view_balance, to_bytes(k_generate_image_out));
70+
derive_scalar(transcript.data(), transcript.size(), &s_view_balance, to_bytes(k_generate_image_out));
7171
}
7272
//-------------------------------------------------------------------------------------------------------------------
7373
void make_carrot_viewincoming_key(const crypto::secret_key &s_view_balance,
7474
crypto::secret_key &k_view_out)
7575
{
7676
// k_v = H_n(s_vb)
7777
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_INCOMING_VIEW_KEY>();
78-
derive_scalar(transcript.data(), transcript.size, &s_view_balance, to_bytes(k_view_out));
78+
derive_scalar(transcript.data(), transcript.size(), &s_view_balance, to_bytes(k_view_out));
7979
}
8080
//-------------------------------------------------------------------------------------------------------------------
8181
void make_carrot_generateaddress_secret(const crypto::secret_key &s_view_balance,
8282
crypto::secret_key &s_generate_address_out)
8383
{
8484
// s_ga = H_32(s_vb)
8585
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_GENERATE_ADDRESS_SECRET>();
86-
derive_bytes_32(transcript.data(), transcript.size, &s_view_balance, to_bytes(s_generate_address_out));
86+
derive_bytes_32(transcript.data(), transcript.size(), &s_view_balance, to_bytes(s_generate_address_out));
8787
}
8888
//-------------------------------------------------------------------------------------------------------------------
8989
void make_carrot_spend_pubkey(const crypto::secret_key &k_generate_image,

src/carrot_core/address_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void make_carrot_index_extension_generator(const crypto::secret_key &s_generate_
5252
{
5353
// s^j_gen = H_32[s_ga](j_major, j_minor)
5454
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_ADDRESS_INDEX_GEN>(j_major, j_minor);
55-
derive_bytes_32(transcript.data(), transcript.size, &s_generate_address, &address_generator_out);
55+
derive_bytes_32(transcript.data(), transcript.size(), &s_generate_address, &address_generator_out);
5656
}
5757
//-------------------------------------------------------------------------------------------------------------------
5858
void make_carrot_subaddress_scalar(const crypto::public_key &spend_pubkey,
@@ -64,7 +64,7 @@ void make_carrot_subaddress_scalar(const crypto::public_key &spend_pubkey,
6464
// k^j_subscal = H_n(K_s, j_major, j_minor, s^j_gen)
6565
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_SUBADDRESS_SCALAR>(
6666
spend_pubkey, j_major, j_minor);
67-
derive_scalar(transcript.data(), transcript.size, &s_address_generator, subaddress_scalar_out.data);
67+
derive_scalar(transcript.data(), transcript.size(), &s_address_generator, subaddress_scalar_out.data);
6868
}
6969
//-------------------------------------------------------------------------------------------------------------------
7070
void make_carrot_address_spend_pubkey(const crypto::public_key &spend_pubkey,

src/carrot_core/enote_utils.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void make_carrot_enote_ephemeral_privkey(const janus_anchor_t &anchor_norm,
8888
// k_e = (H_64(anchor_norm, input_context, K^j_s, K^j_v, pid)) mod l
8989
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_EPHEMERAL_PRIVKEY>(
9090
anchor_norm, input_context, address_spend_pubkey, address_view_pubkey, payment_id);
91-
derive_scalar(transcript.data(), transcript.size, nullptr, &enote_ephemeral_privkey_out);
91+
derive_scalar(transcript.data(), transcript.size(), nullptr, &enote_ephemeral_privkey_out);
9292
}
9393
//-------------------------------------------------------------------------------------------------------------------
9494
void make_carrot_enote_ephemeral_pubkey_cryptonote(const crypto::secret_key &enote_ephemeral_privkey,
@@ -163,7 +163,7 @@ void make_carrot_view_tag(const unsigned char s_sender_receiver_unctx[32],
163163
{
164164
// vt = H_3(s_sr || input_context || Ko)
165165
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_VIEW_TAG>(input_context, onetime_address);
166-
derive_bytes_3(transcript.data(), transcript.size, s_sender_receiver_unctx, &view_tag_out);
166+
derive_bytes_3(transcript.data(), transcript.size(), s_sender_receiver_unctx, &view_tag_out);
167167
}
168168
//-------------------------------------------------------------------------------------------------------------------
169169
void make_carrot_input_context_coinbase(const std::uint64_t block_index, input_context_t &input_context_out)
@@ -189,7 +189,7 @@ void make_carrot_sender_receiver_secret(const unsigned char s_sender_receiver_un
189189
// s^ctx_sr = H_32(s_sr, D_e, input_context)
190190
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_SENDER_RECEIVER_SECRET>(
191191
enote_ephemeral_pubkey, input_context);
192-
derive_bytes_32(transcript.data(), transcript.size, s_sender_receiver_unctx, &s_sender_receiver_out);
192+
derive_bytes_32(transcript.data(), transcript.size(), s_sender_receiver_unctx, &s_sender_receiver_out);
193193
}
194194
//-------------------------------------------------------------------------------------------------------------------
195195
void make_carrot_onetime_address_extension_g(const crypto::hash &s_sender_receiver,
@@ -198,7 +198,7 @@ void make_carrot_onetime_address_extension_g(const crypto::hash &s_sender_receiv
198198
{
199199
// k^o_g = H_n("..g..", s^ctx_sr, C_a)
200200
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_ONETIME_EXTENSION_G>(amount_commitment);
201-
derive_scalar(transcript.data(), transcript.size, &s_sender_receiver, &sender_extension_out);
201+
derive_scalar(transcript.data(), transcript.size(), &s_sender_receiver, &sender_extension_out);
202202
}
203203
//-------------------------------------------------------------------------------------------------------------------
204204
void make_carrot_onetime_address_extension_t(const crypto::hash &s_sender_receiver,
@@ -207,7 +207,7 @@ void make_carrot_onetime_address_extension_t(const crypto::hash &s_sender_receiv
207207
{
208208
// k^o_t = H_n("..t..", s^ctx_sr, C_a)
209209
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_ONETIME_EXTENSION_T>(amount_commitment);
210-
derive_scalar(transcript.data(), transcript.size, &s_sender_receiver, &sender_extension_out);
210+
derive_scalar(transcript.data(), transcript.size(), &s_sender_receiver, &sender_extension_out);
211211
}
212212
//-------------------------------------------------------------------------------------------------------------------
213213
void make_carrot_onetime_address_extension_pubkey(const crypto::hash &s_sender_receiver,
@@ -253,7 +253,7 @@ void make_carrot_amount_blinding_factor(const crypto::hash &s_sender_receiver,
253253
// k_a = H_n(s^ctx_sr, enote_type)
254254
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_AMOUNT_BLINDING_FACTOR>(
255255
static_cast<unsigned char>(enote_type));
256-
derive_scalar(transcript.data(), transcript.size, &s_sender_receiver, &amount_blinding_factor_out);
256+
derive_scalar(transcript.data(), transcript.size(), &s_sender_receiver, &amount_blinding_factor_out);
257257
}
258258
//-------------------------------------------------------------------------------------------------------------------
259259
void make_carrot_anchor_encryption_mask(const crypto::hash &s_sender_receiver,
@@ -262,7 +262,7 @@ void make_carrot_anchor_encryption_mask(const crypto::hash &s_sender_receiver,
262262
{
263263
// m_anchor = H_16(s^ctx_sr, Ko)
264264
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_ENCRYPTION_MASK_ANCHOR>(onetime_address);
265-
derive_bytes_16(transcript.data(), transcript.size, &s_sender_receiver, &anchor_encryption_mask_out);
265+
derive_bytes_16(transcript.data(), transcript.size(), &s_sender_receiver, &anchor_encryption_mask_out);
266266
}
267267
//-------------------------------------------------------------------------------------------------------------------
268268
encrypted_janus_anchor_t encrypt_carrot_anchor(const janus_anchor_t &anchor,
@@ -295,7 +295,7 @@ void make_carrot_amount_encryption_mask(const crypto::hash &s_sender_receiver,
295295
{
296296
// m_a = H_8(s^ctx_sr, Ko)
297297
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_ENCRYPTION_MASK_AMOUNT>(onetime_address);
298-
derive_bytes_8(transcript.data(), transcript.size, &s_sender_receiver, &amount_encryption_mask_out);
298+
derive_bytes_8(transcript.data(), transcript.size(), &s_sender_receiver, &amount_encryption_mask_out);
299299
}
300300
//-------------------------------------------------------------------------------------------------------------------
301301
encrypted_amount_t encrypt_carrot_amount(const rct::xmr_amount amount,
@@ -328,7 +328,7 @@ void make_carrot_payment_id_encryption_mask(const crypto::hash &s_sender_receive
328328
{
329329
// m_pid = H_8(s^ctx_sr, Ko)
330330
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_ENCRYPTION_MASK_PAYMENT_ID>(onetime_address);
331-
derive_bytes_8(transcript.data(), transcript.size, &s_sender_receiver, &payment_id_encryption_mask_out);
331+
derive_bytes_8(transcript.data(), transcript.size(), &s_sender_receiver, &payment_id_encryption_mask_out);
332332
}
333333
//-------------------------------------------------------------------------------------------------------------------
334334
encrypted_payment_id_t encrypt_legacy_payment_id(const payment_id_t payment_id,
@@ -365,7 +365,7 @@ void make_carrot_janus_anchor_special(const crypto::x25519_pubkey &enote_ephemer
365365
// anchor_sp = H_16(D_e, input_context, Ko, k_v, K_s)
366366
const auto transcript = sp::make_fixed_transcript<CARROT_DOMAIN_SEP_JANUS_ANCHOR_SPECIAL>(
367367
enote_ephemeral_pubkey, input_context, account_spend_pubkey);
368-
derive_bytes_16(transcript.data(), transcript.size, &k_view, &anchor_special_out);
368+
derive_bytes_16(transcript.data(), transcript.size(), &k_view, &anchor_special_out);
369369
}
370370
//-------------------------------------------------------------------------------------------------------------------
371371
void recover_address_spend_pubkey(const crypto::public_key &onetime_address,

src/carrot_core/transcript_fixed.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ template <std::size_t N, const unsigned char domain_sep[N], typename... Ts>
7777
class SpFixedTranscript final
7878
{
7979
public:
80-
//public static member variables
81-
static constexpr std::size_t size = 1 + SpFixedTranscript::domain_sep_size() + detail::sizeof_sum<Ts...>();
82-
8380
//constructors
8481
/// normal constructor
8582
SpFixedTranscript(const Ts&... args)
@@ -102,6 +99,11 @@ class SpFixedTranscript final
10299
//member functions
103100
constexpr const void* data() const noexcept { return m_transcript; }
104101

102+
static constexpr std::size_t size()
103+
{
104+
return 1 + domain_sep_size() + detail::sizeof_sum<Ts...>();
105+
}
106+
105107
//destructors
106108
~SpFixedTranscript()
107109
{
@@ -171,7 +173,7 @@ class SpFixedTranscript final
171173

172174
//member variables
173175
/// the transcript buffer
174-
unsigned char m_transcript[size];
176+
unsigned char m_transcript[size()];
175177
};
176178

177179
template <const auto & domain_sep, typename... Ts>

tests/unit_tests/carrot_transcript_fixed.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ TEST(carrot_transcript_fixed, ts_size)
4646
{
4747
static constexpr const unsigned char DS1[] = "perspicacious";
4848
const auto transcript1 = sp::make_fixed_transcript<DS1>((uint32_t)32);
49-
EXPECT_EQ(1 + 13 + 4, transcript1.size);
49+
EXPECT_EQ(1 + 13 + 4, transcript1.size());
5050

5151
static constexpr const unsigned char DS2[] = "recrudescence";
5252
const auto transcript2 = sp::make_fixed_transcript<DS2>((uint32_t)32, (uint64_t)64);
53-
EXPECT_EQ(1 + 13 + 4 + 8, transcript2.size);
53+
EXPECT_EQ(1 + 13 + 4 + 8, transcript2.size());
5454

5555
// vt = H_3(s_sr || input_context || Ko)
5656
const auto transcript_vt = sp::make_fixed_transcript<carrot::CARROT_DOMAIN_SEP_VIEW_TAG>(
5757
carrot::input_context_t{},
5858
crypto::public_key{});
59-
EXPECT_EQ(1 + 15 + 33 + 32, transcript_vt.size);
59+
EXPECT_EQ(1 + 15 + 33 + 32, transcript_vt.size());
6060
}

0 commit comments

Comments
 (0)