forked from bitauth/libauth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecp256k1.Dockerfile
57 lines (49 loc) · 1.87 KB
/
secp256k1.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# FROM trzeci/emscripten-slim:latest
FROM trzeci/emscripten-slim@sha256:e3cd9edf81c5d9cd78d2edf034ce6fcb2dccb35f1f5451e8ce75e5210bbbf036
RUN apt-get update \
&& apt-get install -y \
autoconf \
libtool \
build-essential
COPY wasm /bitcoin-ts/wasm
WORKDIR /bitcoin-ts/wasm/secp256k1
RUN ./autogen.sh
RUN emconfigure ./configure --enable-module-recovery \
# uncomment next line for debug build:
# CFLAGS="-g -O0"
# uncomment next line for production build:
CFLAGS="-O3"
RUN emmake make FORMAT=wasm
RUN mkdir -p out/secp256k1
RUN emcc src/libsecp256k1_la-secp256k1.o \
# uncomment next line for debug build:
# -O0 -g4 -s ASSERTIONS=2 --source-map-base ../../../wasm/secp256k1 \
# uncomment next line for production build:
-O3 \
-s WASM=1 \
-s "BINARYEN_METHOD='native-wasm'" \
-s NO_EXIT_RUNTIME=1 \
-s DETERMINISTIC=1 \
-s EXPORTED_FUNCTIONS='[ \
"_malloc", \
"_free", \
"_secp256k1_context_create", \
"_secp256k1_context_randomize", \
"_secp256k1_ec_seckey_verify", \
"_secp256k1_ec_pubkey_create", \
"_secp256k1_ec_pubkey_parse", \
"_secp256k1_ec_pubkey_serialize", \
"_secp256k1_ecdsa_sign", \
"_secp256k1_ecdsa_signature_malleate", \
"_secp256k1_ecdsa_signature_normalize", \
"_secp256k1_ecdsa_signature_parse_der", \
"_secp256k1_ecdsa_signature_parse_compact", \
"_secp256k1_ecdsa_signature_serialize_der", \
"_secp256k1_ecdsa_signature_serialize_compact", \
"_secp256k1_ecdsa_verify", \
]' \
-o out/secp256k1/secp256k1.js
RUN OUTPUT_TS_FILE=out/secp256k1/secp256k1.base64.ts; printf "/**\n * @hidden\n */\n// prettier-ignore\nexport const secp256k1Base64Bytes =\n '" > $OUTPUT_TS_FILE && base64 -w 0 out/secp256k1/secp256k1.wasm >> $OUTPUT_TS_FILE && printf "';\n" >> $OUTPUT_TS_FILE
RUN cp -r /bitcoin-ts/wasm/secp256k1/out /bitcoin-ts/bin
# copy outputs to mounted volume
CMD ["cp", "-r", "/bitcoin-ts/bin", "/bitcoin-ts/out"]