Skip to content

Commit 5df5e86

Browse files
committed
Move to secp256k1-coinlib for Linux, Web and Android
1 parent a421157 commit 5df5e86

File tree

11 files changed

+85
-72
lines changed

11 files changed

+85
-72
lines changed

coinlib/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 5.0.0 WIP
2+
3+
Requires a rebuild of the secp256k1 library as it has moved to the
4+
secp256k1-coinlib fork.
5+
16
## 4.1.0
27

38
`CoinSelection` now works for `TaprootKeyInput` and

coinlib/bin/build_linux.dart

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,32 @@ String dockerfile = r"""
77
FROM debian:bookworm
88
99
# Install dependenices
10-
RUN apt-get update -y \
11-
&& apt-get install -y autoconf libtool build-essential git
10+
RUN apt-get update -y && apt-get install -y cmake git
1211
13-
# Clone libsecp256k1.
14-
# Could use secp256k1 already in code-base but this makes the dockerfile more
15-
# independent and avoids complexity of copying everything into the correct
16-
# context. It's not a large library to download.
17-
# Use 0.5.0 release
18-
RUN git clone https://github.com/bitcoin-core/secp256k1 \
19-
&& cd secp256k1 \
20-
&& git checkout e3a885d42a7800c1ccebad94ad1e2b82c4df5c65
12+
# Clone libsecp256k1-coinlib v0.7.0
13+
RUN git clone https://github.com/peercoin/secp256k1-coinlib \
14+
&& cd secp256k1-coinlib \
15+
&& git checkout 69018e5b939d8d540ca6b237945100f4ecb5681e
2116
22-
WORKDIR /secp256k1
17+
WORKDIR /secp256k1-coinlib
2318
2419
# Build shared library for linux
25-
RUN ./autogen.sh
26-
RUN ./configure \
27-
--enable-module-recovery --disable-tests \
28-
--disable-exhaustive-tests --disable-benchmark \
29-
CFLAGS="-O2"
30-
RUN make
20+
RUN cmake -B build \
21+
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
22+
-DSECP256K1_BUILD_TESTS=OFF \
23+
-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
24+
-DSECP256K1_BUILD_BENCHMARK=OFF \
25+
-DSECP256K1_BUILD_EXAMPLES=OFF \
26+
-DSECP256K1_BUILD_CTIME_TESTS=OFF \
27+
-DCMAKE_BUILD_TYPE=Release
28+
RUN cmake --build build
3129
3230
# Build shared library into /usr/local/lib as usual and then copy into output
3331
# Unused symbols could be stripped. But for future ease, all symbols are
3432
# maintained.
35-
RUN make install
33+
RUN cmake --install build
3634
RUN mkdir output
37-
RUN cp /usr/local/lib/libsecp256k1.so.2.2.0 output/libsecp256k1.so
35+
RUN cp /usr/local/lib/libsecp256k1.so.6.0.0 output/libsecp256k1.so
3836
""";
3937

4038
void main() async {

coinlib/bin/build_wasm.dart

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,42 @@ String dockerfile = r"""
1010
FROM debian:bookworm
1111
1212
# Install dependenices
13-
RUN apt-get update -y \
14-
&& apt-get install -y autoconf libtool build-essential git wget
13+
RUN apt-get update -y && apt-get install -y cmake git wget
1514
1615
# Download and install wasi-sdk
1716
18-
ENV WASI_VERSION=19
17+
ENV WASI_VERSION=27
1918
ENV WASI_VERSION_FULL=${WASI_VERSION}.0
20-
ENV WASI_SDK_PATH=/wasi-sdk-${WASI_VERSION_FULL}
21-
ENV WASI_ARCHIVE=wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
19+
ENV WASI_SDK_PATH=/wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux
20+
ENV WASI_ARCHIVE=wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux.tar.gz
2221
2322
RUN wget -nv https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/$WASI_ARCHIVE
2423
RUN tar xvf $WASI_ARCHIVE
2524
RUN rm $WASI_ARCHIVE
2625
27-
# Clone libsecp256k1 and use v0.5.0
28-
RUN git clone https://github.com/bitcoin-core/secp256k1 \
29-
&& cd secp256k1 \
30-
&& git checkout e3a885d42a7800c1ccebad94ad1e2b82c4df5c65
31-
WORKDIR /secp256k1
26+
# Clone secp256k1-coinlib and use v0.7.0
27+
RUN git clone https://github.com/peercoin/secp256k1-coinlib \
28+
&& cd secp256k1-coinlib \
29+
&& git checkout 69018e5b939d8d540ca6b237945100f4ecb5681e
30+
WORKDIR /secp256k1-coinlib
3231
3332
# Build using wasi-sdk
34-
RUN ./autogen.sh
35-
RUN ./configure \
36-
--enable-module-recovery --disable-tests --disable-shared \
37-
--disable-exhaustive-tests --disable-benchmark \
38-
--with-sysroot=${WASI_SDK_PATH}/share/wasi-sysroot \
39-
--host=wasm32 --target=wasm32-unknown-wasi \
40-
CFLAGS="-O2 -fPIC" CC=${WASI_SDK_PATH}/bin/clang
41-
RUN make
33+
RUN cmake -B build \
34+
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
35+
-DSECP256K1_BUILD_TESTS=OFF \
36+
-DSECP256K1_DISABLE_SHARED=ON \
37+
-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
38+
-DSECP256K1_BUILD_BENCHMARK=OFF \
39+
-DSECP256K1_BUILD_EXAMPLES=OFF \
40+
-DSECP256K1_BUILD_CTIME_TESTS=OFF \
41+
-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk.cmake \
42+
-DCMAKE_C_FLAGS="-O2 -fPIC" \
43+
-DCMAKE_BUILD_TYPE=Release
44+
RUN cmake --build build
4245
4346
# Link output with wasi standard library and export required functions
47+
# wasm-ld is a bit broken as it requires manual inclusion of necessary symbols
48+
# but it works. Using clang to link would probably be better.
4449
RUN mkdir output
4550
RUN ${WASI_SDK_PATH}/bin/wasm-ld \
4651
-o output/secp256k1.wasm \
@@ -72,15 +77,13 @@ RUN ${WASI_SDK_PATH}/bin/wasm-ld \
7277
--export secp256k1_schnorrsig_sign32 \
7378
--export secp256k1_schnorrsig_verify \
7479
--export secp256k1_ecdh \
75-
# The secp256k1 library object files
76-
src/libsecp256k1_la-secp256k1.o \
77-
src/libsecp256k1_precomputed_la-precomputed_ecmult.o \
78-
src/libsecp256k1_precomputed_la-precomputed_ecmult_gen.o \
80+
# The secp256k1 library file
81+
build/lib/libsecp256k1.a \
7982
# Need to include libc for wasi here as it isn't done for us
8083
${WASI_SDK_PATH}/share/wasi-sysroot/lib/wasm32-wasi/libc.a \
8184
# Need to include another library from clang that isn't included either
8285
# See https://github.com/WebAssembly/wasi-libc/issues/98
83-
${WASI_SDK_PATH}/lib/clang/15.0.7/lib/wasi/libclang_rt.builtins-wasm32.a
86+
${WASI_SDK_PATH}/lib/clang/20/lib/wasm32-unknown-wasi/libclang_rt.builtins.a
8487
""";
8588

8689
void binaryFileToDart(String inPath, String outPath, String name) {

coinlib/lib/src/secp256k1/secp256k1.wasm.g.dart

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

coinlib_flutter/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 5.0.0 WIP
2+
3+
Update to underlying coinlib 5.0.0. Please see the CHANGELOG of coinlib.
4+
15
## 4.0.0
26

37
Update to underlying coinlib 4.0.0. Please see the CHANGELOG of coinlib.

coinlib_flutter/android/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ group 'com.example.coinlib_flutter'
44
version '1.0'
55

66
buildscript {
7-
ext.kotlin_version = "1.8.22"
7+
ext.kotlin_version = "2.2.10"
88
repositories {
99
google()
1010
mavenCentral()
@@ -54,12 +54,12 @@ android {
5454
}
5555

5656
compileOptions {
57-
sourceCompatibility JavaVersion.VERSION_1_8
58-
targetCompatibility JavaVersion.VERSION_1_8
57+
sourceCompatibility JavaVersion.VERSION_17
58+
targetCompatibility JavaVersion.VERSION_17
5959
}
6060

6161
kotlinOptions {
62-
jvmTarget = JavaVersion.VERSION_1_8
62+
jvmTarget = JavaVersion.VERSION_17
6363
}
6464

6565
defaultConfig {

coinlib_flutter/example/android/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ android {
2828
ndkVersion flutter.ndkVersion
2929

3030
compileOptions {
31-
sourceCompatibility JavaVersion.VERSION_1_8
32-
targetCompatibility JavaVersion.VERSION_1_8
31+
sourceCompatibility JavaVersion.VERSION_17
32+
targetCompatibility JavaVersion.VERSION_17
3333
}
3434

3535
kotlinOptions {
36-
jvmTarget = '1.8'
36+
jvmTarget = '17'
3737
}
3838

3939
sourceSets {

coinlib_flutter/example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pluginManagement {
1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
2121
id "com.android.application" version '8.9.0' apply false
22-
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
22+
id "org.jetbrains.kotlin.android" version "2.2.10" apply false
2323
}
2424

2525
include ":app"

coinlib_flutter/example/pubspec.lock

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ packages:
4444
coinlib_flutter:
4545
dependency: "direct main"
4646
description:
47-
name: coinlib_flutter
48-
sha256: "15f385bd11559087e11df73acfdc45d34fef54c7a19b20b598572c7ba9d9d112"
49-
url: "https://pub.dev"
50-
source: hosted
47+
path: ".."
48+
relative: true
49+
source: path
5150
version: "4.0.0"
5251
collection:
5352
dependency: transitive
@@ -93,10 +92,10 @@ packages:
9392
dependency: transitive
9493
description:
9594
name: fake_async
96-
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
95+
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
9796
url: "https://pub.dev"
9897
source: hosted
99-
version: "1.3.2"
98+
version: "1.3.3"
10099
ffi:
101100
dependency: transitive
102101
description:
@@ -143,26 +142,26 @@ packages:
143142
dependency: transitive
144143
description:
145144
name: leak_tracker
146-
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
145+
sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0"
147146
url: "https://pub.dev"
148147
source: hosted
149-
version: "10.0.8"
148+
version: "11.0.1"
150149
leak_tracker_flutter_testing:
151150
dependency: transitive
152151
description:
153152
name: leak_tracker_flutter_testing
154-
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
153+
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
155154
url: "https://pub.dev"
156155
source: hosted
157-
version: "3.0.9"
156+
version: "3.0.10"
158157
leak_tracker_testing:
159158
dependency: transitive
160159
description:
161160
name: leak_tracker_testing
162-
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
161+
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
163162
url: "https://pub.dev"
164163
source: hosted
165-
version: "3.0.1"
164+
version: "3.0.2"
166165
lints:
167166
dependency: transitive
168167
description:
@@ -268,10 +267,10 @@ packages:
268267
dependency: transitive
269268
description:
270269
name: test_api
271-
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
270+
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
272271
url: "https://pub.dev"
273272
source: hosted
274-
version: "0.7.4"
273+
version: "0.7.6"
275274
typed_data:
276275
dependency: transitive
277276
description:
@@ -284,10 +283,10 @@ packages:
284283
dependency: transitive
285284
description:
286285
name: vector_math
287-
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
286+
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
288287
url: "https://pub.dev"
289288
source: hosted
290-
version: "2.1.4"
289+
version: "2.2.0"
291290
vm_service:
292291
dependency: transitive
293292
description:
@@ -305,5 +304,5 @@ packages:
305304
source: hosted
306305
version: "2.0.1"
307306
sdks:
308-
dart: ">=3.7.0 <4.0.0"
307+
dart: ">=3.8.0-0 <4.0.0"
309308
flutter: ">=3.18.0-18.0.pre.54"

coinlib_flutter/example/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ environment:
1010
dependencies:
1111
flutter:
1212
sdk: flutter
13-
coinlib_flutter: ^4.0.0
13+
coinlib_flutter:
14+
path: ../
1415
cupertino_icons: ^1.0.2
1516

1617
dev_dependencies:

0 commit comments

Comments
 (0)