From 8f86674fc1ea06c9f9a5e1fea1624667c1faa191 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 4 Apr 2023 23:18:04 +0200 Subject: [PATCH] crypto: constants for generators U, X, 1/8*H updated + crypto_basics test was adatped --- src/crypto/crypto-sugar.cpp | 2 +- src/currency_core/currency_basic.h | 1 + src/currency_core/currency_format_utils.cpp | 29 +++------------------ tests/functional_tests/crypto_tests.cpp | 10 +++++-- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/crypto/crypto-sugar.cpp b/src/crypto/crypto-sugar.cpp index 0f0be387..44cb960d 100644 --- a/src/crypto/crypto-sugar.cpp +++ b/src/crypto/crypto-sugar.cpp @@ -23,7 +23,7 @@ namespace crypto const point_t c_point_H = { 0x05087c1f5b9b32d6, 0x00547595f445c3b5, 0x764df64578552f2a, 0x8a49a651e0e0da45 }; // == Hp(G), this is being checked in bpp_basics const point_t c_point_H2 = { 0x70c8d1ab9dbf1cc0, 0xc561bb12639a8516, 0x3cfff1def9e5b268, 0xe0936386f3bcce1a }; // == Hp("h2_generator"), checked in bpp_basics - const point_t c_point_U = { 0xc9d2f543dbbc253a, 0x87099e9ac33d06dd, 0x76bcf12dcf6ffcba, 0x20384a4a88752d32 }; // == Hp("U_generator"), checked in + const point_t c_point_U = { 0x5b17569f418e26d0, 0xd45af23bdf43c291, 0xe380f518f0a7432f, 0xa1c94a907d0bc61c }; // == Hp("U_generator"), checked in bpp_basics const point_t c_point_X = { 0xc9d2f543dbbc253a, 0x87099e9ac33d06dd, 0x76bcf12dcf6ffcba, 0x20384a4a88752d32 }; // == Hp("X_generator"), checked in clsag_ggxg_basics const point_t c_point_0 = point_t(point_t::tag_zero()); diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index be786d59..9133873a 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -61,6 +61,7 @@ namespace currency extern const crypto::public_key native_coin_asset_id; extern const crypto::point_t native_coin_asset_id_pt; + extern const crypto::public_key native_coin_asset_id_1div8; const static wide_difficulty_type global_difficulty_pow_starter = DIFFICULTY_POW_STARTER; const static wide_difficulty_type global_difficulty_pos_starter = DIFFICULTY_POS_STARTER; diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 7dd1ef68..b8bb19e3 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -37,8 +37,9 @@ using namespace epee; namespace currency { - const crypto::public_key native_coin_asset_id = crypto::point_t(0x05087c1f5b9b32d6, 0x00547595f445c3b5, 0x764df64578552f2a, 0x8a49a651e0e0da45).to_public_key(); // == crypto::c_point_H, checked in crypto_basics test - const crypto::point_t native_coin_asset_id_pt = crypto::point_t(0x05087c1f5b9b32d6, 0x00547595f445c3b5, 0x764df64578552f2a, 0x8a49a651e0e0da45); // == crypto::c_point_H, checked in crypto_basics test + const crypto::point_t native_coin_asset_id_pt = crypto::point_t(0x05087c1f5b9b32d6, 0x00547595f445c3b5, 0x764df64578552f2a, 0x8a49a651e0e0da45); // == crypto::c_point_H, checked in crypto_basics test + const crypto::public_key native_coin_asset_id = native_coin_asset_id_pt.to_public_key(); // == crypto::c_point_H, checked in crypto_basics test + const crypto::public_key native_coin_asset_id_1div8 = crypto::point_t(0x62fcfaaa3e2dc374, 0x8b2ed458e883f43b, 0xe3a2ad64f07decf4, 0x68626bff9c463449).to_public_key(); // == 1/8 * crypto::c_point_H, checked in crypto_basics test //--------------------------------------------------------------- bool add_tx_extra_alias(transaction& tx, const extra_alias_entry& alinfo) @@ -46,30 +47,6 @@ namespace currency tx.extra.push_back(alinfo); return true; } - - //--------------------------------------------------------------- - /* - bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, - size_t current_block_size, - uint64_t fee, - const account_public_address &miner_address, - transaction& tx, - const blobdata& extra_nonce, - size_t max_outs) - { - - alias_info alias = AUTO_VAL_INIT(alias); - return construct_miner_tx(height, median_size, already_generated_coins, current_block_size, - fee, - miner_address, - tx, - extra_nonce, - max_outs, - alias, - false, - pos_entry()); - }*/ - //-------------------------------------------------------------------------------- bool generate_asset_surjection_proof(const crypto::hash& context_hash, bool has_non_zc_inputs, outputs_generation_context& ogc, zc_asset_surjection_proof& result) { diff --git a/tests/functional_tests/crypto_tests.cpp b/tests/functional_tests/crypto_tests.cpp index 7eb5b771..b6d1a7ab 100644 --- a/tests/functional_tests/crypto_tests.cpp +++ b/tests/functional_tests/crypto_tests.cpp @@ -1,5 +1,5 @@ -// Copyright (c) 2020-2021 Zano Project -// Copyright (c) 2020-2021 sowle (val@zano.org, crypto.sowle@gmail.com) +// Copyright (c) 2020-2023 Zano Project +// Copyright (c) 2020-2023 sowle (val@zano.org, crypto.sowle@gmail.com) // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -514,10 +514,16 @@ TEST(crypto, basics) ASSERT_EQ(currency::native_coin_asset_id_pt, c_point_H); ASSERT_EQ(currency::native_coin_asset_id_pt.to_public_key(), currency::native_coin_asset_id); + const point_t с_1_div_8_H = c_scalar_1div8 * c_point_H; + LOG_PRINT_L0("1/8 * H = " << с_1_div_8_H << " = { " << с_1_div_8_H.to_hex_comma_separated_uint64_str() << " }"); + ASSERT_EQ(currency::native_coin_asset_id_1div8, (c_scalar_1div8 * c_point_H).to_public_key()); + LOG_PRINT_L0("c_point_0 = " << c_point_0 << " = { " << c_point_0.to_hex_comma_separated_uint64_str() << " }"); LOG_PRINT_L0("Zano G = " << c_point_G << " = { " << c_point_G.to_hex_comma_separated_bytes_str() << " }"); LOG_PRINT_L0("Zano H = " << c_point_H << " = { " << c_point_H.to_hex_comma_separated_uint64_str() << " }"); LOG_PRINT_L0("Zano H2 = " << c_point_H2 << " = { " << c_point_H2.to_hex_comma_separated_uint64_str() << " }"); + LOG_PRINT_L0("Zano U = " << c_point_U << " = { " << c_point_U.to_hex_comma_separated_uint64_str() << " }"); + LOG_PRINT_L0("Zano X = " << c_point_X << " = { " << c_point_X.to_hex_comma_separated_uint64_str() << " }"); return true; }