Skip to content

Commit

Permalink
seraphis_main compiles and links
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffro256 committed Jun 4, 2024
1 parent 66e41c1 commit c382a85
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,14 @@ namespace config
const constexpr char HASH_KEY_BINNED_REF_SET_GENERATOR_SEED[] = "binned_refset_generator_seed";
const constexpr char HASH_KEY_BINNED_REF_SET_MEMBER[] = "binned_refset_member";

const constexpr char HASH_KEY_JAMTIS_VIEWBALANCE_KEY[] = "jamtis_view_balance_key";
const constexpr char HASH_KEY_JAMTIS_VIEWRECEIVED_KEY[] = "jamtis_view_received_key";
const constexpr char HASH_KEY_JAMTIS_PROVESPEND_KEY[] = "jamtis_prove_spend_key";
const constexpr char HASH_KEY_JAMTIS_VIEWBALANCE_SECRET[] = "jamtis_view_balance_secret";
const constexpr char HASH_KEY_JAMTIS_GENERATEIMAGE_KEY[] = "jamtis_generate_image_key";
const constexpr char HASH_KEY_JAMTIS_UNLOCKRECEIVED_KEY[] = "jamtis_unlock_received_key";
const constexpr char HASH_KEY_JAMTIS_IDENTIFYRECEIVED_KEY[] = "jamtis_identify_received_key";
const constexpr char HASH_KEY_JAMTIS_FILTERASSIST_KEY[] = "jamtis_filter_assist_key";
const constexpr char HASH_KEY_JAMTIS_GENERATEADDRESS_SECRET[] = "jamtis_generate_address_secret";
const constexpr char HASH_KEY_JAMTIS_CIPHERTAG_SECRET[] = "jamtis_cipher_tag_secret";
const constexpr char HASH_KEY_JAMTIS_FILTERASSIST_KEY[] = "jamtis_filter_assist_key";
const constexpr char HASH_KEY_JAMTIS_INDEX_EXTENSION_GENERATOR[] = "jamtis_index_extension_generator";
const constexpr char HASH_KEY_JAMTIS_ADDRESS_PRIVKEY[] = "jamtis_address_privkey";
const constexpr char HASH_KEY_JAMTIS_SPENDKEY_EXTENSION_G[] = "jamtis_spendkey_extension_g";
Expand Down
92 changes: 92 additions & 0 deletions src/seraphis_core/jamtis_account_secrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

//local headers
#include "crypto/crypto.h"
#include "crypto/generators.h"
#include "crypto/x25519.h"
#include "cryptonote_config.h"
#include "ringct/rctOps.h"
Expand All @@ -52,6 +53,85 @@ namespace sp
namespace jamtis
{
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_provespend_key(const crypto::secret_key &s_master,
crypto::secret_key &k_prove_spend_out)
{
// k_ps = H_n[s_m]()
SpKDFTranscript transcript{config::HASH_KEY_JAMTIS_PROVESPEND_KEY, 0};
sp_derive_key(to_bytes(s_master), transcript.data(), transcript.size(), to_bytes(k_prove_spend_out));
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_viewbalance_secret(const crypto::secret_key &s_master,
crypto::secret_key &s_view_balance_out)
{
// s_vb = H_32[s_m]()
SpKDFTranscript transcript{config::HASH_KEY_JAMTIS_VIEWBALANCE_SECRET, 0};
sp_derive_secret(to_bytes(s_master), transcript.data(), transcript.size(), to_bytes(s_view_balance_out));
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_generateimage_key(const crypto::secret_key &s_view_balance,
crypto::secret_key &k_generate_image_out)
{
// k_gi = H_n[s_vb]()
SpKDFTranscript transcript{config::HASH_KEY_JAMTIS_GENERATEIMAGE_KEY, 0};
sp_derive_key(to_bytes(s_view_balance), transcript.data(), transcript.size(), to_bytes(k_generate_image_out));
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_unlockreceived_key(const crypto::secret_key &s_view_balance,
crypto::x25519_secret_key &d_unlock_received_out)
{
// d_ur = H_n_x25519[s_vb]()
SpKDFTranscript transcript{config::HASH_KEY_JAMTIS_UNLOCKRECEIVED_KEY, 0};
sp_derive_x25519_key(to_bytes(s_view_balance), transcript.data(), transcript.size(), d_unlock_received_out.data);
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_exchangebase_pubkey(const crypto::x25519_secret_key &d_unlock_received,
crypto::x25519_pubkey &exchangebase_pubkey_out)
{
// D_base = d_ur * xG
crypto::x25519_scmul_base(d_unlock_received, exchangebase_pubkey_out);
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_identifyreceived_key(const crypto::secret_key &s_view_balance,
crypto::x25519_secret_key &d_identify_received_out)
{
// d_ir = H_n_x25519[s_vb]()
SpKDFTranscript transcript{config::HASH_KEY_JAMTIS_IDENTIFYRECEIVED_KEY, 0};
sp_derive_x25519_key(to_bytes(s_view_balance), transcript.data(), transcript.size(), d_identify_received_out.data);
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_identifyreceived_pubkey(const crypto::x25519_secret_key &d_identify_received,
const crypto::x25519_pubkey &exchangebase_pubkey,
crypto::x25519_pubkey &identifyreceived_pubkey_out)
{
// D_ir = d_ir * D_base
crypto::x25519_scmul_key(d_identify_received, exchangebase_pubkey, identifyreceived_pubkey_out);
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_filterassist_key(const crypto::secret_key &s_view_balance,
crypto::x25519_secret_key &d_filter_assist_out)
{
// d_fa = H_n_x25519[s_vb]()
SpKDFTranscript transcript{config::HASH_KEY_JAMTIS_FILTERASSIST_KEY, 0};
sp_derive_x25519_key(to_bytes(s_view_balance), transcript.data(), transcript.size(), d_filter_assist_out.data);
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_filterassist_pubkey(const crypto::x25519_secret_key &d_filter_assist,
const crypto::x25519_pubkey &exchangebase_pubkey,
crypto::x25519_pubkey &filterassist_pubkey_out)
{
// D_fa = d_fa * D_base
crypto::x25519_scmul_key(d_filter_assist, exchangebase_pubkey, filterassist_pubkey_out);
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_generateaddress_secret(const crypto::secret_key &s_view_balance,
crypto::secret_key &s_generate_address_out)
{
// s_ga = H_32[s_vb]()
SpKDFTranscript transcript{config::HASH_KEY_JAMTIS_GENERATEADDRESS_SECRET, 0};
sp_derive_secret(to_bytes(s_view_balance), transcript.data(), transcript.size(), to_bytes(s_generate_address_out));
}
//-------------------------------------------------------------------------------------------------------------------
void make_jamtis_ciphertag_secret(const crypto::secret_key &s_generate_address,
crypto::secret_key &s_cipher_tag_out)
{
Expand All @@ -60,5 +140,17 @@ void make_jamtis_ciphertag_secret(const crypto::secret_key &s_generate_address,
sp_derive_secret(to_bytes(s_generate_address), transcript.data(), transcript.size(), to_bytes(s_cipher_tag_out));
}
//-------------------------------------------------------------------------------------------------------------------
void make_rct_spendkey(const crypto::secret_key &k_generate_image,
const crypto::secret_key &k_prove_spend,
rct::key &spend_pubkey_out)
{
// k_ps U
rct::key U_term;
rct::scalarmultKey(U_term, rct::pk2rct(crypto::get_U()), rct::sk2rct(k_prove_spend));

// K_s = k_gi G + k_ps U
rct::addKeys1(spend_pubkey_out, rct::sk2rct(k_generate_image), U_term);
}
//-------------------------------------------------------------------------------------------------------------------
} //namespace jamtis
} //namespace sp
6 changes: 3 additions & 3 deletions src/seraphis_core/jamtis_account_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ void make_jamtis_generateimage_key(const crypto::secret_key &s_view_balance,
* outparam: d_unlock_received_out - d_ur
*/
void make_jamtis_unlockreceived_key(const crypto::secret_key &s_view_balance,
crypto::x25519_secret_key &d_view_received_out);
crypto::x25519_secret_key &d_unlock_received_out);
/**
* brief make_jamtis_exchangebase_pubkey - D_base
* D_base = d_ur * xG
* D_base = d_ur * xG
* param: d_unlock_received - d_ur
* outparam: exchangebase_pubkey_out
*/
Expand All @@ -104,7 +104,7 @@ void make_jamtis_identifyreceived_key(const crypto::secret_key &s_view_balance,
crypto::x25519_secret_key &d_identify_received_out);
/**
* brief: make_jamtis_identifyreceived_pubkey - D_ir
* - D_ir = D_ir * D_base
* D_ir = d_ir * D_base
* param: d_identify_received - d_ir
* param: exchangebase_pubkey - D_base
* outparam: identifyreceived_pubkey_out - D_ir
Expand Down

0 comments on commit c382a85

Please sign in to comment.