Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 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
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
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
36 changes: 17 additions & 19 deletions coinlib/bin/build_linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,32 @@ 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 {
Expand Down
22 changes: 11 additions & 11 deletions coinlib/bin/build_macos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ void main() async {

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 +48,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,7 +69,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");

Expand Down
66 changes: 43 additions & 23 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 Down
35 changes: 13 additions & 22 deletions coinlib/bin/build_windows.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
import 'dart:io';
import 'util.dart';

/// Follows bitcoin-core/secp256k1's "Building on Windows" instructions.
/// Follows peercoin/secp256k1-coinlib's "Building on Windows" instructions.
///
/// Runnable in "Developer Command Prompt for VS 2022".

void main() async {

// Make temporary directory.
final workDir = Directory.current.path;
final tmpDir = createTmpDir();

// Clone bitcoin-core/secp256k1.
await execWithStdioWin("git", [
"clone",
"https://github.com/bitcoin-core/secp256k1",
"$tmpDir/secp256k1",
]);
Directory.current = Directory("$tmpDir/secp256k1");
await execWithStdioWin(
"git",
// Use version 0.5.0
["checkout", "e3a885d42a7800c1ccebad94ad1e2b82c4df5c65"],
);

// Build in tmpDir/secp256k1/build.
Directory("build").createSync();
// Clone into tmp directory
final tmpDir = await cloneForWindowsInTmpDir();

// Configure cmake.
await execWithStdioWin("cmake", [
Expand All @@ -38,6 +22,13 @@ void main() async {
"-B",
"build",
"--debug-output",
"-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",
]);

// Build.
Expand All @@ -53,11 +44,11 @@ void main() async {
Directory("$workDir${Platform.pathSeparator}build").createSync();
final dll = File(
"$tmpDir"
"${Platform.pathSeparator}secp256k1"
"${Platform.pathSeparator}secp256k1-coinlib"
"${Platform.pathSeparator}build"
"${Platform.pathSeparator}src"
"${Platform.pathSeparator}bin"
"${Platform.pathSeparator}RelWithDebInfo"
"${Platform.pathSeparator}libsecp256k1-2.dll",
"${Platform.pathSeparator}libsecp256k1-6.dll",
);

print("File exists: ${dll.existsSync()}");
Expand Down
32 changes: 19 additions & 13 deletions coinlib/bin/build_windows_crosscompile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@ import 'docker_util.dart';
/// Build a Windows DLL for secp256k1 using a Dockerfile string.

String dockerfile = r"""
FROM debian:bullseye
FROM debian:bookworm

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

# Clone libsecp256k1 0.5.0 release.
RUN git clone https://github.com/bitcoin-core/secp256k1 \
&& cd secp256k1 \
&& git checkout e3a885d42a7800c1ccebad94ad1e2b82c4df5c65 \
&& mkdir build
# Clone libsecp256k1-coinlib v0.7.0
RUN git clone https://github.com/peercoin/secp256k1-coinlib \
&& cd secp256k1-coinlib \
&& git checkout 69018e5b939d8d540ca6b237945100f4ecb5681e

WORKDIR /secp256k1/build
WORKDIR /secp256k1-coinlib

# Build shared library for Windows.
RUN cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake
RUN make
RUN cmake -B build \
-DCMAKE_TOOLCHAIN_FILE=cmake/x86_64-w64-mingw32.toolchain.cmake \
-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 DLL and copy into output.
RUN make install
RUN cmake --install build
RUN mkdir output
RUN cp src/libsecp256k1-2.dll output/secp256k1.dll
RUN cp build/bin/libsecp256k1-6.dll output/secp256k1.dll
""";

void main() async {
Expand Down
Loading
Loading