Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 39fa08d769 | |||
| ae02e63ddc | |||
| 9128ef79b9 | |||
| 8bbcc07dd2 | |||
| ff5917f45f | |||
| de812d9c9a | |||
| 5de3d11ccb | |||
| 49a238086e | |||
| 91b90dbc01 | |||
| 8f3385902d | |||
| ad6ba0d7f0 | |||
| 1608a9e1a9 | |||
| 14e378aa0f | |||
| dd4be285f1 | |||
| b9260e0c7b | |||
| d93aaec6a5 | |||
| bd1af278a5 | |||
| 2a4f5cea7c | |||
| 16eba0d12d | |||
| aa39526fe8 | |||
| 44ee67d21f | |||
| 0f9c969b83 | |||
| ac5dcc2133 | |||
| 069c83ef32 | |||
| 655f79b0e0 |
@@ -130,14 +130,14 @@ module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
|
||||
header.writeUInt32BE(rpcData.version, position += 32, 4); // version 121-153
|
||||
header = reverseBuffer(header);
|
||||
}
|
||||
|
||||
|
||||
let blob = Buffer.concat([
|
||||
header, // 80 bytes
|
||||
Buffer.from('AAAAAAAAAAAAAAAA', 'hex'), // 8 bytes
|
||||
Buffer.from('BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB', 'hex'), // 32 bytes
|
||||
varuint.encode(rpcData.transactions.length + 1, Buffer.alloc(varuint.encodingLength(rpcData.transactions.length + 1)), 0)
|
||||
]);
|
||||
const offset1 = blob.length;
|
||||
const offset1 = blob.length;
|
||||
blob = Buffer.concat([ blob, Buffer.from(txCoinbase.toHex(), 'hex') ]);
|
||||
|
||||
rpcData.transactions.forEach(function (value) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cryptoforknote-util",
|
||||
"version": "15.6.0",
|
||||
"version": "15.8.2",
|
||||
"author": {
|
||||
"name": "LucasJones",
|
||||
"email": "lucasjonesdev@hotmail.co.uk"
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// Copyright (c) 2024, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//! @file Supporting types for Carrot (anchor, view tag, etc.).
|
||||
|
||||
#pragma once
|
||||
|
||||
//standard headers
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
//forward declarations
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
|
||||
constexpr std::size_t JANUS_ANCHOR_BYTES{16};
|
||||
|
||||
/// either encodes randomness the private key of, or an HMAC of, the ephemeral pubkey
|
||||
struct janus_anchor_t final
|
||||
{
|
||||
unsigned char bytes[JANUS_ANCHOR_BYTES];
|
||||
};
|
||||
|
||||
/// carrot janus anchor XORd with a user-defined secret
|
||||
using encrypted_janus_anchor_t = janus_anchor_t;
|
||||
|
||||
/// carrot enote types
|
||||
enum class CarrotEnoteType : unsigned char
|
||||
{
|
||||
PAYMENT = 0,
|
||||
CHANGE = 1
|
||||
};
|
||||
|
||||
/// carrot encrypted amount
|
||||
constexpr std::size_t ENCRYPTED_AMOUNT_BYTES{8};
|
||||
struct encrypted_amount_t final
|
||||
{
|
||||
unsigned char bytes[ENCRYPTED_AMOUNT_BYTES];
|
||||
};
|
||||
|
||||
/// legacy payment ID
|
||||
constexpr std::size_t PAYMENT_ID_BYTES{8};
|
||||
struct payment_id_t final
|
||||
{
|
||||
unsigned char bytes[PAYMENT_ID_BYTES];
|
||||
};
|
||||
static constexpr payment_id_t null_payment_id{{0}};
|
||||
|
||||
/// legacy encrypted payment ID
|
||||
struct encrypted_payment_id_t final
|
||||
{
|
||||
unsigned char bytes[PAYMENT_ID_BYTES];
|
||||
};
|
||||
|
||||
/// carrot view tags
|
||||
constexpr std::size_t VIEW_TAG_BYTES{3};
|
||||
struct view_tag_t final
|
||||
{
|
||||
unsigned char bytes[VIEW_TAG_BYTES];
|
||||
};
|
||||
|
||||
static_assert(sizeof(view_tag_t) < 32, "uint8_t cannot index all view tag bits");
|
||||
|
||||
/// carrot input context
|
||||
constexpr std::size_t INPUT_CONTEXT_BYTES{1 + 32};
|
||||
struct input_context_t final
|
||||
{
|
||||
unsigned char bytes[INPUT_CONTEXT_BYTES];
|
||||
};
|
||||
|
||||
// SPARC encrypted return public key
|
||||
constexpr std::size_t ENCRYPTED_RETURN_PUBKEY_BYTES{32};
|
||||
struct encrypted_return_pubkey_t final
|
||||
{
|
||||
unsigned char bytes[ENCRYPTED_RETURN_PUBKEY_BYTES];
|
||||
};
|
||||
|
||||
} //namespace carrot
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <deque>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/contains_fwd.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "serialization"
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace cryptonote_arq
|
||||
{
|
||||
enum class txversion : uint16_t
|
||||
{
|
||||
v0 = 0,
|
||||
v1,
|
||||
v2,
|
||||
v3,
|
||||
|
||||
_count
|
||||
};
|
||||
|
||||
enum class txtype : uint16_t
|
||||
{
|
||||
standard = 0,
|
||||
state_change,
|
||||
key_image_unlock,
|
||||
stake,
|
||||
|
||||
_count
|
||||
};
|
||||
}
|
||||
@@ -26,9 +26,12 @@
|
||||
#include "tx_extra.h"
|
||||
#include "ringct/rctTypes.h"
|
||||
#include "cryptonote_protocol/blobdatatype.h"
|
||||
#include "cryptonote_protocol/enums.h"
|
||||
#include "offshore/pricing_record.h"
|
||||
#include "zephyr_oracle/pricing_record.h"
|
||||
#include "salvium_oracle/pricing_record.h"
|
||||
#include "carrot_core/core_types.h"
|
||||
#include "arq_txtypes.h"
|
||||
|
||||
|
||||
namespace cryptonote
|
||||
@@ -49,19 +52,6 @@ namespace cryptonote
|
||||
|
||||
typedef std::vector<crypto::signature> ring_signature;
|
||||
|
||||
enum salvium_transaction_type
|
||||
{
|
||||
UNSET = 0,
|
||||
MINER = 1,
|
||||
PROTOCOL = 2,
|
||||
TRANSFER = 3,
|
||||
CONVERT = 4,
|
||||
BURN = 5,
|
||||
STAKE = 6,
|
||||
RETURN = 7,
|
||||
MAX = 7
|
||||
};
|
||||
|
||||
/* outputs */
|
||||
|
||||
struct txout_to_script
|
||||
@@ -215,6 +205,25 @@ namespace cryptonote
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
struct txout_to_carrot_v1
|
||||
{
|
||||
crypto::public_key key; // K_o
|
||||
std::string asset_type;
|
||||
carrot::view_tag_t view_tag; // vt
|
||||
carrot::encrypted_janus_anchor_t encrypted_janus_anchor; // anchor_enc
|
||||
|
||||
// Encrypted amount a_enc and amount commitment C_a are stored in rct::rctSigBase
|
||||
// This allows for reuse of this output type between coinbase and non-coinbase txs
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(key)
|
||||
FIELD(asset_type)
|
||||
FIELD(view_tag)
|
||||
FIELD(encrypted_janus_anchor)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
/* inputs */
|
||||
|
||||
struct txin_gen
|
||||
@@ -285,7 +294,7 @@ namespace cryptonote
|
||||
uint64_t amount;
|
||||
std::vector<uint64_t> key_offsets;
|
||||
crypto::key_image k_image;
|
||||
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(amount)
|
||||
FIELD(key_offsets)
|
||||
@@ -337,7 +346,7 @@ namespace cryptonote
|
||||
FIELD(k_image)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
struct txin_salvium_key
|
||||
{
|
||||
uint64_t amount;
|
||||
@@ -352,7 +361,7 @@ namespace cryptonote
|
||||
FIELD(k_image)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_to_key, txin_offshore, txin_onshore, txin_xasset, txin_haven_key> txin_v;
|
||||
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_zephyr_key> txin_zephyr_v;
|
||||
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_salvium_key> txin_salvium_v;
|
||||
@@ -360,6 +369,7 @@ namespace cryptonote
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key> txout_target_v;
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key, txout_offshore, txout_xasset, txout_haven_key, txout_haven_tagged_key> txout_xhv_target_v;
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_salvium_key, txout_salvium_tagged_key> txout_salvium_target_v;
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key, txout_to_carrot_v1> txout_carrot_target_v;
|
||||
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_zephyr_tagged_key> txout_stablero_target_v;
|
||||
|
||||
@@ -399,7 +409,7 @@ namespace cryptonote
|
||||
struct tx_out_salvium
|
||||
{
|
||||
uint64_t amount;
|
||||
txout_salvium_target_v target;
|
||||
txout_carrot_target_v target;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(amount)
|
||||
@@ -407,6 +417,23 @@ namespace cryptonote
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
class protocol_tx_data_t {
|
||||
public:
|
||||
uint8_t version;
|
||||
crypto::public_key return_address;
|
||||
crypto::public_key return_pubkey;
|
||||
carrot::view_tag_t return_view_tag;
|
||||
carrot::encrypted_janus_anchor_t return_anchor_enc;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(version)
|
||||
FIELD(return_address)
|
||||
FIELD(return_pubkey)
|
||||
FIELD(return_view_tag)
|
||||
FIELD(return_anchor_enc)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
enum loki_version
|
||||
{
|
||||
@@ -426,6 +453,8 @@ namespace cryptonote
|
||||
size_t version;
|
||||
uint64_t unlock_time; //number of block (or time), used as a limitation like: spend this tx not early then block/time
|
||||
|
||||
cryptonote_arq::txtype arq_tx_type;
|
||||
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<txin_zephyr_v> vin_zephyr;
|
||||
std::vector<txin_salvium_v> vin_salvium;
|
||||
@@ -446,9 +475,12 @@ namespace cryptonote
|
||||
|
||||
// SALVIUM-SPECIFIC FIELDS
|
||||
// TX type
|
||||
cryptonote::salvium_transaction_type tx_type;
|
||||
// Return address
|
||||
cryptonote::salvium_transaction_type sal_tx_type;
|
||||
crypto::public_key return_address;
|
||||
// Return address list (must be at least 1 and at most BULLETPROOF_MAX_OUTPUTS-1 - the "-1" is for the change output)
|
||||
std::vector<crypto::public_key> return_address_list;
|
||||
//return_address_change_mask
|
||||
std::vector<uint8_t> return_address_change_mask;
|
||||
// Return TX public key
|
||||
crypto::public_key return_pubkey;
|
||||
// Source asset type
|
||||
@@ -459,6 +491,7 @@ namespace cryptonote
|
||||
//uint64_t amount_burnt;
|
||||
// Slippage limit
|
||||
uint64_t amount_slippage_limit;
|
||||
protocol_tx_data_t protocol_tx_data;
|
||||
|
||||
|
||||
//
|
||||
@@ -482,10 +515,10 @@ namespace cryptonote
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
|
||||
VARINT_FIELD(version)
|
||||
//if(version == 0 || CURRENT_TRANSACTION_VERSION < version) return false;
|
||||
|
||||
|
||||
// Only transactions prior to HAVEN_TYPES_TRANSACTION_VERSION are permitted to be anything other than HAVEN_TYPES and need translation
|
||||
if (version < HAVEN_TYPES_TRANSACTION_VERSION) {
|
||||
|
||||
|
||||
if (version < POU_TRANSACTION_VERSION) {
|
||||
VARINT_FIELD(unlock_time)
|
||||
}
|
||||
@@ -717,7 +750,7 @@ namespace cryptonote
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
FIELD(vin)
|
||||
FIELD(vout_xhv)
|
||||
FIELD(extra)
|
||||
@@ -728,25 +761,36 @@ namespace cryptonote
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
|
||||
VARINT_FIELD(version)
|
||||
//if(version == 0 || CURRENT_TRANSACTION_VERSION < version) return false;
|
||||
if(version == 0 || CURRENT_TRANSACTION_VERSION < 4) return false;
|
||||
VARINT_FIELD(unlock_time)
|
||||
FIELD(vin_salvium)
|
||||
FIELD(vout_salvium)
|
||||
FIELD(extra)
|
||||
VARINT_FIELD(tx_type)
|
||||
if (tx_type != cryptonote::salvium_transaction_type::PROTOCOL) {
|
||||
VARINT_FIELD(sal_tx_type)
|
||||
if (sal_tx_type != cryptonote::salvium_transaction_type::UNSET && sal_tx_type != cryptonote::salvium_transaction_type::PROTOCOL) {
|
||||
VARINT_FIELD(amount_burnt)
|
||||
if (tx_type != cryptonote::salvium_transaction_type::MINER) {
|
||||
FIELD(return_address)
|
||||
FIELD(return_pubkey)
|
||||
if (sal_tx_type != cryptonote::salvium_transaction_type::MINER) {
|
||||
if (sal_tx_type == cryptonote::salvium_transaction_type::TRANSFER && version >= TRANSACTION_VERSION_N_OUTS) {
|
||||
FIELD(return_address_list)
|
||||
FIELD(return_address_change_mask)
|
||||
} else {
|
||||
if (sal_tx_type == cryptonote::salvium_transaction_type::STAKE &&
|
||||
version >= TRANSACTION_VERSION_CARROT)
|
||||
{
|
||||
FIELD(protocol_tx_data)
|
||||
} else {
|
||||
FIELD(return_address)
|
||||
FIELD(return_pubkey)
|
||||
}
|
||||
}
|
||||
FIELD(source_asset_type)
|
||||
FIELD(destination_asset_type)
|
||||
VARINT_FIELD(amount_slippage_limit)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
VARINT_FIELD(version)
|
||||
if (version > loki_version_2 && (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC))
|
||||
{
|
||||
@@ -754,22 +798,31 @@ namespace cryptonote
|
||||
if (version == loki_version_3_per_output_unlock_times)
|
||||
FIELD(is_deregister)
|
||||
}
|
||||
|
||||
|
||||
if (version >= static_cast<size_t>(cryptonote_arq::txversion::v3) && (blob_type == BLOB_TYPE_CRYPTONOTE_ARQMA))
|
||||
{
|
||||
VARINT_FIELD(arq_tx_type)
|
||||
if (static_cast<uint16_t>(arq_tx_type) >= static_cast<uint16_t>(cryptonote_arq::txtype::_count))
|
||||
return false;
|
||||
FIELD(output_unlock_times)
|
||||
}
|
||||
|
||||
VARINT_FIELD(unlock_time)
|
||||
|
||||
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR)
|
||||
FIELD(vin_zephyr)
|
||||
else
|
||||
else
|
||||
FIELD(vin)
|
||||
|
||||
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR)
|
||||
FIELD(vout_zephyr)
|
||||
else
|
||||
FIELD(vout)
|
||||
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC)
|
||||
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || blob_type == BLOB_TYPE_CRYPTONOTE_ARQMA)
|
||||
{
|
||||
if (version >= loki_version_3_per_output_unlock_times && vout.size() != output_unlock_times.size()) return false;
|
||||
if ((version >= loki_version_3_per_output_unlock_times || version >= static_cast<size_t>(cryptonote_arq::txversion::v3)) && vout.size() != output_unlock_times.size())
|
||||
return false;
|
||||
}
|
||||
FIELD(extra)
|
||||
if ((blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC) && version >= loki_version_4_tx_types)
|
||||
@@ -915,6 +968,21 @@ namespace cryptonote
|
||||
amount_minted = 0;
|
||||
output_unlock_times.clear();
|
||||
collateral_indices.clear();
|
||||
// SAL
|
||||
sal_tx_type = cryptonote::salvium_transaction_type::UNSET;
|
||||
return_address = cryptonote::null_pkey;
|
||||
return_address_list.clear();
|
||||
return_address_change_mask.clear();
|
||||
return_pubkey = cryptonote::null_pkey;
|
||||
protocol_tx_data.return_address = cryptonote::null_pkey;
|
||||
protocol_tx_data.return_pubkey = cryptonote::null_pkey;
|
||||
protocol_tx_data.return_view_tag = {};
|
||||
protocol_tx_data.return_anchor_enc = {};
|
||||
source_asset_type.clear();
|
||||
destination_asset_type.clear();
|
||||
amount_slippage_limit = 0;
|
||||
// ARQ
|
||||
arq_tx_type = cryptonote_arq::txtype::standard;
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -1080,7 +1148,7 @@ namespace cryptonote
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
|
||||
FIELD(pricing_record)
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
if (major_version >= 2) FIELD(salvium_pricing_record)
|
||||
if (major_version >= 255) FIELD(salvium_pricing_record)
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
||||
if (major_version >= 6)
|
||||
{
|
||||
@@ -1178,6 +1246,7 @@ namespace cryptonote
|
||||
{
|
||||
crypto::public_key m_spend_public_key;
|
||||
crypto::public_key m_view_public_key;
|
||||
bool m_is_carrot;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(m_spend_public_key)
|
||||
@@ -1188,6 +1257,18 @@ namespace cryptonote
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_spend_public_key)
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_view_public_key)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
bool operator==(const account_public_address& rhs) const
|
||||
{
|
||||
return m_spend_public_key == rhs.m_spend_public_key &&
|
||||
m_view_public_key == rhs.m_view_public_key &&
|
||||
m_is_carrot == rhs.m_is_carrot;
|
||||
}
|
||||
|
||||
bool operator!=(const account_public_address& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
|
||||
struct integrated_address {
|
||||
@@ -1230,6 +1311,7 @@ VARIANT_TAG(binary_archive, cryptonote::txout_zephyr_tagged_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_tagged_key, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_salvium_tagged_key, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_offshore, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_carrot_v1, 0x4);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_xasset, 0x5);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_haven_key, 0x6);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_haven_tagged_key, 0x7);
|
||||
|
||||
@@ -287,7 +287,11 @@ namespace cryptonote
|
||||
}
|
||||
crypto::hash tree_root_hash = get_tx_tree_hash(b);
|
||||
blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
|
||||
blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
|
||||
if (b.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
blob.append(tools::get_varint_data(b.tx_hashes.size() + (b.major_version >= HF_VERSION_ENABLE_N_OUTS ? 2 : 1)));
|
||||
} else {
|
||||
blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
|
||||
}
|
||||
if (b.blob_type == BLOB_TYPE_CRYPTONOTE3) {
|
||||
blob.append(reinterpret_cast<const char*>(&b.uncle), sizeof(b.uncle));
|
||||
}
|
||||
|
||||
+104
-50
@@ -1,21 +1,21 @@
|
||||
// Copyright (c) 2014-2018, The Monero Project
|
||||
//
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
@@ -25,35 +25,48 @@
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TX_EXTRA_PADDING_MAX_COUNT 255
|
||||
#define TX_EXTRA_NONCE_MAX_COUNT 255
|
||||
#define TX_EXTRA_OFFSHORE_MAX_COUNT 255
|
||||
#define TX_EXTRA_MEMO_MAX_COUNT 255
|
||||
#define TX_EXTRA_PADDING_MAX_COUNT 255
|
||||
#define TX_EXTRA_NONCE_MAX_COUNT 255
|
||||
#define TX_EXTRA_OFFSHORE_MAX_COUNT 255
|
||||
#define TX_EXTRA_MEMO_MAX_COUNT 255
|
||||
|
||||
#define TX_EXTRA_TAG_PADDING 0x00
|
||||
#define TX_EXTRA_TAG_PUBKEY 0x01
|
||||
#define TX_EXTRA_NONCE 0x02
|
||||
#define TX_EXTRA_MERGE_MINING_TAG 0x03
|
||||
#define TX_EXTRA_TAG_ADDITIONAL_PUBKEYS 0x04
|
||||
#define TX_EXTRA_TAG_OFFSHORE 0x17
|
||||
#define TX_EXTRA_TAG_MEMO 0x18
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_REGISTER 0x70
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER 0x71
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_WINNER 0x72
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR 0x73
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_PUBKEY 0x74
|
||||
#define TX_EXTRA_TAG_TX_SECRET_KEY 0x75
|
||||
#define TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS 0x76
|
||||
#define TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK 0x77
|
||||
#define TX_EXTRA_MYSTERIOUS_MINERGATE_TAG 0xDE
|
||||
#define TX_EXTRA_TAG_PADDING 0x00
|
||||
#define TX_EXTRA_TAG_PUBKEY 0x01
|
||||
#define TX_EXTRA_NONCE 0x02
|
||||
#define TX_EXTRA_MERGE_MINING_TAG 0x03
|
||||
#define TX_EXTRA_TAG_ADDITIONAL_PUBKEYS 0x04
|
||||
#define TX_EXTRA_TAG_OFFSHORE 0x17
|
||||
#define TX_EXTRA_TAG_MEMO 0x18
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_REGISTER 0x70
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_STATE_CHANGE 0x71
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_WINNER 0x72
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR 0x73
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_PUBKEY 0x74
|
||||
#define TX_EXTRA_TAG_TX_SECRET_KEY 0x75
|
||||
#define TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS 0x76
|
||||
#define TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK 0x77
|
||||
#define TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER 0x78
|
||||
#define TX_EXTRA_MYSTERIOUS_MINERGATE_TAG 0xDE
|
||||
|
||||
#define TX_EXTRA_NONCE_PAYMENT_ID 0x00
|
||||
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID 0x01
|
||||
#define TX_EXTRA_NONCE_PAYMENT_ID 0x00
|
||||
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID 0x01
|
||||
|
||||
namespace service_nodes
|
||||
{
|
||||
enum class new_state : uint16_t
|
||||
{
|
||||
deregister = 0,
|
||||
decommission,
|
||||
recommission,
|
||||
ip_change_penalty,
|
||||
_count,
|
||||
};
|
||||
};
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
@@ -208,7 +221,7 @@ namespace cryptonote
|
||||
FIELD(data)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
struct tx_extra_service_node_winner
|
||||
{
|
||||
crypto::public_key m_service_node_key;
|
||||
@@ -277,6 +290,45 @@ namespace cryptonote
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
struct tx_extra_service_node_state_change
|
||||
{
|
||||
struct vote
|
||||
{
|
||||
vote() = default;
|
||||
vote(crypto::signature const &signature, uint32_t validator_index) : signature(signature), validator_index(validator_index) {}
|
||||
crypto::signature signature;
|
||||
uint32_t validator_index;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(validator_index)
|
||||
FIELD(signature)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
service_nodes::new_state state;
|
||||
uint64_t block_height;
|
||||
uint32_t service_node_index;
|
||||
std::vector<vote> votes;
|
||||
|
||||
tx_extra_service_node_state_change() = default;
|
||||
|
||||
template<typename... VotesArgs>
|
||||
tx_extra_service_node_state_change(service_nodes::new_state state, uint64_t block_height, uint32_t service_node_index, VotesArgs &&...votes)
|
||||
: state{state}, block_height{block_height}, service_node_index{service_node_index}, votes{std::forward<VotesArgs>(votes)...} {}
|
||||
|
||||
bool operator==(const tx_extra_service_node_state_change &sc) const
|
||||
{
|
||||
return state == sc.state && block_height == sc.block_height && service_node_index == sc.service_node_index;
|
||||
}
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
ENUM_FIELD(state, state < service_nodes::new_state::_count)
|
||||
FIELD(block_height)
|
||||
FIELD(service_node_index)
|
||||
FIELD(votes)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
struct tx_extra_tx_secret_key
|
||||
{
|
||||
crypto::secret_key key;
|
||||
@@ -324,35 +376,37 @@ namespace cryptonote
|
||||
tx_extra_merge_mining_tag,
|
||||
tx_extra_additional_pub_keys,
|
||||
tx_extra_mysterious_minergate,
|
||||
tx_extra_offshore,
|
||||
tx_extra_memo,
|
||||
tx_extra_offshore,
|
||||
tx_extra_memo,
|
||||
tx_extra_service_node_pubkey,
|
||||
tx_extra_service_node_register,
|
||||
tx_extra_service_node_contributor,
|
||||
tx_extra_service_node_winner,
|
||||
tx_extra_service_node_deregister,
|
||||
tx_extra_service_node_state_change,
|
||||
tx_extra_tx_secret_key,
|
||||
tx_extra_tx_key_image_proofs,
|
||||
tx_extra_tx_key_image_unlock
|
||||
tx_extra_tx_key_image_unlock,
|
||||
tx_extra_service_node_deregister
|
||||
> tx_extra_field;
|
||||
}
|
||||
|
||||
BLOB_SERIALIZER(cryptonote::tx_extra_service_node_deregister::vote);
|
||||
BLOB_SERIALIZER(cryptonote::tx_extra_tx_key_image_proofs::proof);
|
||||
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_padding, TX_EXTRA_TAG_PADDING);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_pub_key, TX_EXTRA_TAG_PUBKEY);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_nonce, TX_EXTRA_NONCE);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_merge_mining_tag, TX_EXTRA_MERGE_MINING_TAG);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_additional_pub_keys, TX_EXTRA_TAG_ADDITIONAL_PUBKEYS);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_mysterious_minergate, TX_EXTRA_MYSTERIOUS_MINERGATE_TAG);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_offshore, TX_EXTRA_TAG_OFFSHORE);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_memo, TX_EXTRA_TAG_MEMO);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_register, TX_EXTRA_TAG_SERVICE_NODE_REGISTER);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_deregister, TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_contributor, TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_winner, TX_EXTRA_TAG_SERVICE_NODE_WINNER);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_pubkey, TX_EXTRA_TAG_SERVICE_NODE_PUBKEY);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_secret_key, TX_EXTRA_TAG_TX_SECRET_KEY);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_proofs, TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_unlock, TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_padding, TX_EXTRA_TAG_PADDING);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_pub_key, TX_EXTRA_TAG_PUBKEY);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_nonce, TX_EXTRA_NONCE);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_merge_mining_tag, TX_EXTRA_MERGE_MINING_TAG);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_additional_pub_keys, TX_EXTRA_TAG_ADDITIONAL_PUBKEYS);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_mysterious_minergate, TX_EXTRA_MYSTERIOUS_MINERGATE_TAG);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_offshore, TX_EXTRA_TAG_OFFSHORE);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_memo, TX_EXTRA_TAG_MEMO);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_register, TX_EXTRA_TAG_SERVICE_NODE_REGISTER);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_state_change, TX_EXTRA_TAG_SERVICE_NODE_STATE_CHANGE);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_contributor, TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_winner, TX_EXTRA_TAG_SERVICE_NODE_WINNER);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_pubkey, TX_EXTRA_TAG_SERVICE_NODE_PUBKEY);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_secret_key, TX_EXTRA_TAG_TX_SECRET_KEY);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_proofs, TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_unlock, TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK);
|
||||
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_deregister, TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER);
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#define HF_VERSION_XASSET_FEES_V2 17
|
||||
#define HF_VERSION_HAVEN2 18
|
||||
#define HF_VERSION_USE_COLLATERAL 20
|
||||
#define HF_VERSION_ENABLE_N_OUTS 2
|
||||
#define TRANSACTION_VERSION_N_OUTS 3
|
||||
#define TRANSACTION_VERSION_CARROT 4
|
||||
|
||||
// UNLOCK TIMES
|
||||
#define TX_V6_OFFSHORE_UNLOCK_BLOCKS 21*720 // 21 day unlock time
|
||||
@@ -37,4 +40,5 @@ enum BLOB_TYPE {
|
||||
BLOB_TYPE_CRYPTONOTE_ZEPHYR = 13, // ZEPHYR
|
||||
BLOB_TYPE_CRYPTONOTE_XLA = 14, // XLA
|
||||
BLOB_TYPE_CRYPTONOTE_SALVIUM= 15, // Salvium
|
||||
BLOB_TYPE_CRYPTONOTE_ARQMA = 16 // Arqma
|
||||
};
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#ifndef CRYPTONOTE_ENUMS_H
|
||||
#define CRYPTONOTE_ENUMS_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
enum salvium_transaction_type
|
||||
{
|
||||
UNSET = 0,
|
||||
MINER = 1,
|
||||
PROTOCOL = 2,
|
||||
TRANSFER = 3,
|
||||
CONVERT = 4,
|
||||
BURN = 5,
|
||||
STAKE = 6,
|
||||
RETURN = 7,
|
||||
AUDIT = 8,
|
||||
MAX = 8
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CRYPTONOTE_ENUMS_H
|
||||
+9
-4
@@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
#include "cryptonote_basic/tx_extra.h"
|
||||
#include "common/base58.h"
|
||||
#include "serialization/binary_utils.h"
|
||||
#include <nan.h>
|
||||
@@ -32,7 +33,7 @@ blobdata uint64be_to_blob(uint64_t num) {
|
||||
res[7] = num & 0xff;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static bool fillExtra(cryptonote::block& block1, const cryptonote::block& block2) {
|
||||
cryptonote::tx_extra_merge_mining_tag mm_tag;
|
||||
mm_tag.depth = 0;
|
||||
@@ -250,7 +251,7 @@ NAN_METHOD(address_decode) {
|
||||
Local<Object> target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
|
||||
if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object.");
|
||||
|
||||
|
||||
blobdata input = std::string(Buffer::Data(target), Buffer::Length(target));
|
||||
|
||||
blobdata data;
|
||||
@@ -330,7 +331,11 @@ NAN_METHOD(construct_mm_parent_block_blob) { // (parentBlockTemplate, blob_type,
|
||||
b.set_blob_type(blob_type);
|
||||
if (!parse_and_validate_block_from_blob(input, b)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to parse prent block");
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC) b.miner_tx.version = cryptonote::loki_version_2;
|
||||
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_ARQMA) {
|
||||
b.miner_tx.version = static_cast<size_t>(cryptonote_arq::txversion::v3);
|
||||
b.miner_tx.arq_tx_type = cryptonote_arq::txtype::standard;
|
||||
}
|
||||
|
||||
block b2 = AUTO_VAL_INIT(b2);
|
||||
b2.set_blob_type(BLOB_TYPE_FORKNOTE2);
|
||||
if (!parse_and_validate_block_from_blob(child_input, b2)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to parse child block");
|
||||
@@ -369,7 +374,7 @@ NAN_METHOD(construct_mm_child_block_blob) { // (shareBuffer, blob_type, childBlo
|
||||
if (!parse_and_validate_block_from_blob(child_block_template_blob, b2)) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to parse child block");
|
||||
|
||||
if (!mergeBlocks(b, b2, std::vector<crypto::hash>())) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to postprocess mining block");
|
||||
|
||||
|
||||
blobdata output = "";
|
||||
if (!block_to_blob(b2, output)) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to convert child block to blob");
|
||||
|
||||
|
||||
+221
-211
@@ -52,6 +52,8 @@ extern "C" {
|
||||
#include "serialization/vector.h"
|
||||
#include "serialization/binary_archive.h"
|
||||
|
||||
#include "cryptonote_protocol/enums.h"
|
||||
|
||||
|
||||
//Define this flag when debugging to get additional info on the console
|
||||
#ifdef DBG
|
||||
@@ -87,8 +89,18 @@ namespace rct {
|
||||
typedef std::vector<key> keyV; //vector of keys
|
||||
typedef std::vector<keyV> keyM; //matrix of keys (indexed by column first)
|
||||
|
||||
static key null_key = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
struct zk_proof {
|
||||
key R; // Commitment
|
||||
key z1; // Response
|
||||
key z2; // Response
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(R)
|
||||
FIELD(z1)
|
||||
FIELD(z2)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
//containers For CT operations
|
||||
//if it's representing a private ctkey then "dest" contains the secret key of the address
|
||||
// while "mask" contains a where C = aG + bH is CT pedersen commitment and b is the amount
|
||||
@@ -101,6 +113,22 @@ namespace rct {
|
||||
typedef std::vector<ctkey> ctkeyV;
|
||||
typedef std::vector<ctkeyV> ctkeyM;
|
||||
|
||||
struct carrot_ctkey {
|
||||
key x;
|
||||
key y;
|
||||
key mask; //C here if public
|
||||
|
||||
bool operator==(const carrot_ctkey &other) const {
|
||||
return (x == other.x) && (y == other.y) && (mask == other.mask);
|
||||
}
|
||||
|
||||
bool operator!=(const carrot_ctkey &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
typedef std::vector<carrot_ctkey> carrot_ctkeyV;
|
||||
typedef std::vector<carrot_ctkey> carrot_ctkeyM;
|
||||
|
||||
//used for multisig data
|
||||
struct multisig_kLRki {
|
||||
key k;
|
||||
@@ -149,12 +177,12 @@ namespace rct {
|
||||
key64 s1;
|
||||
key ee;
|
||||
};
|
||||
|
||||
|
||||
//Container for precomp
|
||||
struct geDsmp {
|
||||
ge_dsmp k;
|
||||
};
|
||||
|
||||
|
||||
//just contains the necessary keys to represent MLSAG sigs
|
||||
//c.f. https://eprint.iacr.org/2015/1098
|
||||
struct mgSig {
|
||||
@@ -185,6 +213,24 @@ namespace rct {
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
// TCLSAG signature
|
||||
struct tclsag {
|
||||
keyV sx; // x scalars(responses)
|
||||
keyV sy; // y scalars(responses)
|
||||
key c1;
|
||||
|
||||
key I; // signing key image
|
||||
key D; // commitment key image
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(sx)
|
||||
FIELD(sy)
|
||||
FIELD(c1)
|
||||
// FIELD(I) - not serialized, it can be reconstructed
|
||||
FIELD(D)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
//contains the data for an Borromean sig
|
||||
// also contains the "Ci" values such that
|
||||
// \sum Ci = C
|
||||
@@ -294,10 +340,10 @@ namespace rct {
|
||||
RCTTypeBulletproof = 3,
|
||||
RCTTypeBulletproof2 = 4,
|
||||
RCTTypeCLSAG = 5,
|
||||
RCTTypeCLSAGN = 6,
|
||||
RCTTypeHaven2 = 7, // Add public mask sum terms, remove extraneous fields (txnFee_usd,txnFee_xasset,txnOffshoreFee_usd,txnOffshoreFee_xasset)
|
||||
RCTTypeHaven3 = 8, // Add public mask sum term for collateral
|
||||
RCTTypeBulletproofPlus = 9,
|
||||
RCTTypeBulletproofPlus = 6,
|
||||
RCTTypeFullProofs = 7,
|
||||
RCTTypeSalviumZero = 8,
|
||||
RCTTypeSalviumOne = 9
|
||||
};
|
||||
enum RangeProofType { RangeProofBorromean, RangeProofBulletproof, RangeProofMultiOutputBulletproof, RangeProofPaddedBulletproof };
|
||||
struct RCTConfig {
|
||||
@@ -310,6 +356,51 @@ namespace rct {
|
||||
VARINT_FIELD(bp_version)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
enum SalviumDataType { SalviumZero=0, SalviumZeroAudit=1, SalviumOne=2 };
|
||||
struct salvium_input_data_t {
|
||||
crypto::key_derivation aR;
|
||||
xmr_amount amount;
|
||||
size_t i;
|
||||
uint8_t origin_tx_type;
|
||||
crypto::key_derivation aR_stake;
|
||||
size_t i_stake;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(aR)
|
||||
VARINT_FIELD(amount)
|
||||
VARINT_FIELD(i)
|
||||
VARINT_FIELD(origin_tx_type)
|
||||
if (origin_tx_type != cryptonote::salvium_transaction_type::UNSET) {
|
||||
FIELD(aR_stake)
|
||||
FIELD(i_stake)
|
||||
}
|
||||
END_SERIALIZE()
|
||||
};
|
||||
struct salvium_data_t {
|
||||
|
||||
uint8_t salvium_data_type; // flag to indicate what type of data is valid
|
||||
zk_proof pr_proof; // p_r
|
||||
zk_proof sa_proof; // spend authority proof
|
||||
zk_proof cz_proof; // change is zero proof
|
||||
std::vector<salvium_input_data_t> input_verification_data;
|
||||
crypto::public_key spend_pubkey;
|
||||
std::string enc_view_privkey_str;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(salvium_data_type)
|
||||
FIELD(pr_proof)
|
||||
FIELD(sa_proof)
|
||||
if (salvium_data_type == SalviumZeroAudit)
|
||||
{
|
||||
FIELD(cz_proof)
|
||||
FIELD(input_verification_data)
|
||||
FIELD(spend_pubkey)
|
||||
FIELD(enc_view_privkey_str)
|
||||
}
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
struct rctSigBase {
|
||||
uint8_t type;
|
||||
key message;
|
||||
@@ -318,16 +409,15 @@ namespace rct {
|
||||
keyV pseudoOuts; //C - for simple rct
|
||||
std::vector<ecdhTuple> ecdhInfo;
|
||||
ctkeyV outPk;
|
||||
ctkeyV outPk_usd;
|
||||
ctkeyV outPk_xasset;
|
||||
xmr_amount txnFee = 0; // contains b
|
||||
xmr_amount txnFee_usd = 0;
|
||||
xmr_amount txnFee_xasset = 0;
|
||||
xmr_amount txnOffshoreFee = 0;
|
||||
xmr_amount txnOffshoreFee_usd = 0;
|
||||
xmr_amount txnOffshoreFee_xasset = 0;
|
||||
keyV maskSums; // contains 2 or 3 elements. 1. is the sum of masks of inputs. 2. is the sum of masks of change outputs. 3. mask of the col output.
|
||||
key p_r;
|
||||
zk_proof pr_proof; // p_r
|
||||
zk_proof sa_proof; // spend authority proof
|
||||
salvium_data_t salvium_data;
|
||||
|
||||
rctSigBase() :
|
||||
type(RCTTypeNull), message{}, mixRing{}, pseudoOuts{}, ecdhInfo{}, outPk{}, txnFee(0), p_r{}, pr_proof{}, sa_proof{}
|
||||
{}
|
||||
|
||||
template<bool W, template <bool> class Archive>
|
||||
bool serialize_rctsig_base(Archive<W> &ar, size_t inputs, size_t outputs)
|
||||
@@ -335,10 +425,9 @@ namespace rct {
|
||||
FIELD(type)
|
||||
if (type == RCTTypeNull)
|
||||
return ar.stream().good();
|
||||
if (type != RCTTypeBulletproofPlus)
|
||||
return serialize_rctsig_base_old(ar, inputs, outputs);
|
||||
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeBulletproofPlus && type != RCTTypeFullProofs && type != RCTTypeSalviumZero && type != RCTTypeSalviumOne)
|
||||
return false;
|
||||
VARINT_FIELD(txnFee)
|
||||
VARINT_FIELD(txnOffshoreFee)
|
||||
// inputs/outputs not saved, only here for serialization help
|
||||
// FIELD(message) - not serialized, it can be reconstructed
|
||||
// FIELD(mixRing) - not serialized, it can be reconstructed
|
||||
@@ -349,193 +438,48 @@ namespace rct {
|
||||
return false;
|
||||
for (size_t i = 0; i < outputs; ++i)
|
||||
{
|
||||
ar.begin_object();
|
||||
if (!typename Archive<W>::is_saving())
|
||||
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
|
||||
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
|
||||
FIELD(amount);
|
||||
ar.end_object();
|
||||
if (outputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
ar.tag("outPk");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
|
||||
if (outPk.size() != outputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < outputs; ++i)
|
||||
{
|
||||
FIELDS(outPk[i].mask)
|
||||
if (outputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
// if txnOffshoreFee is not 0, it is a conversion tx
|
||||
if (txnOffshoreFee) {
|
||||
ar.tag("maskSums");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(3, maskSums);
|
||||
if (maskSums.size() != 3)
|
||||
return false;
|
||||
FIELDS(maskSums[0])
|
||||
ar.delimit_array();
|
||||
FIELDS(maskSums[1])
|
||||
ar.delimit_array();
|
||||
FIELDS(maskSums[2])
|
||||
ar.end_array();
|
||||
}
|
||||
if (crypto_verify_32(p_r.bytes, null_key.bytes))
|
||||
FIELD(p_r)
|
||||
return ar.stream().good();
|
||||
}
|
||||
|
||||
template<bool W, template <bool> class Archive>
|
||||
bool serialize_rctsig_base_old(Archive<W> &ar, size_t inputs, size_t outputs)
|
||||
{
|
||||
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2 && type != RCTTypeHaven3)
|
||||
return false;
|
||||
VARINT_FIELD(txnFee)
|
||||
if (type == RCTTypeHaven2 || type == RCTTypeHaven3) {
|
||||
// serialize offshore fee
|
||||
VARINT_FIELD(txnOffshoreFee)
|
||||
} else if (type == RCTTypeCLSAG || type == RCTTypeCLSAGN) {
|
||||
VARINT_FIELD(txnFee_usd)
|
||||
if (type == RCTTypeCLSAGN)
|
||||
{
|
||||
VARINT_FIELD(txnFee_xasset)
|
||||
}
|
||||
VARINT_FIELD(txnOffshoreFee)
|
||||
VARINT_FIELD(txnOffshoreFee_usd)
|
||||
if (type == RCTTypeCLSAGN)
|
||||
{
|
||||
VARINT_FIELD(txnOffshoreFee_xasset)
|
||||
}
|
||||
} else {
|
||||
txnFee_usd = 0;
|
||||
txnFee_xasset = 0;
|
||||
txnOffshoreFee = 0;
|
||||
txnOffshoreFee_usd = 0;
|
||||
txnOffshoreFee_xasset = 0;
|
||||
}
|
||||
// inputs/outputs not saved, only here for serialization help
|
||||
// FIELD(message) - not serialized, it can be reconstructed
|
||||
// FIELD(mixRing) - not serialized, it can be reconstructed
|
||||
if (type == RCTTypeSimple) // moved to prunable with bulletproofs
|
||||
{
|
||||
ar.tag("pseudoOuts");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(inputs, pseudoOuts);
|
||||
if (pseudoOuts.size() != inputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < inputs; ++i)
|
||||
{
|
||||
FIELDS(pseudoOuts[i])
|
||||
if (inputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
}
|
||||
|
||||
ar.tag("ecdhInfo");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, ecdhInfo);
|
||||
if (ecdhInfo.size() != outputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < outputs; ++i)
|
||||
{
|
||||
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
|
||||
{
|
||||
ar.begin_object();
|
||||
if (!typename Archive<W>::is_saving())
|
||||
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
|
||||
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
|
||||
FIELD(amount);
|
||||
ar.end_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
FIELDS(ecdhInfo[i])
|
||||
}
|
||||
if (outputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
ar.tag("outPk");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
|
||||
if (outPk.size() != outputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < outputs; ++i)
|
||||
{
|
||||
FIELDS(outPk[i].mask)
|
||||
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero || type == RCTTypeSalviumOne)
|
||||
{
|
||||
// Since RCTTypeBulletproof2 enote types, we don't serialize the blinding factor, and only serialize the
|
||||
// first 8 bytes of ecdhInfo[i].amount
|
||||
ar.begin_object();
|
||||
if (!typename Archive<W>::is_saving())
|
||||
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
|
||||
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
|
||||
FIELD(amount);
|
||||
ar.end_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
FIELDS(ecdhInfo[i])
|
||||
}
|
||||
if (outputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
// if txnOffshoreFee is not 0, it is a conversion tx
|
||||
if (type == RCTTypeHaven3 && txnOffshoreFee) {
|
||||
|
||||
ar.tag("maskSums");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(3, maskSums);
|
||||
if (maskSums.size() != 3)
|
||||
return false;
|
||||
FIELDS(maskSums[0])
|
||||
ar.delimit_array();
|
||||
FIELDS(maskSums[1])
|
||||
ar.delimit_array();
|
||||
FIELDS(maskSums[2])
|
||||
ar.end_array();
|
||||
ar.tag("outPk");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
|
||||
if (outPk.size() != outputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < outputs; ++i)
|
||||
{
|
||||
FIELDS(outPk[i].mask)
|
||||
if (outputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
} else if (type == RCTTypeHaven2) {
|
||||
|
||||
ar.tag("maskSums");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(2, maskSums);
|
||||
if (maskSums.size() != 2)
|
||||
return false;
|
||||
FIELDS(maskSums[0])
|
||||
ar.delimit_array();
|
||||
FIELDS(maskSums[1])
|
||||
ar.end_array();
|
||||
|
||||
} else {
|
||||
|
||||
if ((type == RCTTypeCLSAG) || (type == RCTTypeCLSAGN))
|
||||
{
|
||||
ar.tag("outPk_usd");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk_usd);
|
||||
if (outPk_usd.size() != outputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < outputs; ++i)
|
||||
{
|
||||
FIELDS(outPk_usd[i].mask)
|
||||
if (outputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
}
|
||||
if (type == RCTTypeCLSAGN)
|
||||
{
|
||||
ar.tag("outPk_xasset");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk_xasset);
|
||||
if (outPk_xasset.size() != outputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < outputs; ++i)
|
||||
{
|
||||
FIELDS(outPk_xasset[i].mask)
|
||||
if (outputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
}
|
||||
FIELD(p_r)
|
||||
if (type == RCTTypeSalviumZero || type == RCTTypeSalviumOne)
|
||||
{
|
||||
FIELD(salvium_data)
|
||||
}
|
||||
else if (type == RCTTypeFullProofs)
|
||||
{
|
||||
FIELD(pr_proof)
|
||||
FIELD(sa_proof)
|
||||
}
|
||||
return ar.stream().good();
|
||||
}
|
||||
@@ -548,8 +492,15 @@ namespace rct {
|
||||
FIELD(ecdhInfo)
|
||||
FIELD(outPk)
|
||||
VARINT_FIELD(txnFee)
|
||||
VARINT_FIELD(txnOffshoreFee)
|
||||
FIELD(maskSums)
|
||||
FIELD(p_r)
|
||||
if (type == RCTTypeSalviumZero || type == RCTTypeSalviumOne)
|
||||
{
|
||||
FIELD(salvium_data)
|
||||
}
|
||||
else if (type == RCTTypeFullProofs) {
|
||||
FIELD(pr_proof)
|
||||
FIELD(sa_proof)
|
||||
}
|
||||
END_SERIALIZE()
|
||||
};
|
||||
struct rctSigPrunable {
|
||||
@@ -558,6 +509,7 @@ namespace rct {
|
||||
std::vector<BulletproofPlus> bulletproofs_plus;
|
||||
std::vector<mgSig> MGs; // simple rct has N, full has 1
|
||||
std::vector<clsag> CLSAGs;
|
||||
std::vector<tclsag> TCLSAGs;
|
||||
keyV pseudoOuts; //C - for simple rct
|
||||
|
||||
// when changing this function, update cryptonote::get_pruned_transaction_weight
|
||||
@@ -572,9 +524,9 @@ namespace rct {
|
||||
return false;
|
||||
if (type == RCTTypeNull)
|
||||
return ar.stream().good();
|
||||
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2 && type != RCTTypeHaven3 && type != RCTTypeBulletproofPlus)
|
||||
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeBulletproofPlus && type != RCTTypeFullProofs && type != RCTTypeSalviumZero && type != RCTTypeSalviumOne)
|
||||
return false;
|
||||
if (type == RCTTypeBulletproofPlus)
|
||||
if (type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero || type == RCTTypeSalviumOne)
|
||||
{
|
||||
uint32_t nbp = bulletproofs_plus.size();
|
||||
VARINT_FIELD(nbp)
|
||||
@@ -593,10 +545,10 @@ namespace rct {
|
||||
return false;
|
||||
ar.end_array();
|
||||
}
|
||||
else if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
|
||||
else if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG)
|
||||
{
|
||||
uint32_t nbp = bulletproofs.size();
|
||||
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
|
||||
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG)
|
||||
VARINT_FIELD(nbp)
|
||||
else
|
||||
FIELD(nbp)
|
||||
@@ -631,7 +583,60 @@ namespace rct {
|
||||
ar.end_array();
|
||||
}
|
||||
|
||||
if (type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus)
|
||||
if (type == RCTTypeSalviumOne)
|
||||
{
|
||||
ar.tag("TCLSAGs");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(inputs, TCLSAGs);
|
||||
if (TCLSAGs.size() != inputs)
|
||||
return false;
|
||||
for (size_t i = 0; i < inputs; ++i)
|
||||
{
|
||||
// we save the TCLSAGs contents directly, because we want it to save its
|
||||
// arrays without the size prefixes, and the load can't know what size
|
||||
// to expect if it's not in the data
|
||||
ar.begin_object();
|
||||
ar.tag("sx");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(mixin + 1, TCLSAGs[i].sx);
|
||||
if (TCLSAGs[i].sx.size() != mixin + 1)
|
||||
return false;
|
||||
for (size_t j = 0; j <= mixin; ++j)
|
||||
{
|
||||
FIELDS(TCLSAGs[i].sx[j])
|
||||
if (mixin + 1 - j > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
ar.tag("sy");
|
||||
ar.begin_array();
|
||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(mixin + 1, TCLSAGs[i].sy);
|
||||
if (TCLSAGs[i].sy.size() != mixin + 1)
|
||||
return false;
|
||||
for (size_t j = 0; j <= mixin; ++j)
|
||||
{
|
||||
FIELDS(TCLSAGs[i].sy[j])
|
||||
if (mixin + 1 - j > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
ar.tag("c1");
|
||||
FIELDS(TCLSAGs[i].c1)
|
||||
|
||||
// CLSAGs[i].I not saved, it can be reconstructed
|
||||
ar.tag("D");
|
||||
FIELDS(TCLSAGs[i].D)
|
||||
ar.end_object();
|
||||
|
||||
if (inputs - i > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
|
||||
ar.end_array();
|
||||
|
||||
} else if (type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero)
|
||||
{
|
||||
ar.tag("CLSAGs");
|
||||
ar.begin_array();
|
||||
@@ -706,7 +711,7 @@ namespace rct {
|
||||
ar.delimit_array();
|
||||
}
|
||||
ar.end_array();
|
||||
|
||||
|
||||
if (mixin + 1 - j > 1)
|
||||
ar.delimit_array();
|
||||
}
|
||||
@@ -722,7 +727,7 @@ namespace rct {
|
||||
}
|
||||
ar.end_array();
|
||||
}
|
||||
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus)
|
||||
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero || type == RCTTypeSalviumOne)
|
||||
{
|
||||
ar.tag("pseudoOuts");
|
||||
ar.begin_array();
|
||||
@@ -746,6 +751,7 @@ namespace rct {
|
||||
FIELD(bulletproofs_plus)
|
||||
FIELD(MGs)
|
||||
FIELD(CLSAGs)
|
||||
FIELD(TCLSAGs)
|
||||
FIELD(pseudoOuts)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
@@ -754,12 +760,12 @@ namespace rct {
|
||||
|
||||
keyV& get_pseudo_outs()
|
||||
{
|
||||
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus ? p.pseudoOuts : pseudoOuts;
|
||||
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero || type == RCTTypeSalviumOne ? p.pseudoOuts : pseudoOuts;
|
||||
}
|
||||
|
||||
keyV const& get_pseudo_outs() const
|
||||
{
|
||||
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus ? p.pseudoOuts : pseudoOuts;
|
||||
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero || type == RCTTypeSalviumOne ? p.pseudoOuts : pseudoOuts;
|
||||
}
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
@@ -930,5 +936,9 @@ VARIANT_TAG(binary_archive, rct::multisig_kLRki, 0x9d);
|
||||
VARIANT_TAG(binary_archive, rct::multisig_out, 0x9e);
|
||||
VARIANT_TAG(binary_archive, rct::clsag, 0x9f);
|
||||
VARIANT_TAG(binary_archive, rct::BulletproofPlus, 0xa0);
|
||||
VARIANT_TAG(binary_archive, rct::zk_proof, 0xa1);
|
||||
VARIANT_TAG(binary_archive, rct::salvium_input_data_t, 0xa2);
|
||||
VARIANT_TAG(binary_archive, rct::salvium_data_t, 0xa3);
|
||||
VARIANT_TAG(binary_archive, rct::tclsag, 0xa4);
|
||||
|
||||
#endif /* RCTTYPES_H */
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "crypto/chacha8.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/hash.h"
|
||||
#include "carrot_core/core_types.h"
|
||||
|
||||
// read
|
||||
template <template <bool> class Archive>
|
||||
@@ -62,3 +63,5 @@ BLOB_SERIALIZER(crypto::key_derivation);
|
||||
BLOB_SERIALIZER(crypto::key_image);
|
||||
BLOB_SERIALIZER(crypto::signature);
|
||||
BLOB_SERIALIZER(crypto::view_tag);
|
||||
BLOB_SERIALIZER(carrot::view_tag_t);
|
||||
BLOB_SERIALIZER(carrot::janus_anchor_t);
|
||||
|
||||
@@ -97,6 +97,29 @@ inline bool do_serialize(Archive &ar, bool &v)
|
||||
bool r = ::do_serialize(ar, f); \
|
||||
if (!r || !ar.stream().good()) return false; \
|
||||
} while(0);
|
||||
/*! \macro ENUM_FIELD(f, test)
|
||||
* \brief tags and serializes (as a varint) the scoped enum \a f with a requirement that expression\
|
||||
* \a test be true(typically for range testing).
|
||||
*/
|
||||
#define ENUM_FIELD(f, test) ENUM_FIELD_N(#f, f, test)
|
||||
/*! \macro ENUM_FIELD_N(t, f, begin, end)
|
||||
*
|
||||
* \brief tags (as \a t) and serializes (as a varint) the scoped enum \a f with a requirement that
|
||||
* expression \a test be true (typically for range testing).
|
||||
*/
|
||||
#define ENUM_FIELD_N(t, f, test) \
|
||||
do { \
|
||||
using enum_t = decltype(f); \
|
||||
using int_t = typename std::underlying_type<enum_t>::type; \
|
||||
int_t int_value = W ? static_cast<int_t>(f) : 0; \
|
||||
ar.tag(t); \
|
||||
ar.serialize_varint(int_value); \
|
||||
if(!ar.stream().good()) return false; \
|
||||
if(!W) { \
|
||||
f = static_cast<enum_t>(int_value); \
|
||||
if(!(test)) return false; \
|
||||
} \
|
||||
} while(0);
|
||||
#define VARINT_FIELD(f) \
|
||||
do { \
|
||||
ar.tag(#f); \
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// Copyright (c) 2019, Haven Protocol
|
||||
//
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
@@ -25,7 +25,7 @@
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#pragma once
|
||||
@@ -40,6 +40,7 @@
|
||||
template <template <bool> class Archive>
|
||||
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t version)
|
||||
{
|
||||
|
||||
if (version >= 6)
|
||||
{
|
||||
// very basic sanity check
|
||||
|
||||
@@ -32,23 +32,37 @@
|
||||
namespace zephyr_oracle {
|
||||
|
||||
const std::vector<std::string> ASSET_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD"};
|
||||
const std::vector<std::string> RESERVE_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD", "ZYIELDRSV"};
|
||||
|
||||
const std::vector<std::string> ASSET_TYPES_V2 = {"ZPH", "ZSD", "ZRS", "ZYS"};
|
||||
const std::vector<std::string> RESERVE_TYPES_V2 = {"DJED", "YIELD"};
|
||||
|
||||
class asset_type_counts
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Fields
|
||||
// Fields
|
||||
uint64_t ZEPH;
|
||||
uint64_t ZEPHUSD;
|
||||
uint64_t ZEPHRSV;
|
||||
uint64_t ZYIELD;
|
||||
|
||||
// v2 fields
|
||||
uint64_t ZPH;
|
||||
uint64_t ZSD;
|
||||
uint64_t ZRS;
|
||||
uint64_t ZYS;
|
||||
|
||||
asset_type_counts() noexcept
|
||||
: ZEPH(0)
|
||||
, ZEPHUSD(0)
|
||||
, ZEPHRSV(0)
|
||||
, ZYIELD(0)
|
||||
, ZPH(0)
|
||||
, ZSD(0)
|
||||
, ZRS(0)
|
||||
, ZYS(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -62,6 +76,14 @@ namespace zephyr_oracle {
|
||||
return ZEPHRSV;
|
||||
} else if (asset_type == "ZYIELD") {
|
||||
return ZYIELD;
|
||||
} else if (asset_type == "ZPH") {
|
||||
return ZPH;
|
||||
} else if (asset_type == "ZSD") {
|
||||
return ZSD;
|
||||
} else if (asset_type == "ZRS") {
|
||||
return ZRS;
|
||||
} else if (asset_type == "ZYS") {
|
||||
return ZYS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -77,6 +99,14 @@ namespace zephyr_oracle {
|
||||
ZEPHRSV += val;
|
||||
} else if (asset_type == "ZYIELD") {
|
||||
ZYIELD += val;
|
||||
} else if (asset_type == "ZPH") {
|
||||
ZPH += val;
|
||||
} else if (asset_type == "ZSD") {
|
||||
ZSD += val;
|
||||
} else if (asset_type == "ZRS") {
|
||||
ZRS += val;
|
||||
} else if (asset_type == "ZYS") {
|
||||
ZYS += val;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace zephyr_oracle
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
pricing_record::pricing_record() noexcept
|
||||
: spot(0)
|
||||
, moving_average(0)
|
||||
@@ -152,7 +152,7 @@ namespace zephyr_oracle
|
||||
::memcpy(signature, orig.signature, sizeof(signature));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool pricing_record::equal(const pricing_record& other) const noexcept
|
||||
{
|
||||
return ((spot == other.spot) &&
|
||||
@@ -256,7 +256,7 @@ namespace zephyr_oracle
|
||||
}
|
||||
|
||||
// overload for pr validation for block
|
||||
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
|
||||
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
|
||||
{
|
||||
if (hf_version < 3) {
|
||||
if (!this->empty())
|
||||
@@ -298,4 +298,3 @@ namespace zephyr_oracle
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace zephyr_oracle
|
||||
|
||||
public:
|
||||
|
||||
// Fields
|
||||
// Fields
|
||||
uint64_t spot;
|
||||
uint64_t moving_average;
|
||||
uint64_t stable;
|
||||
@@ -127,7 +127,7 @@ namespace zephyr_oracle
|
||||
{
|
||||
return a.equal(b);
|
||||
}
|
||||
|
||||
|
||||
inline bool operator!=(const pricing_record& a, const pricing_record& b) noexcept
|
||||
{
|
||||
return !a.equal(b);
|
||||
@@ -252,4 +252,4 @@ namespace zephyr_oracle
|
||||
};
|
||||
};
|
||||
|
||||
} // oracle
|
||||
} // zephyr_oracle
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
let u = require('../build/Release/cryptoforknote');
|
||||
|
||||
const b = Buffer.from(
|
||||
'1010c59099c206028309f83a444da29afb16cc97126b0d82a0ef9dacdc5f5384e4d14f2bed221f00000000030005bbd769abd769abd769abd769abd769abd76901ff99d7690580c8afa02502c7a7d056ac171af27f081eb7113ee31eb6eac4c523960f31bc54ae4150fd087a80c8afa025022a74a3c4c36d32e95633d44ba9a7b8188297b2ac91afecab826b86fabaa7091680bcc1960b02a42e0bf2c44c7c5f43798f4be091a04d36e21b7a2f85008ff939dc028c1d14e980bcc1960b02c8b180ae1eef14bb14953eb6b0f8d66111c80067dfe9e689fdf72cf1b0d9d58580bcc1960b027d3ab388e3e7844bc42562edf05fb34d4b30b281b1307c75d7d3acfc90ed69b57601a15624111f421a5b16fd3350b5b234d288aa9e369a090fcdaeab7079361a74600211000000228f09650000000000000000000001cb6e8a28b50d5427f24dd6ede582e5eb895d739ad2cfe7eb7df31d7dcf1531c47200000000000000000000000000000000000000000000000000000000000000000000', 'hex');
|
||||
const b2 = u.convert_blob(b, 16);
|
||||
const h1 = b2.toString('hex');
|
||||
|
||||
if (h1 === '1010c59099c206028309f83a444da29afb16cc97126b0d82a0ef9dacdc5f5384e4d14f2bed221f000000006ebc660a5f50595d256087798e91ff9184878de2db66d791108ec4149dcd01fc01') {
|
||||
console.log('PASSED');
|
||||
} else {
|
||||
console.log('FAILED: ' + h1);
|
||||
process.exit(1);
|
||||
}
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
cd $DIR
|
||||
node arq.js || exit 1
|
||||
node bloc.js || exit 1
|
||||
node ird.js || exit 1
|
||||
node msr.js || exit 1
|
||||
@@ -15,4 +16,4 @@ node xla.js || exit 1
|
||||
node xmr.js || exit 1
|
||||
node xmv.js || exit 1
|
||||
node xtnc.js || exit 1
|
||||
node zeph.js || exit 1
|
||||
node zeph.js || exit 1
|
||||
|
||||
+2
-2
@@ -2,12 +2,12 @@
|
||||
let u = require('../build/Release/cryptoforknote');
|
||||
|
||||
const b = Buffer.from(
|
||||
'010194a5ebb406f613c4e7514facf3e5b9923c885357b53f2b02f8e17f9721371296b99113035f00000000020001ffcb6d018f9ffec12d03125e128c041c8a2d41fab9ebe2a7a4b10afbef4e134ec7ba3151c8c730a644310353414c3c7334015f99bdbbe70161dafb2da2fd9a4285da893a7519cff350981a959f525c43e5c60211000000000000000000000000000000000001e3c7bfb00b00020001ffcb6d0023016b6961b458286074406192961c1f0e5236455f45fcd6c175c7142d6353a481d60400020000'
|
||||
'0a0ad3efb6c706668aaad0289b8bf3bf8cd109d6da4107b48f4242185fa6d50b78575c55e728b400000000043c01ffdcb91401bac68dc22104fd2c8f800bd4c33b96cde12515224a403ea052736d98cf8c5d5a5ff4a66dddc00453414c3151042efafd5871735ab1f3dcb6c380e595b2d0340136a86969f8e7a0c4bd739cd6163b38e3c76f1fb443f7a552e755b305b11c53510211000000000000000000000000000000000001ceb1c3b00800043c01ffdcb91400020200020001c0d11e47cd1d4ef51d152f6f186f76a91623b8ce922687ce8c907a5dfda26237'
|
||||
, 'hex');
|
||||
const b2 = u.convert_blob(b, 15);
|
||||
const h1 = b2.toString('hex');
|
||||
|
||||
if (h1 === '010194a5ebb406f613c4e7514facf3e5b9923c885357b53f2b02f8e17f9721371296b99113035f00000000ac81ca3e7bc9369e63563923187d2cfdb42eac839c7fe24e6d5d0080c96d758f01') {
|
||||
if (h1 === '0a0ad3efb6c706668aaad0289b8bf3bf8cd109d6da4107b48f4242185fa6d50b78575c55e728b4000000003dc5e186a15e0b48571088e8b3c0a04597ff88a3dc3661cae2f0a2a8a2a81d7403') {
|
||||
console.log('PASSED');
|
||||
} else {
|
||||
console.log('FAILED: ' + h1);
|
||||
|
||||
Reference in New Issue
Block a user