Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#build
*.o
build
9 changes: 0 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ add_library(frame STATIC ${SRC} ${HEADER})
target_include_directories(frame PRIVATE .)
target_link_libraries(frame PRIVATE Threads::Threads)
target_link_libraries(frame PRIVATE blc)
target_link_libraries(frame PRIVATE RSA)
target_link_libraries(frame PRIVATE LTC)
target_link_libraries(frame PRIVATE LTM)
target_include_directories(frame PRIVATE .)
target_include_directories(frame PRIVATE ./dep/rsa/libtomcrypt/src/headers/.)
target_include_directories(frame PRIVATE ./dep/rsa/libtommath)

add_subdirectory(dev/)
add_subdirectory(dep/)
Expand All @@ -60,9 +54,6 @@ target_link_libraries(bkcnode PRIVATE devobj)
target_link_libraries(bkcnode PRIVATE RSA)
target_link_libraries(bkcnode PRIVATE LTC)
target_link_libraries(bkcnode PRIVATE LTM)
target_include_directories(bkcnode PRIVATE .)
target_include_directories(bkcnode PRIVATE ./dep/rsa/libtomcrypt/src/headers/.)
target_include_directories(bkcnode PRIVATE ./dep/rsa/libtommath)

target_compile_definitions(bkcnode PRIVATE BFC_MAJOR_VERSION=${BFC_MAJOR_VERSION})
target_compile_definitions(bkcnode PRIVATE BFC_MINOR_VERSION=${BFC_MINOR_VERSION})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ set (HEADER
src/headers/tomcrypt.h
src/headers/tomcrypt_pkcs.h
src/headers/tomcrypt_prng.h
src/hashes/sha2/sha224.c
src/hashes/sha2/sha384.c
)

set (GCC_COVERAGE_COMPILE_FLAGS "-O2 -fno-stack-protector -DNDEBUG -Wall -DLTC_SOURCE -DLTM_DESC -DMP_32BIT")

add_library(LTC STATIC ${SRC} ${HEADER})
target_include_directories(LTC PRIVATE src/headers)
target_include_directories(LTC PRIVATE ../libtommath/.)
target_include_directories(LTC PRIVATE ../../include/.)
target_include_directories(LTC PRIVATE .)

add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#ifdef LTM_DESC

#include <tommath.h>
#include <libtommath/tommath.h>

static const struct {
int mpi_code, ltc_code;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ set (GCC_COVERAGE_COMPILE_FLAGS "-O2 -fno-stack-protector -DNDEBUG -Wall")

add_library(LTM STATIC ${SRC} ${HEADER})
target_include_directories(LTM PRIVATE .)
target_include_directories(LTM PRIVATE ..)

add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dep/rsa/libtommath/tommath.h → dep/libtommath/tommath.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <stdint.h>
#include <limits.h>

#include <tommath_class.h>
#include <libtommath/tommath_class.h>

#ifdef __cplusplus
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,8 @@
#ifdef LTM3
#define LTM_LAST
#endif
#include <tommath_superclass.h>
#include <tommath_class.h>
#include <libtommath/tommath_superclass.h>
#include <libtommath/tommath_class.h>
#else
#define LTM_LAST
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef TOMMATH_PRIV_H_
#define TOMMATH_PRIV_H_

#include <tommath.h>
#include <libtommath/tommath.h>
#include <ctype.h>

#ifndef MIN
Expand Down
8 changes: 1 addition & 7 deletions dep/rsa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ set (HEADER
)

add_library(RSA STATIC ${SRC} ${HEADER})
add_subdirectory(libtommath/)
add_subdirectory(libtomcrypt/)

set_property(TARGET RSA PROPERTY CXX_STANDARD 17)

target_link_libraries(RSA PRIVATE LTM)
target_link_libraries(RSA PRIVATE LTC)

target_include_directories(RSA PRIVATE ./include)
target_include_directories(RSA PRIVATE ./libtomcrypt/src/headers/.)
target_include_directories(RSA PRIVATE ./libtommath)
target_include_directories(RSA PRIVATE ../../include/.)
2 changes: 1 addition & 1 deletion dep/rsa/include/rsaKey.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <tomcrypt.h>
#include <libtomcrypt/tomcrypt.h>
#include <string>
#include <blc/blc.hpp>

Expand Down
5 changes: 1 addition & 4 deletions dev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(dev)

set(BKC_MAJOR_VERSION 1)
set(BKC_MINOR_VERSION 0)
set(BKC_PATCH_VERSION 3)
set(BKC_PATCH_VERSION 5)
set(BKC_VERSION
${BKC_MAJOR_VERSION}.${BKC_MINOR_VERSION}.${BKC_PATCH_VERSION}
)
Expand Down Expand Up @@ -77,9 +77,6 @@ add_library(devobj STATIC ${SRCS} ${HEADER} ${PROTOS})
target_include_directories(devobj PRIVATE ./include)
target_include_directories(devobj PRIVATE ../)
target_include_directories(devobj PRIVATE ../include/.)
target_include_directories(devobj PRIVATE ../dep/rsa/libtomcrypt/src/headers/.)
target_include_directories(devobj PRIVATE ../dep/rsa/libtommath)
target_include_directories(devobj PRIVATE ../dep/rsa/include)

target_link_libraries(devobj PRIVATE Threads::Threads)
target_link_libraries(devobj PRIVATE blc)
Expand Down
2 changes: 1 addition & 1 deletion dev/include/chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include <blc/blc.hpp>
#include <bfc/bfc.hpp>
#include <rsa/rsaKey.hpp>

#include "book.hpp"
#include "trans.hpp"
#include "rsaKey.hpp"

namespace bkc {
class chain : public bfc::actor<chain>, public blc::tools::serializable {
Expand Down
2 changes: 1 addition & 1 deletion dev/include/identity.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "rsaKey.hpp"
#include <rsa/rsaKey.hpp>

namespace bkc {
extern rsaKey myLog;
Expand Down
2 changes: 1 addition & 1 deletion dev/include/trans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <blc/blc.hpp>
#include <ctime>
#include <nlohmann/json.hpp>
#include "rsaKey.hpp"
#include <rsa/rsaKey.hpp>

using json = nlohmann::json;

Expand Down
3 changes: 2 additions & 1 deletion dev/protocols/protocolAdminFromAdmin.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <nlohmann/json.hpp>
#include <rsa/rsaKey.hpp>

#include "adminConnector.hpp"
#include "rsaKey.hpp"
#include "identity.hpp"
#include "chain.hpp"

Expand Down
5 changes: 5 additions & 0 deletions dev/protocols/protocolCinFromCin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ void bkc::node::cinCon::cinProto()
}
return (0);
});
this->_cin.add("help", [=](std::string str){
bfc::cout << "list of command :\n\tquit\n\tpush\n\tprint\n\tsend\n\tcreate\n\tdump\n\treload\n\thelp" << blc::endl;

return (0);
});
}
3 changes: 2 additions & 1 deletion dev/protocols/protocolPeerFromPeer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <nlohmann/json.hpp>
#include <rsa/rsaKey.hpp>

#include "peerConnector.hpp"
#include "servConnector.hpp"
#include "connectedPeer.hpp"
#include "rsaKey.hpp"
#include "chain.hpp"
#include "identity.hpp"
#include "lists.hpp"
Expand Down
5 changes: 4 additions & 1 deletion dev/src/book.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "book.hpp"
#include <iomanip>

bkc::book::book()
{
Expand Down Expand Up @@ -92,7 +93,9 @@ bool bkc::book::consumed(const std::string &sign) const
for (auto it : tmp){
already_spent += it.getAmount();
}
if (already_spent >= proof.getAmount())
// std::cout << "consumed report : " << already_spent << "/" << proof.getAmount() << std::endl;
// std::cout << std::fixed << std::setprecision(20) << "ending with : (" << already_spent << " >= " << proof.getAmount() << ") => " << (std::round(already_spent * 1000) == std::round(proof.getAmount() * 1000)) << std::endl;
if (std::round(already_spent * 1000) >= std::round(proof.getAmount() * 1000))
return (true);
return (false);
}
Expand Down
21 changes: 14 additions & 7 deletions dev/src/chain.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "chain.hpp"
#include "identity.hpp"
#include <iomanip>

bkc::chain::chain(blc::tools::pipe &pipe, std::string name, bkc::rsaKey key, unsigned char admLvl, std::string in, std::string out) : actor(pipe, name), _admKey(key), _admLvl(admLvl), _in(in), _out(out)
{
Expand All @@ -26,8 +27,9 @@ double bkc::chain::getBalance(const std::string &key) const
double balance = 0;

for (auto it : v){
if (this->_book.consumed(it.getSign()) == false)
if (this->_book.consumed(it.getSign()) == false){
balance += it.getAmount();
}
}
return (balance);
}
Expand Down Expand Up @@ -71,8 +73,8 @@ bkc::trans bkc::chain::getLeftOver(const bkc::trans &t) const
to_spend += it.getAmount();
}
tmp = to_spend - t.getAmount();
parity = bkc::trans::createTrans(t.getSender(), t.getSender(), round(tmp * 1000.0) / 1000.0, bkc::myLog);
parity.setProof(t.getProof());
parity = bkc::trans::createTrans(t.getSender(), t.getSender(), std::round(tmp * 1000.0) / 1000.0, bkc::myLog);
parity.setProof(t.getProof());
return (parity);
}

Expand All @@ -84,10 +86,10 @@ bkc::trans bkc::chain::consum(const std::string &sign)
double to_spend = 0;

for (auto it : tmp){
already_spent += it.getAmount();
already_spent += round(it.getAmount()) * 1000;
}
for (auto it : proofs){
to_spend += it.getAmount();
to_spend += round(it.getAmount()) * 1000;
}
bkc::trans t = bkc::trans::createTrans(proofs[0].getSender(), proofs[0].getSender(), to_spend - already_spent, bkc::myLog);
t.setProof(sign);
Expand Down Expand Up @@ -119,11 +121,15 @@ double bkc::chain::leftOver(const bkc::trans &t, const bkc::trans &parity)
{
std::vector<bkc::trans> proofs = this->_book.getAllProof(t.getProof());
double amount = 0;
double tmpTrans = round(t.getAmount() * 1000.0);
double tmpParit = round(parity.getAmount() * 1000.0);

std::cout << std::fixed << std::setprecision(20) << "trans : " << tmpTrans << std::endl;
std::cout << std::fixed << std::setprecision(20) << "parity : " << tmpParit << std::endl;
for (auto it : proofs){
amount += it.getAmount();
amount += it.getAmount() * 1000;
}
return (amount - (t.getAmount() + parity.getAmount()));
return (amount - (tmpTrans + tmpParit));
}

void bkc::chain::add(const bkc::trans &t)
Expand Down Expand Up @@ -174,4 +180,5 @@ void bkc::chain::thick()
this->dump();
i = 0;
}
i++;
}
3 changes: 2 additions & 1 deletion dev/src/confFile.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <blc/blc.hpp>
#include <nlohmann/json.hpp>
#include <bfc/bfc.hpp>
#include <rsa/rsaKey.hpp>

#include "adminConnector.hpp"
#include "cinConnector.hpp"
#include "peerServer.hpp"
Expand All @@ -12,7 +14,6 @@

#include "trans.hpp"
#include "chain.hpp"
#include "rsaKey.hpp"
#include "lists.hpp"

#include <stdio.h>
Expand Down
3 changes: 2 additions & 1 deletion dev/src/handleKeyParam.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include <blc/blc.hpp>
#include <nlohmann/json.hpp>
#include <bfc/bfc.hpp>
#include <rsa/rsaKey.hpp>

#include "adminConnector.hpp"
#include "cinConnector.hpp"
#include "peerServer.hpp"
#include "identity.hpp"

#include "rsaKey.hpp"

#include <stdio.h>
#include <ios>
Expand Down
3 changes: 2 additions & 1 deletion dev/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <blc/blc.hpp>
#include <nlohmann/json.hpp>
#include <bfc/bfc.hpp>
#include <rsa/rsaKey.hpp>

#include "adminConnector.hpp"
#include "cinConnector.hpp"
#include "peerServer.hpp"
Expand All @@ -10,7 +12,6 @@
#include "confFile.hpp"
#include "initChain.hpp"

#include "rsaKey.hpp"
#include "getMyIp.hpp"

#include "lists.hpp"
Expand Down
Loading