manuel 6 rokov pred
rodič
commit
910a54792e
6 zmenil súbory, kde vykonal 27 pridanie a 12 odobranie
  1. 2 0
      .gitignore
  2. 3 1
      CMakeLists.txt
  3. 2 1
      include/crypt/BigInt64.hpp
  4. 8 0
      include/hash.hpp
  5. 2 2
      socket_impl/CMakeLists.txt
  6. 10 8
      test.cpp

+ 2 - 0
.gitignore

@@ -10,3 +10,5 @@ s
 server
 test
 kak.txt
+*.kdev4
+build/

+ 3 - 1
CMakeLists.txt

@@ -1,8 +1,10 @@
 cmake_minimum_required (VERSION 3.0)
+set(CMAKE_EXPORT_COMPILE_COMMANDS true)
 include_directories(include)
 set(CMAKE_CXX_COMPILER "g++")
 IF(CMAKE_BUILD_TYPE MATCHES Release)
 	set(CMAKE_CXX_FLAGS "-O3 -march=native -ftree-vectorize -flto -funroll-loops -fomit-frame-pointer -s")
 endif()
 add_subdirectory(socket_impl)
-message(CMAKE_CXX_FLAGS)
+add_executable(toast test.cpp)
+target_link_libraries(toast sio)

+ 2 - 1
include/crypt/BigInt64.hpp

@@ -26,7 +26,8 @@ template<typename T>
 inline int signum(T t){
 	if(t < 0)return -1;
 	if(t >= 0)return 1;
-	assert(false);
+    assert(false && "t is neither >= nor < 0");
+	return 0;
 }
 inline void singleHex(char dest[], uint64_t nr){
 	uint64_t mask = 0xf000000000000000;

+ 8 - 0
include/hash.hpp

@@ -36,4 +36,12 @@ BigInt sha512(ForwardIterator begin, ForwardIterator end){
 	for(std::uint64_t& x : ret)x = reverse(x);
 	return BigInt(ret.begin(), ret.end());
 }
+template<typename Iterable>
+BigInt sha512(const Iterable& arg){
+    return sha512(arg.begin(), arg.end());
+}
+template<typename Iterable>
+BigInt sha256(const Iterable& arg){
+    return sha256(arg.begin(), arg.end());
+}
 #endif

+ 2 - 2
socket_impl/CMakeLists.txt

@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 3.0)
 if(WIN32)
-	add_library(sio hash.cpp socketio_win32.cpp ../msc_supp/uint128_t.cpp)
+	add_library(sio STATIC hash.cpp socketio_win32.cpp ../msc_supp/uint128_t.cpp)
 endif()
 if(UNIX)
-        add_library(sio hash.cpp udpsocket_posix.cpp socketio_posix.cpp)
+        add_library(sio STATIC hash.cpp udpsocket_posix.cpp socketio_posix.cpp)
 endif()

+ 10 - 8
test.cpp

@@ -1,12 +1,14 @@
 #include <crypt/BigInt64.hpp>
 #include <hash.hpp>
+#include <myheader.h>
+#include <iostream>
 int main(){
-	unsigned long long a = 0;
-	unsigned long long* b = &a;
-	while(true){
-		auto hesch = sha512(b,b+1);
-		a++;
-		std::cout << hesch.hexString();
-	}
-	std::cout << "Fertig" << std::endl;
+    std::mt19937_64 gen(54);
+    BigInt n(2);
+    unsigned int i = 1;
+    auto t1 = std::nanoTime();
+    n = n.modPow(BigInt(gen, 31), secure_prime);
+    std::cout << n.toString() << std::endl;
+    auto t2 = std::nanoTime();
+    std::cout << sha512(n).hexString() << std::endl;
 }