Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1b32c27
Update copyright year to 2026
sandakersmann May 9, 2026
4862f5c
Merge pull request #41 from sandakersmann/patch-2
peerchemist May 30, 2026
54d55c4
Move to secp256k1-coinlib for Linux, Web and Android
MatthewLM Sep 8, 2025
5386b63
Guess changes required for Windows
MatthewLM Sep 9, 2025
63b00d5
Update macOS and iOS builds for secp256k1-coinlib
MatthewLM Sep 9, 2025
466e1e3
Get MuSig2 aggregation to work for FFI and WASM
MatthewLM Sep 19, 2025
757314b
Make MuSig keys tweakable
MatthewLM Sep 20, 2025
17beac8
Generate public/secret nonces for MuSig2
MatthewLM Sep 22, 2025
c6b84f5
Add nonce aggregation for MuSig
MatthewLM Sep 28, 2025
4102a15
Add partial signing
MatthewLM Sep 30, 2025
660ba46
Verify and add partial signatures to MuSig session
MatthewLM Oct 5, 2025
36d3f89
Add aggregation of MuSig2 signatures including adaptor signatures
MatthewLM Oct 14, 2025
7843dbd
Ensure MuSigPrivate is involved in tests
MatthewLM Oct 15, 2025
47db8d9
Add CHANGELOG for v5 WIP
MatthewLM Oct 15, 2025
3bdbd5e
Prepare coinlib_flutter for testing MuSig2
MatthewLM Oct 16, 2025
7fa944f
Get macOS to work with MuSig and prepare for 5.0.0
MatthewLM Oct 16, 2025
5d1a2dc
Ensure immutability of MuSigPublicKeys.pubKeys set
MatthewLM Oct 20, 2025
965c227
Add InputSequence abstraction for input sequences
MatthewLM Nov 4, 2025
3b90dbd
Add Locktime abstraction
MatthewLM Nov 6, 2025
b733903
Fix WASM heap views after memory growth
peerchemist Jul 5, 2026
8a8126c
fix: build_windows.dart DLL path + add MinGW build script
soosho Jul 15, 2026
80b2883
fix: remove duplicated clone function in build_windows_mingw.dart
soosho Jul 15, 2026
f4bb362
Mention MinGW in README
MatthewLM Jul 16, 2026
760e382
Finalise CHANGELOGs
MatthewLM Jul 16, 2026
32f1561
feat: add BnB algorithm for coin selection
sneurlax Jul 17, 2026
d783e0d
fix: rewrite bnb algo using iteration instead of recursion
sneurlax Jul 17, 2026
28c1303
fix: use Locktime type in BnB coin selection
sneurlax Jul 17, 2026
50e9f9f
android 16KB page sizes
sneurlax Jul 17, 2026
13f2c29
update pointycastle
sneurlax Jul 17, 2026
f5bce70
feat: support extra payload data in transactions (vExtraData)
sneurlax Jul 17, 2026
2932128
add toString and copyWith
sneurlax Jul 17, 2026
998180d
clean up and add toString()s
sneurlax Jul 17, 2026
8247d60
auto format
sneurlax Jul 17, 2026
7800486
auto format
sneurlax Jul 17, 2026
c5ad057
WIP: quick and dirty ltc mweb support
sneurlax Jul 17, 2026
ed2a45f
some mweb related clean up
sneurlax Jul 17, 2026
f373c29
Fix mwebAddress toString
sneurlax Jul 17, 2026
2c2d6e3
feat: basic MWEB transaction read and write
sneurlax Jul 17, 2026
219ebf7
Merge branch 'fix/update-pointycastle' for upstream v5 migration
sneurlax Jul 17, 2026
210d206
Merge branch 'fix/android-16kb-page-sizes' for upstream v5 migration
sneurlax Jul 17, 2026
769b065
Merge branch 'feat/bnb-coin-selection' for upstream v5 migration
sneurlax Jul 17, 2026
7776f82
Merge branch 'feat/extra-data' for upstream v5 migration
sneurlax Jul 17, 2026
b32ee74
Merge branch 'feat/to-string-copy-with' for upstream v5 migration
sneurlax Jul 17, 2026
60dc3fd
Merge branch 'feat/mweb' for upstream v5 migration
sneurlax Jul 17, 2026
27703b2
fix(android): align secp256k1 .so to 16 KB page size
willyfromtheblock Jul 22, 2026
2f623c7
Merge pull request #50 from willyfromtheblock/16kb-align
peerchemist Jul 22, 2026
a153dca
Merge pull request #48 from cypherstack/fix/android-16kb-page-sizes
peerchemist Jul 22, 2026
595ebe7
update pointycastle
sneurlax Jul 17, 2026
96f1d13
Format according to the way Dart wants
MatthewLM Jul 22, 2026
89bae87
Resolve conflicts between formatter and linter
MatthewLM Jul 22, 2026
af98501
Bump coinlib_flutter to v5.0.1
MatthewLM Jul 22, 2026
2bc681e
style: run dart format
sneurlax Jul 23, 2026
eb06f17
chore: merge peercoin/master to resolve formatting conflicts
sneurlax Jul 23, 2026
1b1d53c
style: restore upstream formatting of coinlib_flutter files
sneurlax Jul 23, 2026
517f0b6
chore: merge peercoin/master and resolve vExtraData conflict
sneurlax Jul 23, 2026
eb96bc6
chore: merge updated feat/to-string-copy-with (upstream master + form…
sneurlax Jul 23, 2026
442719d
chore: merge updated feat/extra-data
sneurlax Jul 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/dart-test-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
run: dart pub get
working-directory: ./coinlib

- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .
working-directory: ./coinlib

- name: Analyze project source
run: dart analyze --fatal-infos
working-directory: ./coinlib
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023-2025 Peercoin Developers
Copyright 2023-2026 Peercoin Developers

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
20 changes: 20 additions & 0 deletions coinlib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## 5.0.0

Requires a rebuild of the secp256k1 library as it has moved to the
secp256k1-coinlib fork.

- Adds MuSig2 support with `MuSigPublicKeys` and `MuSigStatefulSigningSession`.
- Includes adaptor signature support when using MuSig2 with
`SchnorrAdaptorSignature`.
- Adds `InputSequence` abstraction for input sequences. Input sequences are now
`0xfffffffe` by default and enforce locktimes.
- Adds `locktimeIsEnforced` to `Transaction` to determine if the locktime is in
effect.
- Adds `Locktime` abstractions for transactions. Transactions have
`.isUnlocked` to determine if the transaction is available for block
inclusion.
- Moves to underlying secp256k1-coinlib.
- Removed dependency to wasm_interop that had a broken js dependency.
- Fixes `extraEntropy` being ignored for `Secp256k1Base.schnorrSign`.
- Adds MinGW build support for Windows

## 4.1.0

`CoinSelection` now works for `TaprootKeyInput` and
Expand Down
5 changes: 3 additions & 2 deletions coinlib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ the root directory of your package which will produce a shared library into
`build/libsecp256k1.dll`. This can also be run in the `coinlib` root directory
via `dart run bin/build_windows.dart`.

Windows builds use the Visual Studio 17 2022 generator. Earlier Visual Studio
toolchains may work by editing `bin/build_windows.dart`.
Windows builds use the Visual Studio 17 2022 generator. Earlier Visual Studio
toolchains may work by editing `bin/build_windows.dart`. MingGW can also be used
with `dart run coinlib:build_windows_mingw`.

### Cross-compiling for Windows from Linux

Expand Down
3 changes: 3 additions & 0 deletions coinlib/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ linter:
- valid_regexps
- require_trailing_commas
- comment_references

formatter:
trailing_commas: preserve
46 changes: 21 additions & 25 deletions coinlib/bin/build_linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,45 @@ String dockerfile = r"""
FROM debian:bookworm

# Install dependenices
RUN apt-get update -y \
&& apt-get install -y autoconf libtool build-essential git
RUN apt-get update -y && apt-get install -y cmake git

# Clone libsecp256k1.
# Could use secp256k1 already in code-base but this makes the dockerfile more
# independent and avoids complexity of copying everything into the correct
# context. It's not a large library to download.
# Use 0.5.0 release
RUN git clone https://github.com/bitcoin-core/secp256k1 \
&& cd secp256k1 \
&& git checkout e3a885d42a7800c1ccebad94ad1e2b82c4df5c65
# Clone libsecp256k1-coinlib v0.7.0
RUN git clone https://github.com/peercoin/secp256k1-coinlib \
&& cd secp256k1-coinlib \
&& git checkout 69018e5b939d8d540ca6b237945100f4ecb5681e

WORKDIR /secp256k1
WORKDIR /secp256k1-coinlib

# Build shared library for linux
RUN ./autogen.sh
RUN ./configure \
--enable-module-recovery --disable-tests \
--disable-exhaustive-tests --disable-benchmark \
CFLAGS="-O2"
RUN make
RUN cmake -B build \
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
-DSECP256K1_BUILD_TESTS=OFF \
-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
-DSECP256K1_BUILD_BENCHMARK=OFF \
-DSECP256K1_BUILD_EXAMPLES=OFF \
-DSECP256K1_BUILD_CTIME_TESTS=OFF \
-DCMAKE_BUILD_TYPE=Release
RUN cmake --build build

# Build shared library into /usr/local/lib as usual and then copy into output
# Unused symbols could be stripped. But for future ease, all symbols are
# maintained.
RUN make install
RUN cmake --install build
RUN mkdir output
RUN cp /usr/local/lib/libsecp256k1.so.2.2.0 output/libsecp256k1.so
RUN cp /usr/local/lib/libsecp256k1.so.6.0.0 output/libsecp256k1.so
""";

void main() async {

String cmd = await getDockerCmd();
print("Using $cmd to run dockerfile");

// Build secp256k1 and copy shared library to build directory
if (!await dockerBuild(
cmd,
dockerfile,
"coinlib_build_secp256k1_linux",
"output/libsecp256k1.so",
cmd,
dockerfile,
"coinlib_build_secp256k1_linux",
"output/libsecp256k1.so",
)) {
exit(1);
}

}
26 changes: 13 additions & 13 deletions coinlib/bin/build_macos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@ import 'util.dart';
/// Build a universal macOS framework for secp256k1 directly on a mac machine

void main() async {

// Clone secp256k1 to temporary directory to keep source clean

final tmpDir = createTmpDir();
print("Building in $tmpDir");
final libDir = "$tmpDir/secp256k1";
final libDir = "$tmpDir/secp256k1-coinlib";

exitOnCode(
await execWithStdio(
"git", ["clone", "https://github.com/bitcoin-core/secp256k1", libDir],
"git",
["clone", "https://github.com/peercoin/secp256k1-coinlib", libDir],
),
"Could not clone secp256k1 to temporary build directory",
"Could not clone secp256k1-coinlib to temporary build directory",
);

// Checkout to 0.5.0 commit
// Checkout to 0.7.0 commit
exitOnCode(
await execWithStdio(
"git", ["checkout", "e3a885d42a7800c1ccebad94ad1e2b82c4df5c65"],
"git",
["checkout", "69018e5b939d8d540ca6b237945100f4ecb5681e"],
workingDir: libDir,
),
"Could not checkout to v0.5.0 commit",
"Could not checkout to v0.7.0 commit",
);

// Generate configure
// Generate configure. Do not move to cmake on macOS yet
exitCode = await execWithStdio("sh", ["./autogen.sh"], workingDir: libDir);
if (exitCode != 0) {
print("Couldn't generate configure for secp256k1");
print("Couldn't generate configure for secp256k1-coinlib");
exit(1);
}

Expand All @@ -48,14 +49,14 @@ void main() async {
workingDir: libDir,
);
if (exitCode != 0) {
print("Failed to configure secp256k1");
print("Failed to configure secp256k1-coinlib");
exit(1);
}

// Run make
exitCode = await execWithStdio("make", [], workingDir: libDir);
if (exitCode != 0) {
print("Failed to make secp256k1");
print("Failed to make secp256k1-coinlib");
exit(1);
}

Expand All @@ -69,8 +70,7 @@ void main() async {
// Copy framework to build directory
final buildDir = "${Directory.current.path}/build";
Directory(buildDir).create();
final libFile = File("$libDir/build/lib/libsecp256k1.2.dylib");
final libFile = File("$libDir/build/lib/libsecp256k1.6.dylib");
await libFile.copy("$buildDir/libsecp256k1.dylib");
print("Created dylib in build directory");

}
78 changes: 48 additions & 30 deletions coinlib/bin/build_wasm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,42 @@ String dockerfile = r"""
FROM debian:bookworm

# Install dependenices
RUN apt-get update -y \
&& apt-get install -y autoconf libtool build-essential git wget
RUN apt-get update -y && apt-get install -y cmake git wget

# Download and install wasi-sdk

ENV WASI_VERSION=19
ENV WASI_VERSION=27
ENV WASI_VERSION_FULL=${WASI_VERSION}.0
ENV WASI_SDK_PATH=/wasi-sdk-${WASI_VERSION_FULL}
ENV WASI_ARCHIVE=wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
ENV WASI_SDK_PATH=/wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux
ENV WASI_ARCHIVE=wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux.tar.gz

RUN wget -nv https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/$WASI_ARCHIVE
RUN tar xvf $WASI_ARCHIVE
RUN rm $WASI_ARCHIVE

# Clone libsecp256k1 and use v0.5.0
RUN git clone https://github.com/bitcoin-core/secp256k1 \
&& cd secp256k1 \
&& git checkout e3a885d42a7800c1ccebad94ad1e2b82c4df5c65
WORKDIR /secp256k1
# Clone secp256k1-coinlib and use v0.7.0
RUN git clone https://github.com/peercoin/secp256k1-coinlib \
&& cd secp256k1-coinlib \
&& git checkout 69018e5b939d8d540ca6b237945100f4ecb5681e
WORKDIR /secp256k1-coinlib

# Build using wasi-sdk
RUN ./autogen.sh
RUN ./configure \
--enable-module-recovery --disable-tests --disable-shared \
--disable-exhaustive-tests --disable-benchmark \
--with-sysroot=${WASI_SDK_PATH}/share/wasi-sysroot \
--host=wasm32 --target=wasm32-unknown-wasi \
CFLAGS="-O2 -fPIC" CC=${WASI_SDK_PATH}/bin/clang
RUN make
RUN cmake -B build \
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
-DSECP256K1_BUILD_TESTS=OFF \
-DSECP256K1_DISABLE_SHARED=ON \
-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
-DSECP256K1_BUILD_BENCHMARK=OFF \
-DSECP256K1_BUILD_EXAMPLES=OFF \
-DSECP256K1_BUILD_CTIME_TESTS=OFF \
-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk.cmake \
-DCMAKE_C_FLAGS="-O2 -fPIC" \
-DCMAKE_BUILD_TYPE=Release
RUN cmake --build build

# Link output with wasi standard library and export required functions
# wasm-ld is a bit broken as it requires manual inclusion of necessary symbols
# but it works. Using clang to link would probably be better.
RUN mkdir output
RUN ${WASI_SDK_PATH}/bin/wasm-ld \
-o output/secp256k1.wasm \
Expand Down Expand Up @@ -69,18 +74,33 @@ RUN ${WASI_SDK_PATH}/bin/wasm-ld \
--export secp256k1_ec_seckey_negate \
--export secp256k1_keypair_create \
--export secp256k1_xonly_pubkey_parse \
--export secp256k1_xonly_pubkey_serialize \
--export secp256k1_schnorrsig_sign32 \
--export secp256k1_schnorrsig_verify \
--export secp256k1_ecdh \
# The secp256k1 library object files
src/libsecp256k1_la-secp256k1.o \
src/libsecp256k1_precomputed_la-precomputed_ecmult.o \
src/libsecp256k1_precomputed_la-precomputed_ecmult_gen.o \
--export secp256k1_ec_pubkey_sort \
--export secp256k1_musig_pubkey_agg \
--export secp256k1_musig_pubkey_xonly_tweak_add \
--export secp256k1_musig_nonce_gen \
--export secp256k1_musig_pubnonce_parse \
--export secp256k1_musig_pubnonce_serialize \
--export secp256k1_musig_nonce_agg \
--export secp256k1_musig_nonce_process \
--export secp256k1_musig_partial_sign \
--export secp256k1_musig_partial_sig_parse \
--export secp256k1_musig_partial_sig_serialize \
--export secp256k1_musig_partial_sig_verify \
--export secp256k1_musig_partial_sig_agg \
--export secp256k1_musig_nonce_parity \
--export secp256k1_musig_adapt \
--export secp256k1_musig_extract_adaptor \
# The secp256k1 library file
build/lib/libsecp256k1.a \
# Need to include libc for wasi here as it isn't done for us
${WASI_SDK_PATH}/share/wasi-sysroot/lib/wasm32-wasi/libc.a \
# Need to include another library from clang that isn't included either
# See https://github.com/WebAssembly/wasi-libc/issues/98
${WASI_SDK_PATH}/lib/clang/15.0.7/lib/wasi/libclang_rt.builtins-wasm32.a
${WASI_SDK_PATH}/lib/clang/20/lib/wasm32-unknown-wasi/libclang_rt.builtins.a
""";

void binaryFileToDart(String inPath, String outPath, String name) {
Expand All @@ -93,7 +113,6 @@ final $name = base64Decode("$b64");""";
}

void main() async {

String cmd = await getDockerCmd();
print("Using $cmd to run dockerfile");

Expand All @@ -103,11 +122,11 @@ void main() async {

// Build secp256k1 to wasm and copy wasm file to tempdir
if (!await dockerRun(
cmd,
dockerfile,
"coinlib_build_secp256k1_wasm",
tmpDir,
"cp output/secp256k1.wasm /host/secp256k1.wasm",
cmd,
dockerfile,
"coinlib_build_secp256k1_wasm",
tmpDir,
"cp output/secp256k1.wasm /host/secp256k1.wasm",
)) {
exit(1);
}
Expand All @@ -119,5 +138,4 @@ void main() async {
"secp256k1WasmData",
);
print("Output secp256k1.wasm.g.dart successfully");

}
Loading
Loading