{"id":13609810,"url":"https://github.com/ACINQ/secp256k1-kmp","last_synced_at":"2025-04-12T20:32:29.538Z","repository":{"id":37975518,"uuid":"275109250","full_name":"ACINQ/secp256k1-kmp","owner":"ACINQ","description":"Kotlin Multi Platform bindings for Bitcoin secp256k1 library.","archived":false,"fork":false,"pushed_at":"2025-03-10T20:04:41.000Z","size":406,"stargazers_count":56,"open_issues_count":1,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-06T07:12:56.756Z","etag":null,"topics":["android","bitcoin","ios","jvm","kotlin","multiplatform","secp256k1"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ACINQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-26T08:31:13.000Z","updated_at":"2025-03-31T14:28:39.000Z","dependencies_parsed_at":"2024-01-11T21:42:18.720Z","dependency_job_id":"c47a2fe7-d9fb-4b12-b95e-70e73117038f","html_url":"https://github.com/ACINQ/secp256k1-kmp","commit_stats":{"total_commits":110,"total_committers":8,"mean_commits":13.75,"dds":0.3545454545454545,"last_synced_commit":"e28303147f764e81443b5cb59c760e6628162116"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ACINQ%2Fsecp256k1-kmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ACINQ%2Fsecp256k1-kmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ACINQ%2Fsecp256k1-kmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ACINQ%2Fsecp256k1-kmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ACINQ","download_url":"https://codeload.github.com/ACINQ/secp256k1-kmp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248630093,"owners_count":21136378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","bitcoin","ios","jvm","kotlin","multiplatform","secp256k1"],"created_at":"2024-08-01T19:01:38.287Z","updated_at":"2025-04-12T20:32:29.532Z","avatar_url":"https://github.com/ACINQ.png","language":"Kotlin","funding_links":[],"categories":["Kotlin","安全"],"sub_categories":["语音合成"],"readme":"[![Kotlin](https://img.shields.io/badge/Kotlin-2.1.10-blue.svg?style=flat\u0026logo=kotlin)](http://kotlinlang.org)\n[![Maven Central](https://img.shields.io/maven-central/v/fr.acinq.secp256k1/secp256k1-kmp)](https://search.maven.org/search?q=g:fr.acinq.secp256k1%20a:secp256k1-kmp*)\n![Github Actions](https://github.com/ACINQ/secp256k1-kmp/actions/workflows/test.yml/badge.svg)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/ACINQ/secp256k1-kmp/blob/master/LICENSE)\n\n# Secp256k1 for Kotlin/Multiplatform\n\nKotlin/Multiplatform wrapper for Bitcoin Core's secp256k1 library. Targets: JVM, Android, iOS \u0026 Linux.\n\n## Installation\n\nsecp256k1-kmp is available on [maven central](https://search.maven.org/search?q=g:fr.acinq.secp256k1%20a:secp256k1-kmp*)\n\nThen, the actual dependency depends on your targeted platform(s):\n\n### Multiplatform\n\nAdd the `secp256k1` dependency to the common sourceSet, and the JNI dependencies to JVM and Android sourcesets:\n\n```kotlin\n// build.gradle.kts\n\nkotlin {\n    jvm()\n    android()\n    linuxX64(\"linux\")\n    ios()\n\n    sourceSets {\n        val commonMain by getting {\n            dependencies {\n                implementation(kotlin(\"stdlib-common\"))\n                implementation(\"fr.acinq.secp256k1:secp256k1-kmp:$secp256k1_version\")\n            }\n        }\n        val jvmMain by getting {\n            dependencies {\n                implementation(kotlin(\"stdlib\"))\n                implementation(\"fr.acinq.secp256k1:secp256k1-kmp-jni-jvm:$secp256k1_version\")\n            }\n        }\n        val androidMain by getting {\n            dependencies {\n                implementation(kotlin(\"stdlib\"))\n                implementation(\"fr.acinq.secp256k1:secp256k1-kmp-jni-android:$secp256k1_version\")\n            }\n        }\n    }\n}\n```\n\n### Native targets (iOS, linux64)\n\nNative targets include libsecp256k1, called through KMP's c-interop, simply add the `fr.acinq.secp256k1:secp256k1` dependency.\n\n### JVM targets \u0026 Android\n\nThe JVM library uses JNI bindings for libsecp256k1, which is much faster than BouncyCastle. It will extract and load native bindings for your operating system in a temporary directory.\n\nJNI libraries are included for:\n- Linux 64 bits (x86_64 and arm64)\n- Windows 64 bits (x86_64)\n- Macos 64 bits (x86_64 and arm64)\n\nAlong this library, you **must** specify which JNI native library to use in your dependency manager:\n\n* **For desktop or server JVMs**, you must add the dependency:\n  * Either the `fr.acinq.secp256k1:secp256k1-kmp-jni-jvm` dependency which imports all supported platforms.\n  * Or the platform specific dependencies (note that you can add multiple as they do not conflict):\n    * `fr.acinq.secp256k1:secp256k1-kmp-jni-jvm-linux` for Linux\n    * `fr.acinq.secp256k1:secp256k1-kmp-jni-jvm-darwin` for Mac OS X\n    * `fr.acinq.secp256k1:secp256k1-kmp-jni-jvm-mingw` for Windows\n* **For Android**, you must add the `fr.acinq.secp256k1:secp256k1-kmp-jni-android` dependency\n\nIf you are using the JVM on an OS for which we don't provide JNI bindings (32 bits OS for example), you can use your own library native library by\nadding the `fr.acinq.secp256k1:secp256k1-kmp-jni-jvm` dependency and specifying its path with `-Dfr.acinq.secp256k1.lib.path` and optionally its name with `-Dfr.acinq.secp256k1.lib.name`\n(if unspecified bitcoink use the standard name for your OS i.e. libsecp256k1.so on Linux, secp256k1.dll on Windows, ...).\n\nTo compile your own JNI bindings, have a look add the `native/build.sh` and `jni/build.sh` scripts.\n\nYou can also specify the temporary directory where the library will be extracted with `-Djava.io.tmpdir` or `-Dfr.acinq.secp256k1.tmpdir`\n(if you want to use a different directory from `-Djava.io.tmpdir`).\n\n## Usage\n\nPlease have a look at unit tests, more samples will be added soon.\n\n## Building\n\n**secp256k1-kmp** is a [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatform.html) wrapper for Bitcoin Core's [secp256k1 library](https://github.com/bitcoin-core/secp256k1).\n\nTo build the library you need the following:\n- Window 64 bits, Linux 64 bits, or MacOs 64 Bits\n- OpenJDK11 (we recommend using packages provided by https://adoptopenjdk.net/ but there are other options)\n- (optional) Android SDK\n\nIt may work with other Operating Systems and JDKs, but then you're on your own (in particular we don't plan to support 32 bits Operating Systems).\nTo build the library and publish compiled artefacts locally (so they can be used by other projects):\n\n```sh\n./gradlew :build\n./gradlew :publishToMavenLocal\n```\n\nTo run all tests on all platforms:\n\n```sh\n./gradlew allTests\n```\n\nTo run tests on a single platform, for example the JVM:\n\n```sh\n./gradlew jvmTest\n```\n\nIf you want to skip building Android artefacts create a `local.properties` file in the project's root directory and add the following line:\n\n```\nskip.android=true\n```\n\n## Contributing to and extending the library\n\nsecp256k1-kmp follows 2 simples rules:\n- copy as literally as possible what the original [secp256k1 library](https://github.com/bitcoin-core/secp256k1) does: use the same function names, parameters, options, ... \n- follow JNI best practices (memory allocation, error handling, ...)\n \n\"Porting\" C/C++ code that uses [secp256k1](https://github.com/bitcoin-core/secp256k1) should be a no-brainer and we should not have to document secp256k1-kmp\n\n\nTo extend this library and support methods that have been added to specific versions of [secp256k1](https://github.com/bitcoin-core/secp256k1) you have to:\n- add new methods to the Secp256k1 interface src/commonMain/kotlin/fr/acinq/secp256k1/Secp256k1.kt (please follow rule #1 above and try and match secp256k1's interface as much as possible)\n- implement these new methods in jni/src/main/kotlin/fr/acinq/secp256k1/NativeSecp256k1.kt (JNI implementation) and src/nativeMain/kotlin/fr/acinq/secp256k1/Secp256k1Native.kt (native linux/ios/... implementation)\n- update the JNI interface src/main/java/fr/acinq/secp256k1/Secp256k1CFunctions.java (NativeSecp256k1 calls Secp256k1CFunctions)\n- generate a new JNI header file jni/c/headers/java/fr_acinq_secp256k1_Secp256k1CFunctions.h with `javac -h jni/c/headers/java jni/src/main/java/fr/acinq/secp256k1/Secp256k1CFunctions.java`\n- implement the new methods in jni/c/src/fr_acinq_secp256k1_Secp256k1CFunctions.c\n\nYou may also need to modify build files if you need to compile [secp256k1](https://github.com/bitcoin-core/secp256k1) with custom options\n\nWe use [secp256k1](https://github.com/bitcoin-core/secp256k1) through git submodules so you may also need to change what they point to\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FACINQ%2Fsecp256k1-kmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FACINQ%2Fsecp256k1-kmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FACINQ%2Fsecp256k1-kmp/lists"}