Use the new Dart Native Assets toolchain for building secp256k1 - #51
Closed
sneurlax wants to merge 10 commits into
Closed
Use the new Dart Native Assets toolchain for building secp256k1#51sneurlax wants to merge 10 commits into
sneurlax wants to merge 10 commits into
Conversation
Vendor the subset of peercoin/secp256k1-coinlib at v0.7.0 (69018e5) needed to compile the shared library: public headers, implementation and the ecdh, extrakeys, musig, recovery and schnorrsig modules. ffigen now uses the headers from third_party instead of the duplicates under include/.
Use native_toolchain_c to compile the vendored sources into a shared library code asset. The configuration matches the previous CMake builds: -O2, the ecdh, extrakeys, musig, recovery and schnorrsig modules, a window size of 15 and the 86 KiB signing table. Requires Dart 3.10, the first release with stable build hooks.
Contributor
Author
|
side benefit: CocoaPods already need to be updated to Swift Package Manager, this will handle that, too. |
The analyzer flags if (stack != null) ...stack under the raised SDK lower bound.
Regenerate the bindings with ffi-native so functions are top-level @Native declarations resolved against the code asset from the build hook. The wrapper no longer loads a prebuilt library from build/ or via DynamicLibrary.open, and the path dependency is removed.
The Docker, CMake and MinGW scripts are superseded by the build hook. The WebAssembly build script and shared helpers remain.
coinlib compiles secp256k1-coinlib through its build hook for each target platform, so the CMake, Gradle and CocoaPods glue is no longer needed and the package becomes a plain Dart package. Requires Dart 3.10 and Flutter 3.38, the first releases with stable build hooks.
Depend on coinlib_flutter and coinlib by path so the example exercises the checked-out code instead of the packages published to pub.dev. The Linux and Windows runners also gain the template step that installs build hook output into the bundle; they were generated before that step existed.
Flutter 3.44 warns that support for Kotlin Gradle Plugin 2.2.10 "will soon be dropped" and asks for at least 2.2.20. Bump the KGP version in the example app's settings.gradle to clear the warning. Verified on Windows: full-ABI release APK builds (arm64-v8a, armeabi-v7a, x86_64), each bundling libsecp256k1.so with 81 exported secp256k1_* symbols, 20 of them secp256k1_musig_*, and no internal symbols leaked. dart analyze --fatal-infos clean, dart test +327. Staged on a -win branch for review on non-Windows hosts before adoption.
Flutter 3.44 warns that support for Android Gradle Plugin 8.9.0 "will soon be dropped" and asks for at least 8.11.1. AGP 8.11 in turn requires Gradle 8.13 or newer, and Flutter separately wants Gradle 8.14, so move the wrapper straight to 8.14. - AGP 8.9.0 -> 8.11.1 - Gradle 8.11.1 -> 8.14 Together with the preceding Kotlin bump this clears every "will soon be dropped" warning the Flutter Android build emits; the build now runs warning-free. Note this is needed on the peercoin lineage too: while that scaffold already carried the Gradle 8.11.1 wrapper and the explicit namespace, its AGP has been pinned at 8.9.0 on every ref including master. Verified on Windows: full-ABI release APK builds (arm64-v8a, armeabi-v7a, x86_64) with an unchanged secp256k1 export surface, and the Windows desktop release build still bundles secp256k1.dll.
sneurlax
force-pushed
the
feat/native-assets
branch
from
September 4, 2026 00:43
47bae12 to
2230923
Compare
Contributor
Author
|
I am going to redo this where instead of vendoring the whole secp256k1 repo, secp256k1 becomes a new package and plugin using native-assets (native_toolchain_cmake or similar) for the build. Then the new version of this PR will retain most of the stripping of build scaffolding (moving it out into a secp256k1 plugin, I'm thinking at this point) but not the huge addition of the secp256k1 codebase in this way |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See https://dart.dev/tools/hooks for more information related to Dart's new Native Assets toolchain: native builds may now be triggered on
dartandfluttercommands viahook/build.dart. Once set up, users won't have to build secp256k1 manually but builds will be triggered on first run.I have only tested on Linux and Android so far: macOS, iOS, Windows, etc to come:Tested: