Skip to content

Commit

Permalink
fix Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed May 20, 2023
1 parent e617260 commit e48d9b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM apiaryio/emcc:latest
FROM emscripten/emsdk:latest

RUN apt-get update
RUN apt-get install dh-autoreconf -y

WORKDIR /build
WORKDIR /build
25 changes: 11 additions & 14 deletions dist/secp256k1-zkp.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions scripts/build_wasm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

## parralelize. Default 4 jobs, check based on current available cores with cpuinfo
# Parallelize. Default 4 jobs, check based on current available cores with cpuinfo
num_jobs=4
if [ -f /proc/cpuinfo ]; then
num_jobs=$(grep ^processor /proc/cpuinfo | wc -l)
Expand All @@ -11,8 +11,8 @@ fi
# optmization level
OPTIMIZATION_LEVEL=s
# C functions to export to Javascript
EXTRA_EXPORTED_RUNTIME_METHODS="['getValue', 'setValue', 'ccall']"
EXPORTED_FUNCTIONS="['_secp256k1_ecmult_gen_prec_table', '_secp256k1_pre_g', '_free', '_malloc', '_ecdh', '_generator_generate', '_generator_generate_blinded', '_generator_parse', '_generator_serialize', '_pedersen_blind_generator_blind_sum', '_pedersen_commitment', '_pedersen_commitment_parse', '_pedersen_commitment_serialize', '_pedersen_commit', '_pedersen_blind_sum', '_pedersen_verify_tally', '_rangeproof_sign', '_rangeproof_info', '_rangeproof_verify', '_rangeproof_rewind', '_surjectionproof_parse', '_surjectionproof_serialize', '_surjectionproof_initialize', '_surjectionproof_generate', '_surjectionproof_verify', '_ec_seckey_negate', '_ec_seckey_tweak_add', '_ec_seckey_tweak_sub', '_ec_seckey_tweak_mul', '_ec_is_point', '_ec_point_compress', '_ec_point_from_scalar', '_ec_x_only_point_tweak_add', '_ec_sign_ecdsa', '_ec_verify_ecdsa', '_ec_sign_schnorr', '_ec_verify_schnorr', '_ec_seckey_verify']"
EXPORTED_RUNTIME_METHODS="['getValue', 'setValue', 'ccall']"
EXPORTED_FUNCTIONS="['_secp256k1_ecmult_gen_prec_table', '_secp256k1_pre_g', '_free', '_malloc', '_ecdh', '_generator_generate', '_generator_generate_blinded', '_pedersen_blind_generator_blind_sum', '_pedersen_commitment', '_rangeproof_sign', '_rangeproof_info', '_rangeproof_verify', '_rangeproof_rewind', '_surjectionproof_initialize', '_surjectionproof_generate', '_surjectionproof_verify', '_ec_seckey_negate', '_ec_seckey_tweak_add', '_ec_seckey_tweak_sub', '_ec_seckey_tweak_mul', '_ec_is_point', '_ec_point_compress', '_ec_point_from_scalar', '_ec_x_only_point_tweak_add', '_ec_sign_ecdsa', '_ec_verify_ecdsa', '_ec_sign_schnorr', '_ec_verify_schnorr', '_ec_seckey_verify']"

SECP256K1_SOURCE_DIR=secp256k1-zkp

Expand All @@ -22,7 +22,7 @@ cd ${SECP256K1_SOURCE_DIR}
./autogen.sh

# Compile secp256k1 to bitcode
emconfigure ./configure --enable-tests=no --enable-module-rangeproof=yes --enable-module-surjectionproof=yes --enable-experimental=yes --enable-module-generator=yes --enable-module-schnorrsig=yes --enable-module-extrakeys=yes --enable-module-ecdh=yes
emconfigure ./configure --enable-tests=no --enable-exhaustive-tests=no --enable-benchmark=no --enable-module-rangeproof=yes --enable-module-surjectionproof=yes --enable-experimental=yes --enable-module-generator=yes --enable-module-schnorrsig=yes --enable-module-extrakeys=yes --enable-module-ecdh=yes
emmake make -j $num_jobs

# go back to the root folder
Expand All @@ -33,13 +33,13 @@ mkdir -p dist

# Compile to wasm
emcc -O$OPTIMIZATION_LEVEL \
-s "EXTRA_EXPORTED_RUNTIME_METHODS=${EXTRA_EXPORTED_RUNTIME_METHODS}" \
-s "EXPORTED_RUNTIME_METHODS=${EXPORTED_RUNTIME_METHODS}" \
-s "EXPORTED_FUNCTIONS=${EXPORTED_FUNCTIONS}" \
-s NO_FILESYSTEM=1 \
-s MODULARIZE=1 \
-s SINGLE_FILE=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-I${SECP256K1_SOURCE_DIR}/include -L${SECP256K1_SOURCE_DIR}/.libs -lsecp256k1 \
-I${SECP256K1_SOURCE_DIR}/include \
${SECP256K1_SOURCE_DIR}/src/*.o \
./main.c \
"${SECP256K1_SOURCE_DIR}/src/libsecp256k1_la-secp256k1.o" \
-o ./dist/secp256k1-zkp.js

0 comments on commit e48d9b2

Please sign in to comment.