Skip to content
This repository was archived by the owner on Dec 29, 2018. It is now read-only.

Commit 40b0d1a

Browse files
committed
Merge remote-tracking branch 'bts/master'
2 parents fc07679 + d8437ac commit 40b0d1a

File tree

7 files changed

+19
-280
lines changed

7 files changed

+19
-280
lines changed

CMakeLists.txt

+1-12
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ set( fc_sources
281281
src/network/rate_limiting.cpp
282282
src/network/resolve.cpp
283283
src/network/url.cpp
284-
src/compress/smaz.cpp
285284
src/compress/zlib.cpp
286285
)
287286

@@ -367,15 +366,6 @@ else()
367366
set( ZLIB_LIBRARIES "" )
368367
endif( ZLIB_FOUND )
369368

370-
find_package( BZip2 )
371-
if( BZIP2_FOUND )
372-
MESSAGE( STATUS "bzip2 found" )
373-
add_definitions( -DHAS_BZIP2 )
374-
else()
375-
MESSAGE( STATUS "bzip2 not found" )
376-
set( BZIP2_LIBRARIES "" )
377-
endif( BZIP2_FOUND )
378-
379369
# This will become unnecessary once we update to websocketpp which fixes upstream issue #395
380370
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWEBSOCKETPP_STRICT_MASKING")
381371

@@ -406,11 +396,10 @@ target_include_directories(fc
406396
${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
407397
)
408398

409-
#target_link_libraries( fc PUBLIC ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} )
410399
IF(NOT WIN32)
411400
set(LINK_USR_LOCAL_LIB -L/usr/local/lib)
412401
ENDIF()
413-
target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${editline_libraries} ${ECC_LIB} )
402+
target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${editline_libraries} ${ECC_LIB} )
414403

415404
if(MSVC)
416405
set_source_files_properties( src/network/http/websocket.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )

include/fc/bloom_filter.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ class bloom_parameters
5757
random_seed(0xA5A5A5A55A5A5A5AULL)
5858
{}
5959

60+
bloom_parameters(unsigned long long int projected_element_count,
61+
double false_positive_probability,
62+
unsigned long long int maximum_size) :
63+
minimum_size(1),
64+
maximum_size(maximum_size),
65+
minimum_number_of_hashes(1),
66+
maximum_number_of_hashes(std::numeric_limits<unsigned int>::max()),
67+
projected_element_count(projected_element_count),
68+
false_positive_probability(false_positive_probability),
69+
random_seed(0xA5A5A5A55A5A5A5AULL)
70+
{
71+
compute_optimal_parameters();
72+
}
73+
6074
virtual ~bloom_parameters()
6175
{}
6276

include/fc/compress/smaz.hpp

-9
This file was deleted.

src/compress/smaz.cpp

-223
This file was deleted.

src/crypto/elliptic_common.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ namespace fc { namespace ecc {
140140
std::string public_key::to_base58( const public_key_data &key )
141141
{
142142
uint32_t check = (uint32_t)sha256::hash(key.data, sizeof(key))._hash[0];
143-
assert(key.size() + sizeof(check) == 37);
143+
static_assert(sizeof(key) + sizeof(check) == 37, "Elliptic public key size (or its hash) is incorrect");
144144
array<char, 37> data;
145145
memcpy(data.data, key.begin(), key.size());
146146
memcpy(data.begin() + key.size(), (const char*)&check, sizeof(check));
@@ -192,7 +192,7 @@ namespace fc { namespace ecc {
192192
BN_mod(secexp, secexp, order, ctx);
193193

194194
fc::sha256 secret;
195-
assert(BN_num_bytes(secexp) <= int64_t(sizeof(secret)));
195+
FC_ASSERT(BN_num_bytes(secexp) <= int64_t(sizeof(secret)));
196196
auto shift = sizeof(secret) - BN_num_bytes(secexp);
197197
BN_bn2bin(secexp, ((unsigned char*)&secret)+shift);
198198
return regenerate( secret );

src/crypto/pke.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ namespace fc {
7575

7676
bool public_key::verify( const sha1& digest, const signature& sig )const
7777
{
78-
assert( sig.size() == 2048/8 );
78+
static_assert( sig.size() == 2048/8, "Invalid signature size" );
7979
return 0 != RSA_verify( NID_sha1, (const uint8_t*)&digest, 20,
8080
(uint8_t*)sig.data(), 2048/8, my->rsa );
8181
}
8282
bool public_key::verify( const sha256& digest, const signature& sig )const
8383
{
84-
assert( sig.size() == 2048/8 );
84+
static_assert( sig.size() == 2048/8, "Invalid signature size" );
8585
return 0 != RSA_verify( NID_sha256, (const uint8_t*)&digest, 32,
8686
(uint8_t*)sig.data(), 2048/8, my->rsa );
8787
}

tests/compress/compress.cpp

-32
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,11 @@
22

33
#include <fstream>
44
#include <iostream>
5-
#include <fc/compress/smaz.hpp>
65
#include <fc/compress/zlib.hpp>
76
#include <fc/exception/exception.hpp>
87

98
BOOST_AUTO_TEST_SUITE(compress)
109

11-
BOOST_AUTO_TEST_CASE(smaz_test)
12-
{
13-
std::ifstream testfile;
14-
testfile.open("README.md");
15-
16-
std::stringstream buffer;
17-
std::string line;
18-
std::getline( testfile, line );
19-
while( testfile.good() )
20-
{
21-
buffer << line << "\n";
22-
try {
23-
std::string compressed = fc::smaz_compress( line );
24-
std::string decomp = fc::smaz_decompress( compressed );
25-
BOOST_CHECK_EQUAL( decomp, line );
26-
}
27-
catch ( fc::exception& e )
28-
{
29-
std::cout<<e.to_detail_string()<<"\n";
30-
}
31-
32-
std::getline( testfile, line );
33-
}
34-
35-
line = buffer.str();
36-
std::string compressed = fc::smaz_compress( line );
37-
std::string decomp = fc::smaz_decompress( compressed );
38-
BOOST_CHECK_EQUAL( decomp, line );
39-
}
40-
41-
4210
extern "C" {
4311

4412
enum

0 commit comments

Comments
 (0)