Skip to content
Snippets Groups Projects
Commit 6c66f81f authored by Mariusz Trela's avatar Mariusz Trela
Browse files

secp256k1 library is compiled into WASM

parent 6cc8805c
No related branches found
No related tags found
1 merge request!2OpenSSL library is compiled into WASM
......@@ -24,6 +24,9 @@ set_target_properties( crypto PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURC
add_library( ssl STATIC IMPORTED )
set_target_properties( ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/openssl/libssl.a )
target_include_directories( wasm_test PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/openssl/include" "${CMAKE_CURRENT_SOURCE_DIR}/include" ${Boost_INCLUDE_DIR} )
target_link_libraries( wasm_test PRIVATE ssl crypto mfc embind idbfs.js ${Boost_LIBRARIES} )
add_library( secp256k1 STATIC IMPORTED )
set_target_properties( secp256k1 PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/secp256k1-zkp/.libs/libsecp256k1.a )
target_include_directories( wasm_test PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/openssl/include" "${CMAKE_CURRENT_SOURCE_DIR}/secp256k1-zkp/include" "${CMAKE_CURRENT_SOURCE_DIR}/include" ${Boost_INCLUDE_DIR} )
target_link_libraries( wasm_test PRIVATE secp256k1 ssl crypto mfc embind idbfs.js ${Boost_LIBRARIES} )
target_link_options( wasm_test PRIVATE "--emrun" )
......@@ -12,11 +12,20 @@
10. git submodule update --init --recursive
11. emconfigure ./Configure linux-generic64
12. sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
13. emmake make -j 12 build_generated libssl.a libcrypto.a
13. emmake make build_generated libssl.a libcrypto.a
14. ./build.sh && ./run.sh
14. git clone https://github.com/ElementsProject/secp256k1-zkp.git
15. ./autogen.sh
#if above script fails, then try to install:
sudo apt-get install autoconf
and/or
sudo apt-get install libtool
16. emconfigure ./configure
17. emmake make
15. Start a browser and open url: http://<ip>:6931/test/wasm_test.html
18. ./build.sh && ./run.sh
19. Start a browser and open url: http://<ip>:6931/test/wasm_test.html
......@@ -8,6 +8,8 @@
#include <openssl/sha.h>
#include <secp256k1.h>
#include <emscripten/bind.h>
using namespace emscripten;
......@@ -23,7 +25,17 @@ public:
++x;
}
std::string test_sec256k1()
{
secp256k1_context* _ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN);
std::string _result = _ctx ? "OK" : "FAIL";
free( _ctx );
return _result;
}
void dump(std::string path) {
auto _context_status = test_sec256k1();
SHA_CTX ctx;
ctx.num = 12;
......@@ -52,7 +64,8 @@ public:
sd.doWork(path, std::string("specified path: ") + path + path_description
+ std::string(";X has value: ") + std::to_string(x)
+ " use SHA_CTX structure: " + std::to_string( ctx.num )
+ " generate SHA512: " + __sha512 );
+ " generate SHA512: " + __sha512
+ " sec256k1 context status: " + _context_status );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment