|
27 | 27 | // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
|
29 | 29 | //paired header |
30 | | -#include "address_utils_compat.h" |
| 30 | +#include "address_utils.h" |
31 | 31 |
|
32 | 32 | //local headers |
| 33 | +#include "address_device.h" |
| 34 | +#include "crypto/generators.h" |
33 | 35 | #include "cryptonote_config.h" |
34 | 36 | #include "int-util.h" |
35 | 37 | #include "ringct/rctOps.h" |
@@ -87,4 +89,39 @@ void make_legacy_subaddress_spend_pubkey(const crypto::secret_key &legacy_subadd |
87 | 89 | legacy_subaddress_spend_pubkey_out = rct::rct2pk(res_k); |
88 | 90 | } |
89 | 91 | //------------------------------------------------------------------------------------------------------------------- |
| 92 | +void make_legacy_subaddress_spend_pubkey(const cryptonote_hierarchy_address_device &addr_dev, |
| 93 | + const std::uint32_t major_index, |
| 94 | + const std::uint32_t minor_index, |
| 95 | + crypto::public_key &legacy_subaddress_spend_pubkey_out) |
| 96 | +{ |
| 97 | + // k^j_subext = ScalarDeriveLegacy("SubAddr" || IntToBytes8(0) || k_v || IntToBytes32(j_major) || IntToBytes32(j_minor)) |
| 98 | + crypto::secret_key legacy_subaddress_extension; |
| 99 | + addr_dev.make_legacy_subaddress_extension(major_index, minor_index, legacy_subaddress_extension); |
| 100 | + |
| 101 | + // K^j_s = K_s + k^j_subext G |
| 102 | + make_legacy_subaddress_spend_pubkey(legacy_subaddress_extension, |
| 103 | + addr_dev.get_cryptonote_account_spend_pubkey(), |
| 104 | + legacy_subaddress_spend_pubkey_out); |
| 105 | +} |
| 106 | +//------------------------------------------------------------------------------------------------------------------- |
| 107 | +void make_legacy_subaddress_pubkeys(const cryptonote_hierarchy_address_device &addr_dev, |
| 108 | + const std::uint32_t major_index, |
| 109 | + const std::uint32_t minor_index, |
| 110 | + crypto::public_key &legacy_subaddress_spend_pubkey_out, |
| 111 | + crypto::public_key &legacy_subaddress_view_pubkey_out) |
| 112 | +{ |
| 113 | + // K^j_s = K_s + k^j_subext G |
| 114 | + make_legacy_subaddress_spend_pubkey(addr_dev, |
| 115 | + major_index, |
| 116 | + minor_index, |
| 117 | + legacy_subaddress_spend_pubkey_out); |
| 118 | + |
| 119 | + // K^j_base = G if j=0, else K^j_s |
| 120 | + const bool is_subaddress = major_index || minor_index; |
| 121 | + const crypto::public_key base_pubkey = is_subaddress ? legacy_subaddress_spend_pubkey_out : crypto::get_G(); |
| 122 | + |
| 123 | + // K^j_v = k_v K^j_base |
| 124 | + addr_dev.view_key_scalar_mult_ed25519(base_pubkey, legacy_subaddress_view_pubkey_out); |
| 125 | +} |
| 126 | +//------------------------------------------------------------------------------------------------------------------- |
90 | 127 | } //namespace carrot |
0 commit comments