Added documentation + automated interop test
This commit is contained in:
parent
7b15098f3a
commit
20230b761e
3 changed files with 93 additions and 3 deletions
|
|
@ -24,7 +24,7 @@ SET( DEFAULT_LIBRARY_INSTALL_DIR lib/ )
|
||||||
SET( DEFAULT_EXECUTABLE_INSTALL_DIR bin/ )
|
SET( DEFAULT_EXECUTABLE_INSTALL_DIR bin/ )
|
||||||
SET( CMAKE_DEBUG_POSTFIX _debug )
|
SET( CMAKE_DEBUG_POSTFIX _debug )
|
||||||
SET( BUILD_SHARED_LIBS NO )
|
SET( BUILD_SHARED_LIBS NO )
|
||||||
SET( ECC_IMPL secp256k1 ) # openssl or secp256k1
|
SET( ECC_IMPL openssl CACHE STRING "openssl or secp256k1" )
|
||||||
|
|
||||||
set(platformBitness 32)
|
set(platformBitness 32)
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|
@ -261,8 +261,8 @@ target_include_directories(fc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp
|
${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_link_libraries( fc PUBLIC easylzma_static scrypt udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library})
|
#target_link_libraries( fc PUBLIC easylzma_static scrypt udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} )
|
||||||
target_link_libraries( fc PUBLIC easylzma_static udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB})
|
target_link_libraries( fc PUBLIC easylzma_static udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} )
|
||||||
|
|
||||||
IF(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\.(a|lib)$")
|
IF(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\.(a|lib)$")
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
|
|
|
||||||
55
README-ecc.md
Normal file
55
README-ecc.md
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
ECC Support
|
||||||
|
===========
|
||||||
|
|
||||||
|
include/fc/crypto/elliptic.hpp defines an interface for some cryptographic
|
||||||
|
wrapper classes handling elliptic curve cryptography.
|
||||||
|
|
||||||
|
Two implementations of this interface exist. One is based on OpenSSL, the
|
||||||
|
other is based on libsecp256k1 (see https://github.com/bitcoin/secp256k1 ).
|
||||||
|
The implementation to be used is selected at compile time using the
|
||||||
|
cmake variable "ECC_IMPL". It can take two values, openssl or secp256k1 .
|
||||||
|
The default is "openssl". The alternative can be configured when invoking
|
||||||
|
cmake, for example
|
||||||
|
|
||||||
|
cmake -D ECC_IMPL=secp256k1 .
|
||||||
|
|
||||||
|
If secp256k1 is chosen, the secp256k1 library and its include file must
|
||||||
|
already be installed in the appropriate library / include directories on
|
||||||
|
your system.
|
||||||
|
|
||||||
|
|
||||||
|
Testing
|
||||||
|
-------
|
||||||
|
|
||||||
|
Type "make ecc_test" to build the ecc_test executable from tests/ecc_test.cpp
|
||||||
|
with the currently configured ECC implementation.
|
||||||
|
|
||||||
|
ecc_test expects two arguments:
|
||||||
|
|
||||||
|
ecc_test <pass> <interop-file>
|
||||||
|
|
||||||
|
<pass> is a somewhat arbitrary password used for testing.
|
||||||
|
|
||||||
|
<interop-file> is a data file containing intermediate test results.
|
||||||
|
If the file does not exist, it will be created and intermediate results from
|
||||||
|
the current ECC backend are written to it.
|
||||||
|
If the file does exist, intermediate results from the current ECC backend
|
||||||
|
are compared with the file contents.
|
||||||
|
|
||||||
|
For a full round of interoperability testing, you need to do this:
|
||||||
|
|
||||||
|
1. Build ecc_test with openssl backend.
|
||||||
|
2. Run "ecc_test test ecc.interop.openssl".
|
||||||
|
3. Run "ecc_test test ecc.interop.openssl" again, testing openssl against
|
||||||
|
itself.
|
||||||
|
4. Build ecc_test with secp256k1 backend.
|
||||||
|
5. Run "ecc_test test ecc.interop.secp256k1".
|
||||||
|
6. Run "ecc_test test ecc.interop.secp256k1" again, testing secp256k1 against
|
||||||
|
itself.
|
||||||
|
7. Run "ecc_test test ecc.interop.openssl", testing secp256k1 against openssl.
|
||||||
|
8. Build ecc_test with openssl backend.
|
||||||
|
9. Run "ecc_test test ecc.interop.secp256k1", testing openssl against secp256k1.
|
||||||
|
|
||||||
|
None of the test runs should produce any output. The above steps are scripted
|
||||||
|
in tests//ecc-interop.sh .
|
||||||
|
|
||||||
35
tests/ecc-interop.sh
Executable file
35
tests/ecc-interop.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#TIME=time
|
||||||
|
|
||||||
|
cd "`dirname $0`"/..
|
||||||
|
|
||||||
|
echo Building ecc_test with openssl...
|
||||||
|
(
|
||||||
|
cmake -D ECC_IMPL=openssl .
|
||||||
|
make ecc_test
|
||||||
|
mv ecc_test ecc_test.openssl
|
||||||
|
) >/dev/null 2>&1
|
||||||
|
|
||||||
|
echo Building ecc_test with secp256k1...
|
||||||
|
(
|
||||||
|
cmake -D ECC_IMPL=secp256k1 .
|
||||||
|
make ecc_test
|
||||||
|
mv ecc_test ecc_test.secp256k1
|
||||||
|
) >/dev/null 2>&1
|
||||||
|
|
||||||
|
run () {
|
||||||
|
echo "Running ecc_test.$1 test ecc.interop.$1 ..."
|
||||||
|
$TIME "./ecc_test.$1" test "ecc.interop.$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
run openssl
|
||||||
|
run openssl
|
||||||
|
run secp256k1
|
||||||
|
run secp256k1
|
||||||
|
run secp256k1
|
||||||
|
run openssl
|
||||||
|
|
||||||
|
echo Done.
|
||||||
|
|
||||||
|
rm -f ecc_test.openssl ecc_test.secp256k1 ecc.interop.openssl ecc.interop.secp256k1
|
||||||
Loading…
Reference in a new issue