mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-03 11:53:41 +02:00
adding src/wasm.cpp (Emscripten API function)
This commit is contained in:
parent
f904b2a53f
commit
4ff98739a1
2 changed files with 49 additions and 1 deletions
|
|
@ -12,13 +12,19 @@ find_package(OpenSSL 1.1 REQUIRED)
|
||||||
|
|
||||||
include_directories( ${OPENSSL_INCLUDE_DIR} )
|
include_directories( ${OPENSSL_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
if (${CMAKE_SYSTEM_NAME} STREQUAL Emscripten)
|
||||||
|
set (src_main src/wasm.cpp)
|
||||||
|
else()
|
||||||
|
set (src_main src/main.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable( ${CMAKE_PROJECT_NAME}
|
add_executable( ${CMAKE_PROJECT_NAME}
|
||||||
src/ec.cpp
|
src/ec.cpp
|
||||||
src/base58.cpp
|
src/base58.cpp
|
||||||
src/checksum.cpp
|
src/checksum.cpp
|
||||||
src/WIF.cpp
|
src/WIF.cpp
|
||||||
src/utils.cpp
|
src/utils.cpp
|
||||||
src/main.cpp
|
${src_main}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries( ${CMAKE_PROJECT_NAME} PUBLIC ${OPENSSL_LIBRARIES} )
|
target_link_libraries( ${CMAKE_PROJECT_NAME} PUBLIC ${OPENSSL_LIBRARIES} )
|
||||||
|
|
|
||||||
42
src/wasm.cpp
Normal file
42
src/wasm.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <emscripten.h>
|
||||||
|
#include <emscripten/bind.h>
|
||||||
|
#include <emscripten/val.h>
|
||||||
|
#include <string>
|
||||||
|
#include "WIF.h"
|
||||||
|
#include "ec.h"
|
||||||
|
|
||||||
|
emscripten::val keygen(void) {
|
||||||
|
struct ec_keypair pair;
|
||||||
|
std::string ret = "";
|
||||||
|
ec_generate_key(&pair);
|
||||||
|
|
||||||
|
ret = wif_pub_encode(pair.pub) + ":" + wif_priv_encode(pair.secret);
|
||||||
|
return emscripten::val(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
EMSCRIPTEN_BINDINGS(eosiokeygen) {
|
||||||
|
emscripten::function("eosio_keygen", &keygen);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue