From da133cd3849529e64e564ff18422f6b52516738c Mon Sep 17 00:00:00 2001 From: clintar Date: Wed, 11 Nov 2015 19:24:47 -0700 Subject: [PATCH 01/21] updates for Nan 2.x --- package.json | 38 ++++++++++---------- src/main.cc | 97 +++++++++++++++++++++++++++++----------------------- 2 files changed, 73 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index 697206d6..bef4d713 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,21 @@ { - "name": "cryptonote-util", - "version": "0.0.1", - "main": "cryptonote", - "author": { - "name": "LucasJones", - "email": "lucasjonesdev@hotmail.co.uk" - }, - "repository": { - "type": "git", - "url": "https://github.com/LucasJones/node-cryptonote-util.git" - }, - "dependencies" : { - "bindings" : "*", - "nan" : "1" - }, - "keywords": [ - "cryptonight", - "cryptonote" - ] + "name": "cryptonote-util", + "version": "0.0.1", + "main": "cryptonote", + "author": { + "name": "LucasJones", + "email": "lucasjonesdev@hotmail.co.uk" + }, + "repository": { + "type": "git", + "url": "https://github.com/clintar/node-cryptonote-util.git" + }, + "dependencies": { + "bindings": "*", + "nan": "^2.0.0" + }, + "keywords": [ + "cryptonight", + "cryptonote" + ] } diff --git a/src/main.cc b/src/main.cc index 13bd3452..c58a1eac 100644 --- a/src/main.cc +++ b/src/main.cc @@ -14,9 +14,12 @@ #include "serialization/binary_utils.h" #include -#define THROW_ERROR_EXCEPTION(x) NanThrowError(x) -#define THROW_ERROR_EXCEPTION_WITH_STATUS_CODE(x, y) NanThrowError(x, y) - +#define THROW_ERROR_EXCEPTION(x) Nan::ThrowError(x) + +void callback(char* data, void* hint) { + free(data); +} + using namespace node; using namespace v8; using namespace cryptonote; @@ -78,12 +81,11 @@ static bool construct_parent_block(const cryptonote::block& b, cryptonote::block } NAN_METHOD(convert_blob) { - NanScope(); - if (args.Length() < 1) + if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = args[0]->ToObject(); + Local target = info[0]->ToObject(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -107,19 +109,24 @@ NAN_METHOD(convert_blob) { if (!get_block_hashing_blob(parent_block, output)) return THROW_ERROR_EXCEPTION("Failed to create mining block"); } - - NanReturnValue( - NanNewBufferHandle(output.data(), output.size()) +// Local v8::Local returnValue = Nan::NewBuffer(output.length()).ToLocalChecked(); +// memcpy(Buffer::Data(returnValue), output.c_str(), output.length()); +// info.GetReturnValue().Set( +// returnValue +// ); + + v8::Local returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked(); + info.GetReturnValue().Set( + returnValue ); } -NAN_METHOD(get_block_id) { - NanScope(); +void get_block_id(const Nan::FunctionCallbackInfo& info) { - if (args.Length() < 1) + if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = args[0]->ToObject(); + Local target = info[0]->ToObject(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -134,20 +141,20 @@ NAN_METHOD(get_block_id) { crypto::hash block_id; if (!get_block_hash(b, block_id)) return THROW_ERROR_EXCEPTION("Failed to calculate hash for block"); - - NanReturnValue( - NanNewBufferHandle(reinterpret_cast(&block_id), sizeof(block_id)) + + char *cstr = reinterpret_cast(&block_id); + info.GetReturnValue().Set( + Nan::NewBuffer(cstr, 32, callback,0).ToLocalChecked() ); } -NAN_METHOD(construct_block_blob) { - NanScope(); +void construct_block_blob(const Nan::FunctionCallbackInfo& info) { - if (args.Length() < 2) + if (info.Length() < 2) return THROW_ERROR_EXCEPTION("You must provide two arguments."); - Local block_template_buf = args[0]->ToObject(); - Local nonce_buf = args[1]->ToObject(); + Local block_template_buf = info[0]->ToObject(); + Local nonce_buf = info[1]->ToObject(); if (!Buffer::HasInstance(block_template_buf) || !Buffer::HasInstance(nonce_buf)) return THROW_ERROR_EXCEPTION("Both arguments should be buffer objects."); @@ -178,18 +185,18 @@ NAN_METHOD(construct_block_blob) { if (!block_to_blob(b, output)) return THROW_ERROR_EXCEPTION("Failed to convert block to blob"); - NanReturnValue( - NanNewBufferHandle(output.data(), output.size()) + v8::Local returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked(); + info.GetReturnValue().Set( + returnValue ); } -NAN_METHOD(convert_blob_bb) { - NanScope(); +void convert_blob_bb(const Nan::FunctionCallbackInfo& info) { - if (args.Length() < 1) + if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = args[0]->ToObject(); + Local target = info[0]->ToObject(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -204,18 +211,18 @@ NAN_METHOD(convert_blob_bb) { } output = get_block_hashing_blob(b); - NanReturnValue( - NanNewBufferHandle(output.data(), output.size()) + v8::Local returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked(); + info.GetReturnValue().Set( + returnValue ); } -NAN_METHOD(address_decode) { - NanEscapableScope(); +void address_decode(const Nan::FunctionCallbackInfo& info) { - if (args.Length() < 1) + if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = args[0]->ToObject(); + Local target = info[0]->ToObject(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -225,24 +232,28 @@ NAN_METHOD(address_decode) { blobdata data; uint64_t prefix; if (!tools::base58::decode_addr(input, prefix, data)) - NanReturnUndefined(); + { + info.GetReturnValue().Set(Nan::Undefined()); + } + // info.GetReturnValue().Set(Nan::Undefined()); + account_public_address adr; if (!::serialization::parse_binary(data, adr)) - NanReturnUndefined(); + info.GetReturnValue().Set(Nan::Undefined()); if (!crypto::check_key(adr.m_spend_public_key) || !crypto::check_key(adr.m_view_public_key)) - NanReturnUndefined(); + info.GetReturnValue().Set(Nan::Undefined()); - NanReturnValue(NanNew(static_cast(prefix))); + info.GetReturnValue().Set(Nan::New(static_cast(prefix))); } -void init(Handle exports) { - exports->Set(NanNew("construct_block_blob"), NanNew(construct_block_blob)->GetFunction()); - exports->Set(NanNew("get_block_id"), NanNew(get_block_id)->GetFunction()); - exports->Set(NanNew("convert_blob"), NanNew(convert_blob)->GetFunction()); - exports->Set(NanNew("convert_blob_bb"), NanNew(convert_blob_bb)->GetFunction()); - exports->Set(NanNew("address_decode"), NanNew(address_decode)->GetFunction()); +NAN_MODULE_INIT(init) { + Nan::Set(target, Nan::New("construct_block_blob").ToLocalChecked(), Nan::GetFunction(Nan::New(construct_block_blob)).ToLocalChecked()); + Nan::Set(target, Nan::New("get_block_id").ToLocalChecked(), Nan::GetFunction(Nan::New(get_block_id)).ToLocalChecked()); + Nan::Set(target, Nan::New("convert_blob").ToLocalChecked(), Nan::GetFunction(Nan::New(convert_blob)).ToLocalChecked()); + Nan::Set(target, Nan::New("convert_blob_bb").ToLocalChecked(), Nan::GetFunction(Nan::New(convert_blob_bb)).ToLocalChecked()); + Nan::Set(target, Nan::New("address_decode").ToLocalChecked(), Nan::GetFunction(Nan::New(address_decode)).ToLocalChecked()); } NODE_MODULE(cryptonote, init) From 0ac11dca8b77dcc377bbdafd454d5927bc59a4fd Mon Sep 17 00:00:00 2001 From: clintar Date: Thu, 12 Nov 2015 13:42:40 -0700 Subject: [PATCH 02/21] use copybuffer --- src/main.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index c58a1eac..b9e4af1c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -143,8 +143,9 @@ void get_block_id(const Nan::FunctionCallbackInfo& info) { return THROW_ERROR_EXCEPTION("Failed to calculate hash for block"); char *cstr = reinterpret_cast(&block_id); + v8::Local returnValue = Nan::CopyBuffer(cstr, 32).ToLocalChecked(); info.GetReturnValue().Set( - Nan::NewBuffer(cstr, 32, callback,0).ToLocalChecked() + returnValue ); } From 54f5563ebb250013249ace0d0c97f2b389cbb882 Mon Sep 17 00:00:00 2001 From: clintar Date: Tue, 17 Nov 2015 23:26:36 -0700 Subject: [PATCH 03/21] make compatible with standard node-cryptonote-pool --- src/main.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main.cc b/src/main.cc index b9e4af1c..2d1b0c44 100644 --- a/src/main.cc +++ b/src/main.cc @@ -240,13 +240,26 @@ void address_decode(const Nan::FunctionCallbackInfo& info) { account_public_address adr; - if (!::serialization::parse_binary(data, adr)) - info.GetReturnValue().Set(Nan::Undefined()); - - if (!crypto::check_key(adr.m_spend_public_key) || !crypto::check_key(adr.m_view_public_key)) - info.GetReturnValue().Set(Nan::Undefined()); + if (!::serialization::parse_binary(data, adr) || !crypto::check_key(adr.m_spend_public_key) || !crypto::check_key(adr.m_view_public_key)) + { + if(data.length()) + { + data = uint64be_to_blob(prefix) + data; + } + else + { + info.GetReturnValue().Set(Nan::Undefined()); + } + v8::Local returnValue = Nan::CopyBuffer((char*)data.data(), data.size()).ToLocalChecked(); + info.GetReturnValue().Set( + returnValue + ); - info.GetReturnValue().Set(Nan::New(static_cast(prefix))); + } + else + { + info.GetReturnValue().Set(Nan::New(static_cast(prefix))); + } } NAN_MODULE_INIT(init) { From 81f2e15516e3704d388c8ed327d6a7129256493f Mon Sep 17 00:00:00 2001 From: clintar Date: Wed, 23 Mar 2016 16:49:58 -0600 Subject: [PATCH 04/21] since BLOCK_MAJOR_VERSION_2 is the same after xmr hardfork, create a different function for fantomcoin for now. --- src/main.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main.cc b/src/main.cc index 2d1b0c44..bdd1401c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -93,6 +93,33 @@ NAN_METHOD(convert_blob) { blobdata input = std::string(Buffer::Data(target), Buffer::Length(target)); blobdata output = ""; + //convert + block b = AUTO_VAL_INIT(b); + if (!parse_and_validate_block_from_blob(input, b)) + return THROW_ERROR_EXCEPTION("Failed to parse block"); + + if (!get_block_hashing_blob(b, output)) + return THROW_ERROR_EXCEPTION("Failed to create mining block"); + + v8::Local returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked(); + info.GetReturnValue().Set( + returnValue + ); +} + +NAN_METHOD(convert_blob_fa) { + + if (info.Length() < 1) + return THROW_ERROR_EXCEPTION("You must provide one argument."); + + Local target = info[0]->ToObject(); + + 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 output = ""; + //convert block b = AUTO_VAL_INIT(b); if (!parse_and_validate_block_from_blob(input, b)) From 0a259628adf3fe9ed169fef28424cf8b8a92b88c Mon Sep 17 00:00:00 2001 From: clintar Date: Thu, 24 Mar 2016 02:54:11 -0600 Subject: [PATCH 05/21] another fix since xmr hardfork version increased --- src/main.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main.cc b/src/main.cc index bdd1401c..617f01d8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -195,6 +195,38 @@ void construct_block_blob(const Nan::FunctionCallbackInfo& info) { blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf)); blobdata output = ""; + block b = AUTO_VAL_INIT(b); + if (!parse_and_validate_block_from_blob(block_template_blob, b)) + return THROW_ERROR_EXCEPTION("Failed to parse block"); + + if (!block_to_blob(b, output)) + return THROW_ERROR_EXCEPTION("Failed to convert block to blob"); + + v8::Local returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked(); + info.GetReturnValue().Set( + returnValue + ); +} + +void construct_block_blob_fa(const Nan::FunctionCallbackInfo& info) { + + if (info.Length() < 2) + return THROW_ERROR_EXCEPTION("You must provide two arguments."); + + Local block_template_buf = info[0]->ToObject(); + Local nonce_buf = info[1]->ToObject(); + + if (!Buffer::HasInstance(block_template_buf) || !Buffer::HasInstance(nonce_buf)) + return THROW_ERROR_EXCEPTION("Both arguments should be buffer objects."); + + if (Buffer::Length(nonce_buf) != 4) + return THROW_ERROR_EXCEPTION("Nonce buffer has invalid size."); + + uint32_t nonce = *reinterpret_cast(Buffer::Data(nonce_buf)); + + blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf)); + blobdata output = ""; + block b = AUTO_VAL_INIT(b); if (!parse_and_validate_block_from_blob(block_template_blob, b)) return THROW_ERROR_EXCEPTION("Failed to parse block"); From 15d682bfb64a7c769d2c0a3f41361956afb055fe Mon Sep 17 00:00:00 2001 From: clintar Date: Thu, 24 Mar 2016 03:18:20 -0600 Subject: [PATCH 06/21] more fixes since xmr hardfork version increased --- src/cryptonote_core/cryptonote_basic.h | 10 ++++----- .../cryptonote_format_utils.cpp | 22 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index d59e37b7..a681a4c6 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -479,11 +479,11 @@ namespace cryptonote BEGIN_SERIALIZE_OBJECT() FIELDS(*static_cast(this)) - if (BLOCK_MAJOR_VERSION_2 <= major_version) - { - auto sbb = make_serializable_bytecoin_block(*this, false, false); - FIELD_N("parent_block", sbb); - } +// if (BLOCK_MAJOR_VERSION_2 <= major_version) +// { +// auto sbb = make_serializable_bytecoin_block(*this, false, false); +// FIELD_N("parent_block", sbb); +// } FIELD(miner_tx) FIELD(tx_hashes) END_SERIALIZE() diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 7d8562b3..739b3b64 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -650,15 +650,15 @@ 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; +// 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); - } +// blob.append(parent_blob); +// } return get_object_hash(blob, res); } @@ -851,8 +851,8 @@ 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; +// 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); @@ -899,7 +899,7 @@ namespace cryptonote 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_v2(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); From 3e9fd69c9c4373eb04cf649de253f0a307e9fd8b Mon Sep 17 00:00:00 2001 From: clintar Date: Thu, 24 Mar 2016 03:33:39 -0600 Subject: [PATCH 07/21] more fixes --- src/cryptonote_core/cryptonote_basic.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index a681a4c6..f9e6727f 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -458,15 +458,9 @@ namespace cryptonote VARINT_FIELD(major_version) if(major_version > BLOCK_MAJOR_VERSION_2) return false; VARINT_FIELD(minor_version) - if (BLOCK_MAJOR_VERSION_1 == major_version) - { - VARINT_FIELD(timestamp) - } + VARINT_FIELD(timestamp) FIELD(prev_id) - if (BLOCK_MAJOR_VERSION_1 == major_version) - { - FIELD(nonce) - } + FIELD(nonce) END_SERIALIZE() }; From 8d74079e59552a00cd287fa854c79c751421634c Mon Sep 17 00:00:00 2001 From: clintar Date: Thu, 24 Mar 2016 03:48:41 -0600 Subject: [PATCH 08/21] accidentally removed nonce. need nonce --- src/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 617f01d8..cf575a15 100644 --- a/src/main.cc +++ b/src/main.cc @@ -198,7 +198,7 @@ void construct_block_blob(const Nan::FunctionCallbackInfo& info) { block b = AUTO_VAL_INIT(b); if (!parse_and_validate_block_from_blob(block_template_blob, b)) return THROW_ERROR_EXCEPTION("Failed to parse block"); - + b.nonce = nonce; if (!block_to_blob(b, output)) return THROW_ERROR_EXCEPTION("Failed to convert block to blob"); From 06862b9954a749f9214ced571e70d42a0d1ce398 Mon Sep 17 00:00:00 2001 From: clintar Date: Thu, 22 Sep 2016 10:32:40 -0600 Subject: [PATCH 09/21] fix for monero fork --- src/cryptonote_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index f516b24a..42153892 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -6,7 +6,7 @@ #define CURRENT_BLOCK_MINOR_VERSION 0 #define BLOCK_MAJOR_VERSION_1 1 -#define BLOCK_MAJOR_VERSION_2 2 +#define BLOCK_MAJOR_VERSION_2 3 #define COIN ((uint64_t)100000000) // pow(10, 8) #define DEFAULT_FEE ((uint64_t)1000000) // pow(10, 6) From bd693d478a9a661d9120b14e62beabf641389315 Mon Sep 17 00:00:00 2001 From: clintar Date: Thu, 22 Sep 2016 13:58:54 -0600 Subject: [PATCH 10/21] get rid of old fantomcoin cruft --- src/cryptonote_core/cryptonote_basic.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index f9e6727f..555fb937 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -456,7 +456,6 @@ namespace cryptonote BEGIN_SERIALIZE() VARINT_FIELD(major_version) - if(major_version > BLOCK_MAJOR_VERSION_2) return false; VARINT_FIELD(minor_version) VARINT_FIELD(timestamp) FIELD(prev_id) @@ -473,11 +472,6 @@ namespace cryptonote BEGIN_SERIALIZE_OBJECT() FIELDS(*static_cast(this)) -// if (BLOCK_MAJOR_VERSION_2 <= major_version) -// { -// auto sbb = make_serializable_bytecoin_block(*this, false, false); -// FIELD_N("parent_block", sbb); -// } FIELD(miner_tx) FIELD(tx_hashes) END_SERIALIZE() From 902571957dd507320808a8b0e6bf38ed9265f5bd Mon Sep 17 00:00:00 2001 From: clintar Date: Tue, 4 Oct 2016 12:39:49 -0600 Subject: [PATCH 11/21] implement block differences after ringct, attempt 1 --- src/cryptonote_config.h | 2 +- src/cryptonote_core/cryptonote_basic.h | 69 ++-- src/ringct/rctTypes.h | 492 +++++++++++++++++++++++++ 3 files changed, 540 insertions(+), 23 deletions(-) create mode 100644 src/ringct/rctTypes.h diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 42153892..31cb0322 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -1,7 +1,7 @@ #pragma once #define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0 -#define CURRENT_TRANSACTION_VERSION 1 +#define CURRENT_TRANSACTION_VERSION 2 #define CURRENT_BLOCK_MAJOR_VERSION 1 #define CURRENT_BLOCK_MINOR_VERSION 0 diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index 555fb937..20d333dc 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -24,6 +24,7 @@ #include "crypto/hash.h" #include "misc_language.h" #include "tx_extra.h" +#include "ringct/rctTypes.h" namespace cryptonote @@ -189,6 +190,7 @@ namespace cryptonote { public: std::vector > signatures; //count signatures always the same as inputs count + rct::rctSig rct_signatures; transaction(); virtual ~transaction(); @@ -197,34 +199,57 @@ namespace cryptonote BEGIN_SERIALIZE_OBJECT() FIELDS(*static_cast(this)) - ar.tag("signatures"); - ar.begin_array(); - PREPARE_CUSTOM_VECTOR_SERIALIZATION(vin.size(), signatures); - bool signatures_not_expected = signatures.empty(); - if (!signatures_not_expected && vin.size() != signatures.size()) - return false; - - for (size_t i = 0; i < vin.size(); ++i) + if (version == 1) { - size_t signature_size = get_signature_size(vin[i]); - if (signatures_not_expected) + ar.tag("signatures"); + ar.begin_array(); + PREPARE_CUSTOM_VECTOR_SERIALIZATION(vin.size(), signatures); + bool signatures_not_expected = signatures.empty(); + if (!signatures_not_expected && vin.size() != signatures.size()) + return false; + + for (size_t i = 0; i < vin.size(); ++i) { - if (0 == signature_size) - continue; - else + size_t signature_size = get_signature_size(vin[i]); + if (signatures_not_expected) + { + if (0 == signature_size) + continue; + else + return false; + } + + PREPARE_CUSTOM_VECTOR_SERIALIZATION(signature_size, signatures[i]); + if (signature_size != signatures[i].size()) return false; - } - - PREPARE_CUSTOM_VECTOR_SERIALIZATION(signature_size, signatures[i]); - if (signature_size != signatures[i].size()) - return false; - FIELDS(signatures[i]); + FIELDS(signatures[i]); - if (vin.size() - i > 1) - ar.delimit_array(); + if (vin.size() - i > 1) + ar.delimit_array(); + } + ar.end_array(); + } + else + { + ar.tag("rct_signatures"); + if (!vin.empty()) + { + ar.begin_object(); + bool r = rct_signatures.serialize_rctsig_base(ar, vin.size(), vout.size()); + if (!r || !ar.stream().good()) return false; + ar.end_object(); + if (rct_signatures.type != rct::RCTTypeNull) + { + ar.tag("rctsig_prunable"); + ar.begin_object(); + r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin.size(), vout.size(), + vin[0].type() == typeid(txin_to_key) ? boost::get(vin[0]).key_offsets.size() - 1 : 0); + if (!r || !ar.stream().good()) return false; + ar.end_object(); + } + } } - ar.end_array(); END_SERIALIZE() private: diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h new file mode 100644 index 00000000..bfafebb8 --- /dev/null +++ b/src/ringct/rctTypes.h @@ -0,0 +1,492 @@ +// Copyright (c) 2016, Monero Research Labs +// +// Author: Shen Noether +// +// 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. + +#pragma once +#ifndef RCT_TYPES_H +#define RCT_TYPES_H + +#include +#include +#include +#include +#include +#include + +extern "C" { +#include "crypto/generic-ops.h" +#include "crypto/crypto-ops.h" +#include "crypto/random.h" +#include "crypto/keccak.h" +} +#include "crypto/crypto.h" + +#include "serialization/serialization.h" +#include "serialization/debug_archive.h" +#include "serialization/binary_archive.h" +#include "serialization/json_archive.h" + + +//Define this flag when debugging to get additional info on the console +#ifdef DBG +#define DP(x) dp(x) +#else +#define DP(x) +#endif + +//atomic units of moneros +#define ATOMS 64 + +//for printing large ints + +using namespace std; +using namespace crypto; + +//Namespace specifically for ring ct code +namespace rct { + //basic ops containers + typedef unsigned char * Bytes; + + // Can contain a secret or public key + // similar to secret_key / public_key of crypto-ops, + // but uses unsigned chars, + // also includes an operator for accessing the i'th byte. + struct key { + unsigned char & operator[](int i) { + return bytes[i]; + } + unsigned char operator[](int i) const { + return bytes[i]; + } + bool operator==(const key &k) const { return !memcmp(bytes, k.bytes, sizeof(bytes)); } + unsigned char bytes[32]; + }; + typedef vector keyV; //vector of keys + typedef vector keyM; //matrix of keys (indexed by column first) + + //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 + // (store b, the amount, separately + //if it's representing a public ctkey, then "dest" = P the address, mask = C the commitment + struct ctkey { + key dest; + key mask; //C here if public + }; + typedef vector ctkeyV; + typedef vector ctkeyM; + + //data for passing the amount to the receiver secretly + // If the pedersen commitment to an amount is C = aG + bH, + // "mask" contains a 32 byte key a + // "amount" contains a hex representation (in 32 bytes) of a 64 bit number + // "senderPk" is not the senders actual public key, but a one-time public key generated for + // the purpose of the ECDH exchange + struct ecdhTuple { + key mask; + key amount; + key senderPk; + + BEGIN_SERIALIZE_OBJECT() + FIELD(mask) + FIELD(amount) + // FIELD(senderPk) // not serialized, as we do not use it in monero currently + END_SERIALIZE() + }; + + //containers for representing amounts + typedef uint64_t xmr_amount; + 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; + }; + + //Container for precomp + struct geDsmp { + ge_dsmp k; + }; + + //just contains the necessary keys to represent MLSAG sigs + //c.f. http://eprint.iacr.org/2015/1098 + struct mgSig { + keyM ss; + key cc; + keyV II; + + BEGIN_SERIALIZE_OBJECT() + FIELD(ss) + FIELD(cc) + // FIELD(II) - not serialized, it can be reconstructed + END_SERIALIZE() + }; + //contains the data for an asnl 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; + key64 Ci; + + BEGIN_SERIALIZE_OBJECT() + FIELD(asig) + FIELD(Ci) + END_SERIALIZE() + }; + //A container to hold all signatures necessary for RingCT + // rangeSigs holds all the rangeproof data of a transaction + // MG holds the MLSAG signature of a transaction + // mixRing holds all the public keypairs (P, C) for a transaction + // ecdhInfo holds an encoded mask / amount to be passed to each receiver + // outPk contains public keypairs which are destinations (P, C), + // P = address, C = commitment to amount + enum { + RCTTypeNull = 0, + RCTTypeFull = 1, + RCTTypeSimple = 2, + }; + struct rctSigBase { + uint8_t type; + key message; + ctkeyM mixRing; //the set of all pubkeys / copy + //pairs that you mix with + keyV pseudoOuts; //C - for simple rct + vector ecdhInfo; + ctkeyV outPk; + xmr_amount txnFee; // contains b + + template class Archive> + bool serialize_rctsig_base(Archive &ar, size_t inputs, size_t outputs) + { + FIELD(type) + if (type == RCTTypeNull) + return true; + if (type != RCTTypeFull && type != RCTTypeSimple) + return false; + VARINT_FIELD(txnFee) + // 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) + { + 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) + { + 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 (outputs - i > 1) + ar.delimit_array(); + } + ar.end_array(); + return true; + } + }; + struct rctSigPrunable { + vector rangeSigs; + vector MGs; // simple rct has N, full has 1 + + template class Archive> + bool serialize_rctsig_prunable(Archive &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin) + { + if (type == RCTTypeNull) + return true; + if (type != RCTTypeFull && type != RCTTypeSimple) + return false; + ar.tag("rangeSigs"); + ar.begin_array(); + PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, rangeSigs); + if (rangeSigs.size() != outputs) + return false; + for (size_t i = 0; i < outputs; ++i) + { + FIELDS(rangeSigs[i]) + if (outputs - i > 1) + ar.delimit_array(); + } + ar.end_array(); + + ar.tag("MGs"); + ar.begin_array(); + // we keep a byte for size of MGs, because we don't know whether this is + // a simple or full rct signature, and it's starting to annoy the hell out of me + size_t mg_elements = type == RCTTypeSimple ? inputs : 1; + PREPARE_CUSTOM_VECTOR_SERIALIZATION(mg_elements, MGs); + if (MGs.size() != mg_elements) + return false; + for (size_t i = 0; i < mg_elements; ++i) + { + // 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.tag("ss"); + ar.begin_array(); + PREPARE_CUSTOM_VECTOR_SERIALIZATION(mixin + 1, MGs[i].ss); + if (MGs[i].ss.size() != mixin + 1) + return false; + for (size_t j = 0; j < mixin + 1; ++j) + { + ar.begin_array(); + size_t mg_ss2_elements = (type == RCTTypeSimple ? 1 : inputs) + 1; + PREPARE_CUSTOM_VECTOR_SERIALIZATION(mg_ss2_elements, MGs[i].ss[j]); + if (MGs[i].ss[j].size() != mg_ss2_elements) + return false; + for (size_t k = 0; k < mg_ss2_elements; ++k) + { + FIELDS(MGs[i].ss[j][k]) + if (mg_ss2_elements - j > 1) + ar.delimit_array(); + } + ar.end_array(); + + if (mixin + 1 - j > 1) + ar.delimit_array(); + } + ar.end_array(); + + FIELDS(MGs[i].cc) + // MGs[i].II not saved, it can be reconstructed + if (mg_elements - i > 1) + ar.delimit_array(); + } + ar.end_array(); + return true; + } + + }; + struct rctSig: public rctSigBase { + rctSigPrunable p; + }; + + //other basepoint H = toPoint(cn_fast_hash(G)), G the basepoint + static const key H = { {0x8b, 0x65, 0x59, 0x70, 0x15, 0x37, 0x99, 0xaf, 0x2a, 0xea, 0xdc, 0x9f, 0xf1, 0xad, 0xd0, 0xea, 0x6c, 0x72, 0x51, 0xd5, 0x41, 0x54, 0xcf, 0xa9, 0x2c, 0x17, 0x3a, 0x0d, 0xd3, 0x9c, 0x1f, 0x94} }; + + //H2 contains 2^i H in each index, i.e. H, 2H, 4H, 8H, ... + //This is used for the range proofG + //You can regenerate this by running python2 Test.py HPow2 in the MiniNero repo + static const key64 H2 = {{0x8b, 0x65, 0x59, 0x70, 0x15, 0x37, 0x99, 0xaf, 0x2a, 0xea, 0xdc, 0x9f, 0xf1, 0xad, 0xd0, 0xea, 0x6c, 0x72, 0x51, 0xd5, 0x41, 0x54, 0xcf, 0xa9, 0x2c, 0x17, 0x3a, 0x0d, 0xd3, 0x9c, 0x1f, 0x94}, + {0x8f, 0xaa, 0x44, 0x8a, 0xe4, 0xb3, 0xe2, 0xbb, 0x3d, 0x4d, 0x13, 0x09, 0x09, 0xf5, 0x5f, 0xcd, 0x79, 0x71, 0x1c, 0x1c, 0x83, 0xcd, 0xbc, 0xca, 0xdd, 0x42, 0xcb, 0xe1, 0x51, 0x5e, 0x87, 0x12}, + {0x12, 0xa7, 0xd6, 0x2c, 0x77, 0x91, 0x65, 0x4a, 0x57, 0xf3, 0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b9, 0x7d, 0x22, 0xfe, 0xad, 0xbc, 0x6c, 0x0d, 0x89, 0x30, 0xc5, 0xf8, 0xfc, 0x50, 0x8b, 0x2f, 0xc5, 0xb3, 0x53, 0x28, 0xd2, 0x6b, 0x88, 0xdb, 0x19, 0xae}, + {0x60, 0xb6, 0x26, 0xa0, 0x33, 0xb5, 0x5f, 0x27, 0xd7, 0x67, 0x6c, 0x40, 0x95, 0xea, 0xba, 0xbc, 0x7a, 0x2c, 0x7e, 0xde, 0x26, 0x24, 0xb4, 0x72, 0xe9, 0x7f, 0x64, 0xf9, 0x6b, 0x8c, 0xfc, 0x0e}, + {0xe5, 0xb5, 0x2b, 0xc9, 0x27, 0x46, 0x8d, 0xf7, 0x18, 0x93, 0xeb, 0x81, 0x97, 0xef, 0x82, 0x0c, 0xf7, 0x6c, 0xb0, 0xaa, 0xf6, 0xe8, 0xe4, 0xfe, 0x93, 0xad, 0x62, 0xd8, 0x03, 0x98, 0x31, 0x04}, + {0x05, 0x65, 0x41, 0xae, 0x5d, 0xa9, 0x96, 0x1b, 0xe2, 0xb0, 0xa5, 0xe8, 0x95, 0xe5, 0xc5, 0xba, 0x15, 0x3c, 0xbb, 0x62, 0xdd, 0x56, 0x1a, 0x42, 0x7b, 0xad, 0x0f, 0xfd, 0x41, 0x92, 0x31, 0x99}, + {0xf8, 0xfe, 0xf0, 0x5a, 0x3f, 0xa5, 0xc9, 0xf3, 0xeb, 0xa4, 0x16, 0x38, 0xb2, 0x47, 0xb7, 0x11, 0xa9, 0x9f, 0x96, 0x0f, 0xe7, 0x3a, 0xa2, 0xf9, 0x01, 0x36, 0xae, 0xb2, 0x03, 0x29, 0xb8, 0x88}}; + + //Debug printing for the above types + //Actually use DP(value) and #define DBG + void dp(key a); + void dp(bool a); + void dp(const char * a, int l); + void dp(keyV a); + void dp(keyM a); + void dp(xmr_amount vali); + void dp(int vali); + void dp(bits amountb); + void dp(const char * st); + + //various conversions + + //uint long long to 32 byte key + void d2h(key & amounth, xmr_amount val); + key d2h(xmr_amount val); + //uint long long to int[64] + void d2b(bits amountb, xmr_amount val); + //32 byte key to uint long long + // if the key holds a value > 2^64 + // 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); + //int[64] to 32 byte key + void b2h(key & amountdh, bits amountb2); + //int[64] to uint long long + xmr_amount b2d(bits amountb); + + static inline const rct::key pk2rct(const crypto::public_key &pk) { return (const rct::key&)pk; } + static inline const rct::key sk2rct(const crypto::secret_key &sk) { return (const rct::key&)sk; } + static inline const rct::key ki2rct(const crypto::key_image &ki) { return (const rct::key&)ki; } + static inline const rct::key hash2rct(const crypto::hash &h) { return (const rct::key&)h; } + static inline const crypto::public_key rct2pk(const rct::key &k) { return (const crypto::public_key&)k; } + static inline const crypto::secret_key rct2sk(const rct::key &k) { return (const crypto::secret_key&)k; } + static inline const crypto::key_image rct2ki(const rct::key &k) { return (const crypto::key_image&)k; } + static inline const crypto::hash rct2hash(const rct::key &k) { return (const crypto::hash&)k; } + static inline bool operator==(const rct::key &k0, const crypto::public_key &k1) { return !memcmp(&k0, &k1, 32); } + static inline bool operator!=(const rct::key &k0, const crypto::public_key &k1) { return memcmp(&k0, &k1, 32); } +} + + +namespace cryptonote { + static inline bool operator==(const crypto::public_key &k0, const rct::key &k1) { return !memcmp(&k0, &k1, 32); } + static inline bool operator!=(const crypto::public_key &k0, const rct::key &k1) { return memcmp(&k0, &k1, 32); } + static inline bool operator==(const crypto::secret_key &k0, const rct::key &k1) { return !memcmp(&k0, &k1, 32); } + static inline bool operator!=(const crypto::secret_key &k0, const rct::key &k1) { return memcmp(&k0, &k1, 32); } +} + +template std::ostream &print256(std::ostream &o, const T &v); +inline std::ostream &operator <<(std::ostream &o, const rct::key &v) { return print256(o, v); } + + +BLOB_SERIALIZER(rct::key); +BLOB_SERIALIZER(rct::key64); +BLOB_SERIALIZER(rct::ctkey); +BLOB_SERIALIZER(rct::asnlSig); + +VARIANT_TAG(debug_archive, rct::key, "rct::key"); +VARIANT_TAG(debug_archive, rct::key64, "rct::key64"); +VARIANT_TAG(debug_archive, rct::keyV, "rct::keyV"); +VARIANT_TAG(debug_archive, rct::keyM, "rct::keyM"); +VARIANT_TAG(debug_archive, rct::ctkey, "rct::ctkey"); +VARIANT_TAG(debug_archive, rct::ctkeyV, "rct::ctkeyV"); +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::rctSig, "rct::rctSig"); + +VARIANT_TAG(binary_archive, rct::key, 0x90); +VARIANT_TAG(binary_archive, rct::key64, 0x91); +VARIANT_TAG(binary_archive, rct::keyV, 0x92); +VARIANT_TAG(binary_archive, rct::keyM, 0x93); +VARIANT_TAG(binary_archive, rct::ctkey, 0x94); +VARIANT_TAG(binary_archive, rct::ctkeyV, 0x95); +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::rctSig, 0x9b); + +VARIANT_TAG(json_archive, rct::key, "rct_key"); +VARIANT_TAG(json_archive, rct::key64, "rct_key64"); +VARIANT_TAG(json_archive, rct::keyV, "rct_keyV"); +VARIANT_TAG(json_archive, rct::keyM, "rct_keyM"); +VARIANT_TAG(json_archive, rct::ctkey, "rct_ctkey"); +VARIANT_TAG(json_archive, rct::ctkeyV, "rct_ctkeyV"); +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::rctSig, "rct_rctSig"); + +#endif /* RCTTYPES_H */ From 54d041c33a42778a1354e50c644db448a1e945c7 Mon Sep 17 00:00:00 2001 From: clintar Date: Mon, 21 Nov 2016 13:56:56 -0700 Subject: [PATCH 12/21] Digitalnote 4.0.0-beta update --- src/cryptonote_config.h | 3 ++- src/cryptonote_core/cryptonote_basic.h | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 31cb0322..3895d327 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -6,7 +6,8 @@ #define CURRENT_BLOCK_MINOR_VERSION 0 #define BLOCK_MAJOR_VERSION_1 1 -#define BLOCK_MAJOR_VERSION_2 3 +#define BLOCK_MAJOR_VERSION_2 2 +#define BLOCK_MAJOR_VERSION_3 3 #define COIN ((uint64_t)100000000) // pow(10, 8) #define DEFAULT_FEE ((uint64_t)1000000) // pow(10, 6) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index 20d333dc..814e32e5 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -470,6 +470,15 @@ namespace cryptonote // Implemented below inline serializable_bytecoin_block make_serializable_bytecoin_block(const block& b, bool hashing_serialization, bool header_only); +struct RootBlock { + uint8_t majorVersion; + uint8_t minorVersion; + crypto::hash previousBlockHash; + uint16_t transactionCount; + std::vector baseTransactionBranch; + transaction baseTransaction; + std::vector blockchainBranch; +}; struct block_header { @@ -478,7 +487,6 @@ namespace cryptonote uint64_t timestamp; crypto::hash prev_id; uint32_t nonce; - BEGIN_SERIALIZE() VARINT_FIELD(major_version) VARINT_FIELD(minor_version) @@ -491,7 +499,7 @@ namespace cryptonote struct block: public block_header { bytecoin_block parent_block; - + RootBlock rootBlock; transaction miner_tx; std::vector tx_hashes; From 31c531b2764e36e243cff1e8998890986c06dea3 Mon Sep 17 00:00:00 2001 From: clintar Date: Mon, 21 Nov 2016 14:52:39 -0700 Subject: [PATCH 13/21] Revert "Digitalnote 4.0.0-beta update" This reverts commit 54d041c33a42778a1354e50c644db448a1e945c7. --- src/cryptonote_config.h | 3 +-- src/cryptonote_core/cryptonote_basic.h | 12 ++---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 3895d327..31cb0322 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -6,8 +6,7 @@ #define CURRENT_BLOCK_MINOR_VERSION 0 #define BLOCK_MAJOR_VERSION_1 1 -#define BLOCK_MAJOR_VERSION_2 2 -#define BLOCK_MAJOR_VERSION_3 3 +#define BLOCK_MAJOR_VERSION_2 3 #define COIN ((uint64_t)100000000) // pow(10, 8) #define DEFAULT_FEE ((uint64_t)1000000) // pow(10, 6) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index 814e32e5..20d333dc 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -470,15 +470,6 @@ namespace cryptonote // Implemented below inline serializable_bytecoin_block make_serializable_bytecoin_block(const block& b, bool hashing_serialization, bool header_only); -struct RootBlock { - uint8_t majorVersion; - uint8_t minorVersion; - crypto::hash previousBlockHash; - uint16_t transactionCount; - std::vector baseTransactionBranch; - transaction baseTransaction; - std::vector blockchainBranch; -}; struct block_header { @@ -487,6 +478,7 @@ struct RootBlock { uint64_t timestamp; crypto::hash prev_id; uint32_t nonce; + BEGIN_SERIALIZE() VARINT_FIELD(major_version) VARINT_FIELD(minor_version) @@ -499,7 +491,7 @@ struct RootBlock { struct block: public block_header { bytecoin_block parent_block; - RootBlock rootBlock; + transaction miner_tx; std::vector tx_hashes; From 7fefaae440ea16334ed8850e37fd97708b8b013e Mon Sep 17 00:00:00 2001 From: Gingeropolous Date: Sun, 11 Dec 2016 20:17:33 -0500 Subject: [PATCH 14/21] deletel line 411 minor major return false --- src/cryptonote_core/cryptonote_basic.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index 20d333dc..2677fe3d 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -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); From 7e9bb84f3193cc7908a1b5026ba69648763e3a32 Mon Sep 17 00:00:00 2001 From: gingeropolous Date: Sun, 11 Dec 2016 20:26:38 -0500 Subject: [PATCH 15/21] delete all major lines --- .../cryptonote_format_utils.cpp | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 739b3b64..b30c20cc 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -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); } //--------------------------------------------------------------- @@ -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); @@ -851,8 +839,6 @@ 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); @@ -860,8 +846,6 @@ namespace cryptonote //--------------------------------------------------------------- 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; @@ -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); } //--------------------------------------------------------------- } From 9d9f18573e01e9c60c82b8be5aa3d94ae6519078 Mon Sep 17 00:00:00 2001 From: gingeropolous Date: Sun, 11 Dec 2016 22:17:14 -0500 Subject: [PATCH 16/21] removed another major comparison --- src/main.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main.cc b/src/main.cc index cf575a15..a8a3d028 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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"); From 48551c3c1fb03807fc33143a4ed96fdff8d998b4 Mon Sep 17 00:00:00 2001 From: gingeropolous Date: Mon, 12 Dec 2016 20:09:47 -0500 Subject: [PATCH 17/21] swapped in new rctTypes.h --- src/ringct/rctTypes.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index bfafebb8..71cc61dd 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -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 @@ -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() @@ -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); @@ -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(); @@ -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; @@ -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 @@ -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"); @@ -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); @@ -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"); @@ -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 */ From 37f50f9b535f0258c3a1c6f7247a891b4c211ff3 Mon Sep 17 00:00:00 2001 From: M5M400 Date: Mon, 19 Dec 2016 18:39:52 +0100 Subject: [PATCH 18/21] Add files via upload --- .../cryptonote_format_utils.cpp | 57 ++++++++++++++++++- src/cryptonote_core/cryptonote_format_utils.h | 1 + 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index b30c20cc..41eac6b4 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -613,10 +613,65 @@ namespace cryptonote return get_object_hash(static_cast(t), res, blob_size); } + //--------------------------------------------------------------- + bool get_transaction_hash(const transaction& t, crypto::hash& res, size_t* blob_size) + { + // v1 transactions hash the entire blob + if (t.version == 1) + { + size_t ignored_blob_size, &blob_size_ref = blob_size ? *blob_size : ignored_blob_size; + return get_object_hash(t, res, blob_size_ref); + } + + // v2 transactions hash different parts together, than hash the set of those hashes + crypto::hash hashes[3]; + + // prefix + get_transaction_prefix_hash(t, hashes[0]); + + transaction &tt = const_cast(t); + + // base rct + { + std::stringstream ss; + binary_archive ba(ss); + const size_t inputs = t.vin.size(); + const size_t outputs = t.vout.size(); + bool r = tt.rct_signatures.serialize_rctsig_base(ba, inputs, outputs); + CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures base"); + cryptonote::get_blob_hash(ss.str(), hashes[1]); + } + + // prunable rct + if (t.rct_signatures.type == rct::RCTTypeNull) + { + hashes[2] = cryptonote::null_hash; + } + else + { + std::stringstream ss; + binary_archive ba(ss); + const size_t inputs = t.vin.size(); + const size_t outputs = t.vout.size(); + const size_t mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_to_key) ? boost::get(t.vin[0]).key_offsets.size() - 1 : 0; + bool r = tt.rct_signatures.p.serialize_rctsig_prunable(ba, t.rct_signatures.type, inputs, outputs, mixin); + CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures prunable"); + cryptonote::get_blob_hash(ss.str(), hashes[2]); + } + + // the tx hash is the hash of the 3 hashes + res = cn_fast_hash(hashes, sizeof(hashes)); + + // we still need the size + if (blob_size) + *blob_size = get_object_blobsize(t); + + return true; + } //--------------------------------------------------------------- bool get_transaction_hash(const transaction& t, crypto::hash& res, size_t& blob_size) { - return get_object_hash(t, res, blob_size); + return get_transaction_hash(t, res, &blob_size); } //--------------------------------------------------------------- bool get_block_hashing_blob(const block& b, blobdata& blob) diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index a91349cf..b9e5dc59 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -77,6 +77,7 @@ namespace cryptonote crypto::hash get_transaction_hash(const transaction& t); bool get_transaction_hash(const transaction& t, crypto::hash& res); bool get_transaction_hash(const transaction& t, crypto::hash& res, size_t& blob_size); + bool get_transaction_hash(const transaction& t, crypto::hash& res, size_t* blob_size); bool get_block_hashing_blob(const block& b, blobdata& blob); bool get_bytecoin_block_hashing_blob(const block& b, blobdata& blob); blobdata get_block_hashing_blob(const bb_block& b); From bceb602ec16bc29f3cc968c35fcfb745a97dfb9f Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sat, 28 Jan 2017 22:47:23 -0800 Subject: [PATCH 19/21] Migrating changes because I'm an idiot who can't target the right branch. --- src/crypto/hash.h | 69 ++++++++++++++------------ src/cryptonote_core/cryptonote_basic.h | 18 ++++++- src/main.cc | 46 +++++++++++++++++ src/serialization/crypto.h | 2 + 4 files changed, 103 insertions(+), 32 deletions(-) diff --git a/src/crypto/hash.h b/src/crypto/hash.h index 90bf3393..7fe96cbb 100644 --- a/src/crypto/hash.h +++ b/src/crypto/hash.h @@ -11,50 +11,57 @@ namespace crypto { - extern "C" { + extern "C" { #include "hash-ops.h" - } + } #pragma pack(push, 1) - POD_CLASS hash { - char data[HASH_SIZE]; - }; + POD_CLASS hash{ + char data[HASH_SIZE]; + }; + POD_CLASS hash8{ + char data[8]; + }; + #pragma pack(pop) - static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size"); + static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size"); + static_assert(sizeof(hash8) == 8, "Invalid structure size"); - /* - Cryptonight hash functions - */ + /* + Cryptonight hash functions + */ - inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) { - cn_fast_hash(data, length, reinterpret_cast(&hash)); - } + inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) { + cn_fast_hash(data, length, reinterpret_cast(&hash)); + } - inline hash cn_fast_hash(const void *data, std::size_t length) { - hash h; - cn_fast_hash(data, length, reinterpret_cast(&h)); - return h; - } + inline hash cn_fast_hash(const void *data, std::size_t length) { + hash h; + cn_fast_hash(data, length, reinterpret_cast(&h)); + return h; + } - inline void cn_slow_hash(const void *data, std::size_t length, hash &hash) { - cn_slow_hash(data, length, reinterpret_cast(&hash)); - } + inline void cn_slow_hash(const void *data, std::size_t length, hash &hash) { + cn_slow_hash(data, length, reinterpret_cast(&hash)); + } - inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) { - tree_hash(reinterpret_cast(hashes), count, reinterpret_cast(&root_hash)); - } + inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) { + tree_hash(reinterpret_cast(hashes), count, reinterpret_cast(&root_hash)); + } - inline void tree_branch(const hash* hashes, std::size_t count, hash* branch) - { - tree_branch(reinterpret_cast(hashes), count, reinterpret_cast(branch)); - } + inline void tree_branch(const hash *hashes, std::size_t count, hash *branch) { + tree_branch(reinterpret_cast(hashes), count, + reinterpret_cast(branch)); + } - inline void tree_hash_from_branch(const hash* branch, std::size_t depth, const hash& leaf, const void* path, hash& root_hash) - { - tree_hash_from_branch(reinterpret_cast(branch), depth, reinterpret_cast(&leaf), path, reinterpret_cast(&root_hash)); - } + inline void + tree_hash_from_branch(const hash *branch, std::size_t depth, const hash &leaf, const void *path, hash &root_hash) { + tree_hash_from_branch(reinterpret_cast(branch), depth, + reinterpret_cast(&leaf), path, reinterpret_cast(&root_hash)); + } } CRYPTO_MAKE_HASHABLE(hash) +CRYPTO_MAKE_COMPARABLE(hash8) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index 2677fe3d..39c12fff 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -559,7 +559,23 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; - struct keypair + struct integrated_address { + account_public_address adr; + crypto::hash8 payment_id; + + BEGIN_SERIALIZE_OBJECT() + FIELD(adr) + FIELD(payment_id) + END_SERIALIZE() + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(adr) + KV_SERIALIZE(payment_id) + END_KV_SERIALIZE_MAP() + }; + + + struct keypair { crypto::public_key pub; crypto::secret_key sec; diff --git a/src/main.cc b/src/main.cc index a8a3d028..38520540 100644 --- a/src/main.cc +++ b/src/main.cc @@ -318,12 +318,58 @@ void address_decode(const Nan::FunctionCallbackInfo& info) { } } +void address_decode_integrated(const Nan::FunctionCallbackInfo& info) { + + if (info.Length() < 1) + return THROW_ERROR_EXCEPTION("You must provide one argument."); + + Local target = info[0]->ToObject(); + + 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; + uint64_t prefix; + if (!tools::base58::decode_addr(input, prefix, data)) + { + info.GetReturnValue().Set(Nan::Undefined()); + } + // info.GetReturnValue().Set(Nan::Undefined()); + + + integrated_address iadr; + if (!::serialization::parse_binary(data, iadr) || !crypto::check_key(iadr.adr.m_spend_public_key) || !crypto::check_key(iadr.adr.m_view_public_key)) + { + if(data.length()) + { + data = uint64be_to_blob(prefix) + data; + } + else + { + info.GetReturnValue().Set(Nan::Undefined()); + } + v8::Local returnValue = Nan::CopyBuffer((char*)data.data(), data.size()).ToLocalChecked(); + info.GetReturnValue().Set( + returnValue + ); + + } + else + { + info.GetReturnValue().Set(Nan::New(static_cast(prefix))); + } +} + + NAN_MODULE_INIT(init) { Nan::Set(target, Nan::New("construct_block_blob").ToLocalChecked(), Nan::GetFunction(Nan::New(construct_block_blob)).ToLocalChecked()); Nan::Set(target, Nan::New("get_block_id").ToLocalChecked(), Nan::GetFunction(Nan::New(get_block_id)).ToLocalChecked()); Nan::Set(target, Nan::New("convert_blob").ToLocalChecked(), Nan::GetFunction(Nan::New(convert_blob)).ToLocalChecked()); Nan::Set(target, Nan::New("convert_blob_bb").ToLocalChecked(), Nan::GetFunction(Nan::New(convert_blob_bb)).ToLocalChecked()); Nan::Set(target, Nan::New("address_decode").ToLocalChecked(), Nan::GetFunction(Nan::New(address_decode)).ToLocalChecked()); + Nan::Set(target, Nan::New("address_decode_integrated").ToLocalChecked(), Nan::GetFunction(Nan::New(address_decode_integrated)).ToLocalChecked()); } NODE_MODULE(cryptonote, init) diff --git a/src/serialization/crypto.h b/src/serialization/crypto.h index 6e683e62..76a3a1d1 100644 --- a/src/serialization/crypto.h +++ b/src/serialization/crypto.h @@ -53,12 +53,14 @@ bool do_serialize(Archive &ar, std::vector &v) BLOB_SERIALIZER(crypto::chacha8_iv); BLOB_SERIALIZER(crypto::hash); +BLOB_SERIALIZER(crypto::hash8); BLOB_SERIALIZER(crypto::public_key); BLOB_SERIALIZER(crypto::secret_key); BLOB_SERIALIZER(crypto::key_derivation); BLOB_SERIALIZER(crypto::key_image); BLOB_SERIALIZER(crypto::signature); VARIANT_TAG(debug_archive, crypto::hash, "hash"); +VARIANT_TAG(debug_archive, crypto::hash8, "hash8"); VARIANT_TAG(debug_archive, crypto::public_key, "public_key"); VARIANT_TAG(debug_archive, crypto::secret_key, "secret_key"); VARIANT_TAG(debug_archive, crypto::key_derivation, "key_derivation"); From f1e3597f5f1447c23f13997e6f8937d5c9a9ca1f Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sat, 28 Jan 2017 22:47:58 -0800 Subject: [PATCH 20/21] Retargeting. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bef4d713..64f14d26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cryptonote-util", - "version": "0.0.1", + "version": "0.0.3", "main": "cryptonote", "author": { "name": "LucasJones", From 7aa89bd430b96981f8e7f5f534a1c679e5c18b34 Mon Sep 17 00:00:00 2001 From: Sergey Kukunin Date: Fri, 3 Mar 2017 09:20:31 +0200 Subject: [PATCH 21/21] Make package compilable on OSX --- binding.gyp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/binding.gyp b/binding.gyp index 1ecc104f..4b753e50 100644 --- a/binding.gyp +++ b/binding.gyp @@ -30,6 +30,9 @@ "-fexceptions", "-frtti", ], + "xcode_settings": { + "OTHER_CFLAGS": ["-fexceptions", "-frtti"] + } } ] }