forked from cyph/ntru.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·67 lines (59 loc) · 2.13 KB
/
Makefile
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
58
59
60
61
62
63
64
65
66
67
all:
rm -rf dist NTRUEncrypt libsodium 2> /dev/null
mkdir dist
git clone --depth 1 -b stable https://github.com/jedisct1/libsodium
cd libsodium ; emconfigure ./configure --enable-minimal --disable-shared
git clone --depth 1 https://github.com/NTRUOpenSourceProject/NTRUEncrypt
bash -c ' \
args="$$(echo " \
-s SINGLE_FILE=1 \
-DPARAMS=NTRU_EES743EP1 \
-s TOTAL_MEMORY=16777216 -s TOTAL_STACK=8388608 \
-s NO_DYNAMIC_EXECUTION=1 -s ASSERTIONS=0 \
-s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ALIASING_FUNCTION_POINTERS=1 \
-s FUNCTION_POINTER_ALIGNMENT=1 -s DISABLE_EXCEPTION_CATCHING=1 \
-s RESERVED_FUNCTION_POINTERS=8 -s NO_FILESYSTEM=1 \
-Ilibsodium/src/libsodium/include/sodium \
-INTRUEncrypt/include -INTRUEncrypt/src \
libsodium/src/libsodium/randombytes/randombytes.c \
$$(ls NTRUEncrypt/src/*.c | grep -v _simd.c | grep -v _32.c | grep -v _64.c) \
ntru.c \
-s EXPORTED_FUNCTIONS=\"[ \
'"'"'_ntrujs_init'"'"', \
'"'"'_ntrujs_keypair'"'"', \
'"'"'_ntrujs_encrypt'"'"', \
'"'"'_ntrujs_decrypt'"'"', \
'"'"'_ntrujs_public_key_bytes'"'"', \
'"'"'_ntrujs_private_key_bytes'"'"', \
'"'"'_ntrujs_encrypted_bytes'"'"', \
'"'"'_ntrujs_decrypted_bytes'"'"' \
]\" \
" | perl -pe "s/\s+/ /g" | perl -pe "s/\[ /\[/g" | perl -pe "s/ \]/\]/g")"; \
\
bash -c "emcc -Oz -s RUNNING_JS_OPTS=1 -s NO_EXIT_RUNTIME=1 $$args -o dist/ntru.asm.js"; \
bash -c "emcc -O3 -s WASM=1 $$args -o dist/ntru.wasm.js"; \
'
cp pre.js dist/ntru.tmp.js
echo " \
var finalModule; \
var moduleReady = Promise.resolve().then(function () { \
" >> dist/ntru.tmp.js
cat dist/ntru.wasm.js >> dist/ntru.tmp.js
echo " \
return Module['wasmReady'].then(function () { \
finalModule = Module; \
});\
}).catch(function () { \
" >> dist/ntru.tmp.js
cat dist/ntru.asm.js >> dist/ntru.tmp.js
echo " \
finalModule = Module; \
}); \
" >> dist/ntru.tmp.js
cat post.js >> dist/ntru.tmp.js
uglifyjs dist/ntru.tmp.js -cmo dist/ntru.js
sed -i 's|use asm||g' dist/ntru.js
sed -i 's|require(|eval("require")(|g' dist/ntru.js
rm -rf NTRUEncrypt libsodium dist/ntru.*.js
clean:
rm -rf dist NTRUEncrypt libsodium