Giter VIP home page Giter VIP logo

hyperledger / iroha-ed25519 Goto Github PK

View Code? Open in Web Editor NEW
29.0 9.0 13.0 1.25 MB

RFC8032 compatible Ed25519 implementation with pluggable hash (sha2-512, sha3-512)

Home Page: https://wiki.hyperledger.org/display/iroha

License: Apache License 2.0

CMake 3.47% Python 0.34% C 27.59% Assembly 65.85% Makefile 0.06% C++ 1.31% Shell 0.10% q 0.45% SWIG 0.83%
amd64-64-24k ref10 flexible ed25519 sha2 sha512 sha3 openssl linux osx

iroha-ed25519's Introduction

codecov

Ed25519 digital signature algorithm

Ed25519 digital signature algorithm is described in RFC8032. This repository aims to provide modularized implementation of this algorithm.

Originally Ed25519 consists of three modules:

  • digital signature algorithm itself
  • SHA512 hash function
  • random number generator, to generate keypairs

This repository offers at least two different C implementations for every module. Every implementation is tested and can be replaced with other at link-time. New implementations can be added as well.

During CMake time, users are able to choose any of these implementations using cmake definitions:

  • EDIMPL
    • ref10 - portable C implementation.
    • amd64-64-24k-pic - optimized C and ASM implementation, works only on Linux amd64. Has fixes in ASM files, to allow position independent code (-fPIC) builds.
  • HASH
    • sha2_openssl
    • sha2_sphlib
    • sha3_brainhub - default
  • RANDOM
    • rand_openssl
    • dev_urandom - default
    • dev_random
    • bcryptgen (windows only)
  • BUILD
    • STATIC
    • SHARED - build ed25519 library as shared library (default)

Example: We want to build shared library with fast amd64 implementation, SHA3 and PRNG, which reads entropy from /dev/urandom:

$ cmake .. -DEDIMPL=amd64-64-24k-pic -DHASH=sha3_brainhub -DRANDOM=dev_urandom -DBUILD=SHARED                   bogdan@Bogdans-MacBook-Pro
-- [hunter] Calculating Toolchain-SHA1
-- [hunter] Calculating Config-SHA1
-- [hunter] HUNTER_ROOT: /Users/bogdan/.hunter
-- [hunter] [ Hunter-ID: 1c7aaff | Toolchain-ID: 9e23df5 | Config-ID: 997ea55 ]
-- [hunter] GTEST_ROOT: /Users/bogdan/.hunter/_Base/1c7aaff/9e23df5/997ea55/Install (ver.: 1.8.0-hunter-p11)
-- EDIMPL=amd64-64-24k-pic is selected (Ed25519 implementation)
-- HASH=sha3_brainhub is selected (SHA implementation)
-- RANDOM=dev_urandom is selected (RNG implementation)
-- BUILD=SHARED is selected (library build type)
-- [ed25519] Target RANDOM=bcryptgen is not supported on your platform
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/bogdan/tools/iroha-ed25519/build

Note: only those targets (including tests) will be built, which are specified in EDIMPL, HASH, RANDOM variables.

API

Modules

ed25519 digital signature algorithm

  • ref10 - portable but relatively slow C implementation, originally copied from supercop-20171020. Its API was redesigned to separate signature data from the signed message content.
  • amd64-64-24k-pic - fast (4x ref10) but non-portable C and ASM implementation, only for AMD64. Copied from supercop-20171020. Adopted to be included as a module. Has Position Independent Code (-fPIC) fixes by @l4l.

SHA512 has function as a dependency of ed25519

  • sha2_openssl - implementation of FIPS 180-4 SHA2 512 hash function, which uses openssl underneath
  • sha2_sphlib - implementation of FIPS 180-4 SHA2 512 hash function, which was taken from supercop-20190110
  • sha3_brainhub - implementation of FIPS 202 SHA3 512 hash function taken from brainhub repository. Repository consists of a single C file, which was adopted to be included in a project as a module.

PRNG implementation as a dependency of ed25519

To generate keypair ed25519 needs a source of randomness (entropy).

This repository offers 4 implementations:

  • rand_openssl uses RAND_bytes from openssl
  • dev_urandom reads entropy from /dev/urandom
  • dev_random reads entropy from /dev/random (blocking call, uses busy waiting when user asks for more entropy than device can offer)
  • bcryptgen reads entropy from windows preferred entropy source.

iroha-ed25519's People

Contributors

hyperledger-bot avatar l4l avatar lasintez avatar lebdron avatar ryjones avatar tkyonezu avatar warchant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iroha-ed25519's Issues

Can't compile on Windows

  • OS: Windows Server 2016 x64
  • Compiler: cmake (MSVC 2017 x86_64)

Build & install commands:

set -e
git clone git://github.com/hyperledger/iroha-ed25519.git /tmp/ed25519
cd /tmp/ed25519
cmake -DCMAKE_BUILD_TYPE=Release -DTESTING=OFF -H/tmp/ed25519 -B/tmp/ed25519/build
cmake --build /tmp/ed25519/build --target install

Log

Cloning into 'C:/Users/ADMINI~1/AppData/Local/Temp/2/ed25519'...
remote: Counting objects: 817, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 817 (delta 0), reused 3 (delta 0), pack-reused 810
Receiving objects: 100% (817/817), 1.19 MiB | 2.22 MiB/s, done.
Resolving deltas: 100% (357/357), done.
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.16299.0 to target Windows 10.0.14393.
-- The C compiler identification is MSVC 19.13.26132.0
-- The CXX compiler identification is MSVC 19.13.26132.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.13.26128/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.13.26128/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.13.26128/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.13.26128/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.13.26128/bin/Hostx86/x86/cl.exe
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
-- EDIMPL=ref10 is selected (Ed25519 implementation)
-- HASH=sha3_brainhub is selected (SHA implementation)
-- RANDOM=dev_urandom is selected (RNG implementation)
-- BUILD=SHARED is selected (library build type)
-- CMAKE_BUILD_TYPE=Release is selected (cmake build type)
-- [ed25519] Target EDIMPL=amd64-64-24k is not supported on your platform
-- [ed25519] Target EDIMPL=amd64-64-24k-pic is not supported on your platform
-- [ed25519] Target RANDOM=dev_random is not supported on your platform
-- [ed25519] Target RANDOM=dev_urandom is not supported on your platform
-- [ed25519] Target HASH=sha2_openssl is not supported on your platform
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
-- Performing Test COMPILER_HAS_DEPRECATED
-- Performing Test COMPILER_HAS_DEPRECATED - Success
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Administrator/AppData/Local/Temp/2/ed25519/build




Microsoft (R) Build Engine version 15.6.85.37198 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 6/13/2018 2:38:59 PM.
Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\install.vcxpr    oj" on node 1 (default targets).
Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\install.vcxpr    oj" (1) is building "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\Z    ERO_CHECK.vcxproj" (2) on node 1 (default targets).
InitializeBuildStatus:
  Creating "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "A    lwaysCreate" was specified.
CustomBuild:
  All outputs are up-to-date.
FinalizeBuildStatus:
  Deleting file "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
  Touching "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build    \ZERO_CHECK.vcxproj" (default targets).
Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\install.vcxpr    oj" (1) is building "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\A    LL_BUILD.vcxproj" (3) on node 1 (default targets).
Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ALL_BUILD.vcx    proj" (3) is building "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build    \ed25519.vcxproj" (4) on node 1 (default targets).
Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ed25519.vcxpr    oj" (4) is building "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\l    ib\ed25519\ref10\ref10.vcxproj" (5) on node 1 (default targets).
InitializeBuildStatus:
  Touching "ref10.dir\Debug\ref10.tlog\unsuccessfulbuild".
CustomBuild:
  All outputs are up-to-date.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\1    4.13.26128\bin\HostX86\x86\CL.exe /c /IC:\Users\Administrator\AppData\Local\Temp    \2\ed25519\build /IC:\Users\Administrator\AppData\Local\Temp\2\ed25519\include /    IC:\Users\Administrator\AppData\Local\Temp\2\ed25519\lib\ed25519\ref10 /IC:\User    s\Administrator\AppData\Local\Temp\2\ed25519\lib\ed25519\ref10\C:\Users\Administ    rator\AppData\Local\Temp\2\ed25519\build /Zi /nologo /W3 /WX- /diagnostics:class    ic /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D ed25519_EXPORTS /D "CMAKE_INTDIR=\"Debu    g\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inlin    e /Fo"ref10.dir\Debug\\" /Fd"ref10.dir\Debug\ref10.pdb" /Gd /TC /analyze- /FC /e    rrorReport:queue C:\Users\Administrator\AppData\Local\Temp\2\ed25519\lib\ed25519    \ref10\ed25519.c
  ed25519.c
c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.c(    30): error C2057: expected constant expression [C:\Users\Administrator\AppData\L    ocal\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.c(    30): error C2466: cannot allocate an array of constant size 0 [C:\Users\Administ    rator\AppData\Local\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.c(    30): error C2133: 'context': unknown size [C:\Users\Administrator\AppData\Local\    Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.c(    71): error C2057: expected constant expression [C:\Users\Administrator\AppData\L    ocal\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.c(    71): error C2466: cannot allocate an array of constant size 0 [C:\Users\Administ    rator\AppData\Local\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.c(    71): error C2133: 'context': unknown size [C:\Users\Administrator\AppData\Local\    Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
Done Building Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build    \lib\ed25519\ref10\ref10.vcxproj" (default targets) -- FAILED.
Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ed25519.vcxpr    oj" (4) is building "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\l    ib\hash\sha3_brainhub\sha3_brainhub.vcxproj" (6) on node 1 (default targets).
InitializeBuildStatus:
  Touching "sha3_brainhub.dir\Debug\sha3_brainhub.tlog\unsuccessfulbuild".
CustomBuild:
  All outputs are up-to-date.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\1    4.13.26128\bin\HostX86\x86\CL.exe /c /IC:\Users\Administrator\AppData\Local\Temp    \2\ed25519\build /IC:\Users\Administrator\AppData\Local\Temp\2\ed25519\include /    IC:\Users\Administrator\AppData\Local\Temp\2\ed25519\lib\hash\sha3_brainhub\C:\U    sers\Administrator\AppData\Local\Temp\2\ed25519\build /Zi /nologo /W3 /WX- /diag    nostics:classic /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D ed25519_EXPORTS /D "CMAKE_    INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forSc    ope /Zc:inline /Fo"sha3_brainhub.dir\Debug\\" /Fd"sha3_brainhub.dir\Debug\sha3_b    rainhub.pdb" /Gd /TC /analyze- /FC /errorReport:queue C:\Users\Administrator\App    Data\Local\Temp\2\ed25519\lib\hash\sha3_brainhub\sha3_256.c C:\Users\Administrat    or\AppData\Local\Temp\2\ed25519\lib\hash\sha3_brainhub\sha3_512.c
  sha3_256.c
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    256.c(12): warning C4244: 'function': conversion from 'unsigned __int64' to '::s    ize_t', possible loss of data [C:\Users\Administrator\AppData\Local\Temp\2\ed255    19\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    256.c(23): error C2057: expected constant expression [C:\Users\Administrator\App    Data\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    256.c(23): error C2466: cannot allocate an array of constant size 0 [C:\Users\Ad    ministrator\AppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brain    hub.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    256.c(23): error C2133: 'ctx': unknown size [C:\Users\Administrator\AppData\Loca    l\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
  sha3_512.c
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    512.c(12): warning C4244: 'function': conversion from 'unsigned __int64' to '::s    ize_t', possible loss of data [C:\Users\Administrator\AppData\Local\Temp\2\ed255    19\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    512.c(23): error C2057: expected constant expression [C:\Users\Administrator\App    Data\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    512.c(23): error C2466: cannot allocate an array of constant size 0 [C:\Users\Ad    ministrator\AppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brain    hub.vcxproj]
c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha3_    512.c(23): error C2133: 'ctx': unknown size [C:\Users\Administrator\AppData\Loca    l\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
  Generating Code...
Done Building Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build    \lib\hash\sha3_brainhub\sha3_brainhub.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build    \ed25519.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build    \ALL_BUILD.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build    \install.vcxproj" (default targets) -- FAILED.

Build FAILED.

"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\install.vcxproj" (def    ault target) (1) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ALL_BUILD.vcxproj" (d    efault target) (3) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ed25519.vcxproj" (def    ault target) (4) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhu    b\sha3_brainhub.vcxproj" (default target) (6) ->
(ClCompile target) ->
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_256.c(12): warning C4244: 'function': conversion from 'unsigned __int64' to ':    :size_t', possible loss of data [C:\Users\Administrator\AppData\Local\Temp\2\ed2    5519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_512.c(12): warning C4244: 'function': conversion from 'unsigned __int64' to ':    :size_t', possible loss of data [C:\Users\Administrator\AppData\Local\Temp\2\ed2    5519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]


"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\install.vcxproj" (def    ault target) (1) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ALL_BUILD.vcxproj" (d    efault target) (3) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ed25519.vcxproj" (def    ault target) (4) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\lib\ed25519\ref10\ref    10.vcxproj" (default target) (5) ->
(ClCompile target) ->
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.    c(30): error C2057: expected constant expression [C:\Users\Administrator\AppData    \Local\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.    c(30): error C2466: cannot allocate an array of constant size 0 [C:\Users\Admini    strator\AppData\Local\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.    c(30): error C2133: 'context': unknown size [C:\Users\Administrator\AppData\Loca    l\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.    c(71): error C2057: expected constant expression [C:\Users\Administrator\AppData    \Local\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.    c(71): error C2466: cannot allocate an array of constant size 0 [C:\Users\Admini    strator\AppData\Local\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\ed25519\ref10\ed25519.    c(71): error C2133: 'context': unknown size [C:\Users\Administrator\AppData\Loca    l\Temp\2\ed25519\build\lib\ed25519\ref10\ref10.vcxproj]


"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\install.vcxproj" (def    ault target) (1) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ALL_BUILD.vcxproj" (d    efault target) (3) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\ed25519.vcxproj" (def    ault target) (4) ->
"C:\Users\Administrator\AppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhu    b\sha3_brainhub.vcxproj" (default target) (6) ->
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_256.c(23): error C2057: expected constant expression [C:\Users\Administrator\A    ppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_256.c(23): error C2466: cannot allocate an array of constant size 0 [C:\Users\    Administrator\AppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_bra    inhub.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_256.c(23): error C2133: 'ctx': unknown size [C:\Users\Administrator\AppData\Lo    cal\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_512.c(23): error C2057: expected constant expression [C:\Users\Administrator\A    ppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_512.c(23): error C2466: cannot allocate an array of constant size 0 [C:\Users\    Administrator\AppData\Local\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_bra    inhub.vcxproj]
  c:\users\administrator\appdata\local\temp\2\ed25519\lib\hash\sha3_brainhub\sha    3_512.c(23): error C2133: 'ctx': unknown size [C:\Users\Administrator\AppData\Lo    cal\Temp\2\ed25519\build\lib\hash\sha3_brainhub\sha3_brainhub.vcxproj]

    2 Warning(s)
    12 Error(s)

Time Elapsed 00:00:01.91

Library merging

problem

Project consists of 3 subprojects: EDIMPL, HASH, RANDOM. Each of subprojects can have many implementations. The task is to produce single SHARED library, which is a result of merging of 3 subprojects.

requirements

We consider two clients of this repository:

  1. "build only what you need" client -- this client typically needs to produce single libed25519.so, which consists of selected implementations. Nothing else should be built.
  2. "CI" client -- this client typically needs to build all possible combinations of libraries and execute tests against them, collect coverage of all execution paths and execute static / dynamic analyzers.

We can't just define all targets and add them to all target (usual make), because it is likely that some combinations will work on client (1) and some will not (example is EDIMPL=amd64-64-24k-pic on MAC, it will not work). make install for such client will fail.

From the other side, client (2) can typically build all targets or almost all targets -- it has all dependencies (such as openssl) and it has proper architecture (amd64).

solutions

solution 1 (https://github.com/hyperledger/iroha-ed25519/releases/tag/1.1.0)

Define every implementation as OBJECT library and include OBJECT library in every dependent target. Client specifies EDIMPL, HASH, RANDOM and combination of these libraries is built together in single SHARED ed25519.

Problems:

  • some implementations depend on other libraries, such as openssl and it is not possible to link anything to OBJECT library, therefore it results in linking error.
  • to test all combinations in CI (client (2)) we need to write a lot of CI steps. Hard to write them and maintain.
  • hard to collect coverage

solution 2

Define every implementation as STATIC library.

Problems:

  • resulting SHARED library will not contain symbols of STATIC libraries.

  • above problem can be solved with flag -Wl,--whole-archive ${lib1} ${lib2} ${lib3} -Wl,--no-whole-archive. But in this case this error appears:

    /usr/bin/ld: lib/ed25519/amd64-64-24k/CMakeFiles/amd64-64-24k.dir/fe25519_mul.s.o: relocation R_X86_64_32S against `crypto_sign_ed25519_amd64_64_38' can not be used when making a shared object; recompile with -fPIC		
    lib/ed25519/amd64-64-24k/CMakeFiles/amd64-64-24k.dir/fe25519_mul.s.o: error adding symbols: Bad value		
    collect2: error: ld returned 1 exit status		
    CMakeFiles/ed25519.dir/build.make:211: recipe for target 'libed25519.so.1.2.2' failed
    

    even when everything is built with -fPIC.

    And above problem again can be solved with something like linker exportmap:
    https://github.com/hyperledger/iroha-ed25519/blob/master/src/CMakeLists.txt#L14-L16
    https://github.com/hyperledger/iroha-ed25519/blob/master/exportmap

    But, exactly this solution is not portable -- only Linux ld can use exportmap.

solution 3

Append all sources to a variable and use them in single ed25519 target as it is done here:
https://github.com/hyperledger/iroha-ed25519/blob/master/src/CMakeLists.txt#L8-L32

Problems:

  • same problem as with use of --whole-archive.
  • every test recompiles target from scratch, which increases compilation time.

compilation/linking error when building the library

[ 89%] Linking C shared library libed25519.so
/usr/bin/ld: lib/ed25519/amd64-64-24k-pic/CMakeFiles/amd64-64-24k-pic.dir/fe25519_mul.s.o: relocation R_X86_64_PC32 against symbol `crypto_sign_ed25519_amd64_64_38' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

I followed the instructions on the page except that I used the amd64-64-24k-pic implementation so that I'd get the PIC fixes. It looks like there's an instance that was missed.

Compiler overriding

For now cmake overrides the system-defined compiler, would be nice to fix that

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.