Skip to content

Commit

Permalink
Merge pull request fancoder#2 from Gingeropolous/xmr-Nan-2.0
Browse files Browse the repository at this point in the history
deletel line 411 minor major return false
  • Loading branch information
clintar authored Dec 13, 2016
2 parents 31c531b + 48551c3 commit 55a1dde
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 42 deletions.
1 change: 0 additions & 1 deletion src/cryptonote_core/cryptonote_basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ namespace cryptonote

BEGIN_SERIALIZE_OBJECT()
VARINT_FIELD_N("major_version", b.major_version);
if(b.major_version > CURRENT_BYTECOIN_BLOCK_MAJOR_VERSION) return false;
VARINT_FIELD_N("minor_version", b.minor_version);
VARINT_FIELD(timestamp);
FIELD_N("prev_id", b.prev_id);
Expand Down
23 changes: 0 additions & 23 deletions src/cryptonote_core/cryptonote_format_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,16 +650,6 @@ namespace cryptonote
if (!get_block_hashing_blob(b, blob))
return false;

// if (BLOCK_MAJOR_VERSION_2 <= b.major_version)
// {
// blobdata parent_blob;
// auto sbb = make_serializable_bytecoin_block(b, true, false);
// if (!t_serializable_object_to_blob(sbb, parent_blob))
// return false;

// blob.append(parent_blob);
// }

return get_object_hash(blob, res);
}
//---------------------------------------------------------------
Expand Down Expand Up @@ -698,8 +688,6 @@ namespace cryptonote
string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);
bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
bl.major_version = CURRENT_BLOCK_MAJOR_VERSION;
bl.minor_version = CURRENT_BLOCK_MINOR_VERSION;
bl.timestamp = 0;
bl.nonce = 10000;
miner::find_nonce_for_given_block(bl, 1, 0);
Expand Down Expand Up @@ -851,17 +839,13 @@ namespace cryptonote
//---------------------------------------------------------------
bool check_proof_of_work_v1(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
{
// if (BLOCK_MAJOR_VERSION_1 != bl.major_version)
// return false;

proof_of_work = get_block_longhash(bl, 0);
return check_hash(proof_of_work, current_diffic);
}
//---------------------------------------------------------------
bool check_proof_of_work_v2(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
{
if (BLOCK_MAJOR_VERSION_2 != bl.major_version)
return false;

if (!get_bytecoin_block_longhash(bl, proof_of_work))
return false;
Expand Down Expand Up @@ -896,13 +880,6 @@ namespace cryptonote
//---------------------------------------------------------------
bool check_proof_of_work(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
{
switch (bl.major_version)
{
case BLOCK_MAJOR_VERSION_1: return check_proof_of_work_v1(bl, current_diffic, proof_of_work);
case BLOCK_MAJOR_VERSION_2: return check_proof_of_work_v1(bl, current_diffic, proof_of_work);
}

CHECK_AND_ASSERT_MES(false, false, "unknown block major version: " << bl.major_version << "." << bl.minor_version);
}
//---------------------------------------------------------------
}
5 changes: 1 addition & 4 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ NAN_METHOD(convert_blob_fa) {
if (!parse_and_validate_block_from_blob(input, b))
return THROW_ERROR_EXCEPTION("Failed to parse block");

if (b.major_version < BLOCK_MAJOR_VERSION_2) {
if (!get_block_hashing_blob(b, output))
return THROW_ERROR_EXCEPTION("Failed to create mining block");
} else {
else {
block parent_block;
if (!construct_parent_block(b, parent_block))
return THROW_ERROR_EXCEPTION("Failed to construct parent block");
Expand Down
30 changes: 16 additions & 14 deletions src/ringct/rctTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,10 @@ namespace rct {
typedef unsigned int bits[ATOMS];
typedef key key64[64];

//just contains the necessary keys to represent asnlSigs
//c.f. http://eprint.iacr.org/2015/1098
struct asnlSig {
key64 L1;
key64 s2;
key s;
struct boroSig {
key64 s0;
key64 s1;
key ee;
};

//Container for precomp
Expand All @@ -151,14 +149,14 @@ namespace rct {
// FIELD(II) - not serialized, it can be reconstructed
END_SERIALIZE()
};
//contains the data for an asnl sig
//contains the data for an Borromean sig
// also contains the "Ci" values such that
// \sum Ci = C
// and the signature proves that each Ci is either
// a Pedersen commitment to 0 or to 2^i
//thus proving that C is in the range of [0, 2^64]
struct rangeSig {
asnlSig asig;
boroSig asig;
key64 Ci;

BEGIN_SERIALIZE_OBJECT()
Expand Down Expand Up @@ -281,6 +279,7 @@ namespace rct {
// we save the MGs contents directly, because we want it to save its
// arrays and matrices 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("ss");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(mixin + 1, MGs[i].ss);
Expand All @@ -296,7 +295,7 @@ namespace rct {
for (size_t k = 0; k < mg_ss2_elements; ++k)
{
FIELDS(MGs[i].ss[j][k])
if (mg_ss2_elements - j > 1)
if (mg_ss2_elements - k > 1)
ar.delimit_array();
}
ar.end_array();
Expand All @@ -306,10 +305,13 @@ namespace rct {
}
ar.end_array();

ar.tag("cc");
FIELDS(MGs[i].cc)
// MGs[i].II not saved, it can be reconstructed
if (mg_elements - i > 1)
ar.delimit_array();

ar.end_object();
}
ar.end_array();
return true;
Expand Down Expand Up @@ -415,7 +417,7 @@ namespace rct {
// then the value in the first 8 bytes is returned
xmr_amount h2d(const key &test);
//32 byte key to int[64]
void h2b(bits amountb2, key & test);
void h2b(bits amountb2, const key & test);
//int[64] to 32 byte key
void b2h(key & amountdh, bits amountb2);
//int[64] to uint long long
Expand Down Expand Up @@ -448,7 +450,7 @@ inline std::ostream &operator <<(std::ostream &o, const rct::key &v) { return pr
BLOB_SERIALIZER(rct::key);
BLOB_SERIALIZER(rct::key64);
BLOB_SERIALIZER(rct::ctkey);
BLOB_SERIALIZER(rct::asnlSig);
BLOB_SERIALIZER(rct::boroSig);

VARIANT_TAG(debug_archive, rct::key, "rct::key");
VARIANT_TAG(debug_archive, rct::key64, "rct::key64");
Expand All @@ -460,7 +462,7 @@ VARIANT_TAG(debug_archive, rct::ctkeyM, "rct::ctkeyM");
VARIANT_TAG(debug_archive, rct::ecdhTuple, "rct::ecdhTuple");
VARIANT_TAG(debug_archive, rct::mgSig, "rct::mgSig");
VARIANT_TAG(debug_archive, rct::rangeSig, "rct::rangeSig");
VARIANT_TAG(debug_archive, rct::asnlSig, "rct::asnlSig");
VARIANT_TAG(debug_archive, rct::boroSig, "rct::boroSig");
VARIANT_TAG(debug_archive, rct::rctSig, "rct::rctSig");

VARIANT_TAG(binary_archive, rct::key, 0x90);
Expand All @@ -473,7 +475,7 @@ VARIANT_TAG(binary_archive, rct::ctkeyM, 0x96);
VARIANT_TAG(binary_archive, rct::ecdhTuple, 0x97);
VARIANT_TAG(binary_archive, rct::mgSig, 0x98);
VARIANT_TAG(binary_archive, rct::rangeSig, 0x99);
VARIANT_TAG(binary_archive, rct::asnlSig, 0x9a);
VARIANT_TAG(binary_archive, rct::boroSig, 0x9a);
VARIANT_TAG(binary_archive, rct::rctSig, 0x9b);

VARIANT_TAG(json_archive, rct::key, "rct_key");
Expand All @@ -486,7 +488,7 @@ VARIANT_TAG(json_archive, rct::ctkeyM, "rct_ctkeyM");
VARIANT_TAG(json_archive, rct::ecdhTuple, "rct_ecdhTuple");
VARIANT_TAG(json_archive, rct::mgSig, "rct_mgSig");
VARIANT_TAG(json_archive, rct::rangeSig, "rct_rangeSig");
VARIANT_TAG(json_archive, rct::asnlSig, "rct_asnlSig");
VARIANT_TAG(json_archive, rct::boroSig, "rct_boroSig");
VARIANT_TAG(json_archive, rct::rctSig, "rct_rctSig");

#endif /* RCTTYPES_H */

0 comments on commit 55a1dde

Please sign in to comment.