diff --git a/cmake/Modules/Finded25519.cmake b/cmake/Modules/Finded25519.cmake new file mode 100644 index 0000000000..930b3bee54 --- /dev/null +++ b/cmake/Modules/Finded25519.cmake @@ -0,0 +1,41 @@ +add_library(ed25519 UNKNOWN IMPORTED) + +find_path(ed25519_INCLUDE_DIR ed25519/ed25519.h) +mark_as_advanced(ed25519_INCLUDE_DIR) + +find_library(ed25519_LIBRARY ed25519) +mark_as_advanced(ed25519_LIBRARY) + +find_package_handle_standard_args(ed25519 DEFAULT_MSG + ed25519_INCLUDE_DIR + ed25519_LIBRARY + ) + +set(URL https://github.com/warchant/ed25519.git) +set(VERSION 0d31b082e0f0d4144fe598fb0f2a120e36de2a8f) +set_target_description(ed25519 "Digital signature algorithm" ${URL} ${VERSION}) + +if (NOT ed25519_FOUND) + externalproject_add(warchant_ed25519 + GIT_REPOSITORY ${URL} + GIT_TAG ${VERSION} + CMAKE_ARGS + -DTESTING=OFF + INSTALL_COMMAND "" # remove install step + TEST_COMMAND "" # remove test step + UPDATE_COMMAND "" # remove update step + ) + externalproject_get_property(warchant_ed25519 binary_dir) + externalproject_get_property(warchant_ed25519 source_dir) + set(ed25519_INCLUDE_DIR ${source_dir}/include) + set(ed25519_LIBRARY ${binary_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}ed25519${CMAKE_SHARED_LIBRARY_SUFFIX}) + message(STATUS ${ed25519_LIBRARY}) + file(MAKE_DIRECTORY ${ed25519_INCLUDE_DIR}) + + add_dependencies(ed25519 warchant_ed25519) +endif () + +set_target_properties(ed25519 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${ed25519_INCLUDE_DIR} + IMPORTED_LOCATION ${ed25519_LIBRARY} + ) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index c49de5e1c2..31bea19515 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -101,4 +101,7 @@ if(BENCHMARKING) find_package(benchmark) endif() - +################################### +# ed25519/sha3 # +################################### +find_package(ed25519) diff --git a/docker/develop/Dockerfile b/docker/develop/Dockerfile index 65b8cbe74a..d8e8e57487 100644 --- a/docker/develop/Dockerfile +++ b/docker/develop/Dockerfile @@ -184,5 +184,13 @@ RUN git clone git://sourceware.org/git/valgrind.git /tmp/valgrind; \ make -C /tmp/valgrind install; \ rm -rf /tmp/valgrind +# install ed25519 +RUN git clone git://github.com/warchant/ed25519.git /tmp/ed25519; \ + (cd /tmp/ed25519 ; git checkout 0d31b082e0f0d4144fe598fb0f2a120e36de2a8f); \ + cmake -DCMAKE_BUILD_TYPE=Debug -DTESTING=OFF -H/tmp/ed25519 -B/tmp/ed25519/build; \ + cmake --build /tmp/ed25519/build --target install -- -j${PARALLELISM}; \ + ldconfig; \ + rm -rf /tmp/ed25519 + WORKDIR /opt/iroha CMD ["/bin/bash"] diff --git a/libs/common/types.hpp b/libs/common/types.hpp index 8580c19c17..dbe93c324d 100644 --- a/libs/common/types.hpp +++ b/libs/common/types.hpp @@ -307,7 +307,7 @@ namespace iroha { using sig_t = blob_t<64>; // ed25519 sig is 64 bytes length using pubkey_t = blob_t<32>; - using privkey_t = blob_t<64>; + using privkey_t = blob_t<32>; struct keypair_t { keypair_t() = default;