5 Commits

Author SHA1 Message Date
Salomon BRYS
7d22d835a5 Kotlin 1.4.31 (#13)
* Kotlin 1.4.31

* Updated CI add-path disabled command to new more secure environment file.

* Properly setting up Android in CI
2021-03-08 16:50:25 +01:00
sstone
bb25eb21b7 Set version to 0.4.1 2020-09-16 10:40:37 +02:00
sstone
6a67dbe9f6 signatureNormalize: relax check on signature size
Checking that the sig size is >= 64 is enough, this is just a quick check before the actual library method is called.
2020-09-10 20:21:58 +02:00
Salomon BRYS
7272a55b8a Changed deployment artifact-id to secp256k1-kmp (#12)
Co-authored-by: Salomon BRYS <salomon@kodein.net>
2020-09-09 11:00:04 +02:00
Salomon BRYS
d702925e40 Kotlin 1.4.0 (#11)
Co-authored-by: Salomon BRYS <salomon@kodein.net>
2020-08-18 10:52:42 +02:00
16 changed files with 134 additions and 79 deletions

View File

@@ -28,6 +28,35 @@ jobs:
path: ~/.gradle path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle- restore-keys: ${{ runner.os }}-gradle-
- name: Android environment
shell: bash
run: |
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV
echo "ANDROID_NDK_VERSION=21.3.6528147" >> $GITHUB_ENV
- name: Cached Android NDK
uses: actions/cache@v2
with:
path: ${{ format('{0}/ndk/{1}', env.ANDROID_HOME, env.ANDROID_NDK_VERSION) }}
key: ${{ runner.os }}-android-ndk-${{ env.ANDROID_NDK_VERSION }}
- name: Set up shell
if: matrix.os == 'windows-latest'
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm.exe "C:/WINDOWS/system32/bash.EXE"
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Setup Android
if: matrix.os != 'windows-latest'
shell: bash
run: |
$ANDROID_HOME/tools/bin/sdkmanager "ndk;$ANDROID_NDK_VERSION"
- name: Setup Android
if: matrix.os == 'windows-latest'
shell: bash
run: |
$ANDROID_HOME\\tools\\bin\\sdkmanager.bat "ndk;$ANDROID_NDK_VERSION"
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
@@ -35,11 +64,6 @@ jobs:
- name: Install Automake - name: Install Automake
if: matrix.os == 'macOS-latest' if: matrix.os == 'macOS-latest'
run: brew install automake run: brew install automake
- name: Set up shell
if: matrix.os == 'windows-latest'
run: |
echo ::add-path::C:\msys64\usr\bin\
rm.exe "C:/WINDOWS/system32/bash.EXE"
- name: Check JVM - name: Check JVM
shell: bash shell: bash
run: ./gradlew jvmTest run: ./gradlew jvmTest
@@ -56,7 +80,7 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2 uses: reactivecircus/android-emulator-runner@v2
with: with:
api-level: 29 api-level: 29
ndk: 21.3.6528147 ndk: ${{ env.ANDROID_NDK_VERSION }}
cmake: 3.10.2.4988404 cmake: 3.10.2.4988404
script: ./gradlew connectedCheck script: ./gradlew connectedCheck
- name: Publish Linux - name: Publish Linux

View File

@@ -36,6 +36,35 @@ jobs:
path: ~/.gradle path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle- restore-keys: ${{ runner.os }}-gradle-
- name: Android environment
shell: bash
run: |
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV
echo "ANDROID_NDK_VERSION=21.3.6528147" >> $GITHUB_ENV
- name: Cached Android NDK
uses: actions/cache@v2
with:
path: ${{ format('{0}/ndk/{1}', env.ANDROID_HOME, env.ANDROID_NDK_VERSION) }}
key: ${{ runner.os }}-android-ndk-${{ env.ANDROID_NDK_VERSION }}
- name: Set up shell
if: matrix.os == 'windows-latest'
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm.exe "C:/WINDOWS/system32/bash.EXE"
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Setup Android
if: matrix.os != 'windows-latest'
shell: bash
run: |
$ANDROID_HOME/tools/bin/sdkmanager "ndk;$ANDROID_NDK_VERSION"
- name: Setup Android
if: matrix.os == 'windows-latest'
shell: bash
run: |
$ANDROID_HOME\\tools\\bin\\sdkmanager.bat "ndk;$ANDROID_NDK_VERSION"
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
@@ -43,11 +72,6 @@ jobs:
- name: Install Automake - name: Install Automake
if: matrix.os == 'macOS-latest' if: matrix.os == 'macOS-latest'
run: brew install automake run: brew install automake
- name: Set up shell
if: matrix.os == 'windows-latest'
run: |
echo ::add-path::C:\msys64\usr\bin\
rm.exe "C:/WINDOWS/system32/bash.EXE"
- name: Check JVM - name: Check JVM
shell: bash shell: bash
run: ./gradlew jvmTest run: ./gradlew jvmTest
@@ -64,7 +88,7 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2 uses: reactivecircus/android-emulator-runner@v2
with: with:
api-level: 29 api-level: 29
ndk: 21.3.6528147 ndk: ${{ env.ANDROID_NDK_VERSION }}
cmake: 3.10.2.4988404 cmake: 3.10.2.4988404
script: ./gradlew connectedCheck script: ./gradlew connectedCheck
- name: Publish Linux - name: Publish Linux

View File

@@ -42,6 +42,35 @@ jobs:
path: ~/.gradle path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle- restore-keys: ${{ runner.os }}-gradle-
- name: Android environment
shell: bash
run: |
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV
echo "ANDROID_NDK_VERSION=21.3.6528147" >> $GITHUB_ENV
- name: Cached Android NDK
uses: actions/cache@v2
with:
path: ${{ format('{0}/ndk/{1}', env.ANDROID_HOME, env.ANDROID_NDK_VERSION) }}
key: ${{ runner.os }}-android-ndk-${{ env.ANDROID_NDK_VERSION }}
- name: Set up shell
if: matrix.os == 'windows-latest'
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm.exe "C:/WINDOWS/system32/bash.EXE"
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Setup Android
if: matrix.os != 'windows-latest'
shell: bash
run: |
$ANDROID_HOME/tools/bin/sdkmanager "ndk;$ANDROID_NDK_VERSION"
- name: Setup Android
if: matrix.os == 'windows-latest'
shell: bash
run: |
$ANDROID_HOME\\tools\\bin\\sdkmanager.bat "ndk;$ANDROID_NDK_VERSION"
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
@@ -49,11 +78,6 @@ jobs:
- name: Install Automake - name: Install Automake
if: matrix.os == 'macOS-latest' if: matrix.os == 'macOS-latest'
run: brew install automake run: brew install automake
- name: Set up shell
if: matrix.os == 'windows-latest'
run: |
echo ::add-path::C:\msys64\usr\bin\
rm.exe "C:/WINDOWS/system32/bash.EXE"
- name: Check JVM - name: Check JVM
shell: bash shell: bash
run: ./gradlew jvmTest run: ./gradlew jvmTest
@@ -70,6 +94,6 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2 uses: reactivecircus/android-emulator-runner@v2
with: with:
api-level: 29 api-level: 29
ndk: 21.3.6528147 ndk: ${{ env.ANDROID_NDK_VERSION }}
cmake: 3.10.2.4988404 cmake: 3.10.2.4988404
script: ./gradlew connectedCheck script: ./gradlew connectedCheck

View File

@@ -4,56 +4,49 @@ import org.apache.http.entity.ContentType
import org.apache.http.entity.StringEntity import org.apache.http.entity.StringEntity
import org.apache.http.impl.auth.BasicScheme import org.apache.http.impl.auth.BasicScheme
import org.apache.http.auth.UsernamePasswordCredentials import org.apache.http.auth.UsernamePasswordCredentials
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins { plugins {
kotlin("multiplatform") version "1.4.0" kotlin("multiplatform") version "1.4.31"
`maven-publish` `maven-publish`
} }
buildscript { buildscript {
repositories { repositories {
google() google()
maven("https://dl.bintray.com/kotlin/kotlin-eap") mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath("com.android.tools.build:gradle:4.0.0") classpath("com.android.tools.build:gradle:4.0.2")
} }
} }
allprojects { allprojects {
group = "fr.acinq.secp256k1" group = "fr.acinq.secp256k1"
version = "0.3.0-1.4" version = "0.5.0"
repositories { repositories {
jcenter() jcenter()
google() google()
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
} }
} }
val currentOs = org.gradle.internal.os.OperatingSystem.current() val currentOs = OperatingSystem.current()
kotlin { kotlin {
explicitApi() explicitApi()
val commonMain by sourceSets.getting { val commonMain by sourceSets.getting
dependencies {
implementation(kotlin("stdlib-common"))
}
}
jvm { jvm {
compilations.all { compilations.all {
kotlinOptions.jvmTarget = "1.8" kotlinOptions.jvmTarget = "1.8"
} }
compilations["main"].dependencies {
implementation(kotlin("stdlib-jdk8"))
}
} }
fun org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.secp256k1CInterop(target: String) { fun KotlinNativeTarget.secp256k1CInterop(target: String) {
compilations["main"].cinterops { compilations["main"].cinterops {
val libsecp256k1 by creating { val libsecp256k1 by creating {
includeDirs.headerFilterOnly(project.file("native/secp256k1/include/")) includeDirs.headerFilterOnly(project.file("native/secp256k1/include/"))
@@ -66,16 +59,16 @@ kotlin {
linuxX64("linux") { linuxX64("linux") {
secp256k1CInterop("host") secp256k1CInterop("host")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
// https://youtrack.jetbrains.com/issue/KT-39396 // https://youtrack.jetbrains.com/issue/KT-39396
compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/linux/libsecp256k1.a") compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/linux/libsecp256k1.a")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
} }
ios { ios {
secp256k1CInterop("ios") secp256k1CInterop("ios")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
// https://youtrack.jetbrains.com/issue/KT-39396 // https://youtrack.jetbrains.com/issue/KT-39396
compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/ios/libsecp256k1.a") compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/ios/libsecp256k1.a")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
} }
sourceSets.all { sourceSets.all {
@@ -88,13 +81,13 @@ kotlin {
allprojects { allprojects {
plugins.withId("org.jetbrains.kotlin.multiplatform") { plugins.withId("org.jetbrains.kotlin.multiplatform") {
afterEvaluate { afterEvaluate {
val currentOs = org.gradle.internal.os.OperatingSystem.current() val currentOs = OperatingSystem.current()
val targets = when { val targets = when {
currentOs.isLinux -> listOf() currentOs.isLinux -> listOf()
currentOs.isMacOsX -> listOf("linux") currentOs.isMacOsX -> listOf("linux")
currentOs.isWindows -> listOf("linux") currentOs.isWindows -> listOf("linux")
else -> listOf("linux") else -> listOf("linux")
}.mapNotNull { kotlin.targets.findByName(it) as? org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget } }.mapNotNull { kotlin.targets.findByName(it) as? KotlinNativeTarget }
configure(targets) { configure(targets) {
compilations.all { compilations.all {
@@ -189,12 +182,14 @@ if (hasBintray) {
} }
} }
afterEvaluate { allprojects {
tasks.withType<AbstractTestTask>() { afterEvaluate {
testLogging { tasks.withType<AbstractTestTask>() {
events("passed", "skipped", "failed", "standard_out", "standard_error") testLogging {
showExceptions = true events("passed", "skipped", "failed", "standard_out", "standard_error")
showStackTraces = true showExceptions = true
showStackTraces = true
}
} }
} }
} }

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -10,7 +10,6 @@ kotlin {
dependencies { dependencies {
api(project(":jni")) api(project(":jni"))
implementation(kotlin("stdlib-jdk8"))
} }
android { android {
@@ -48,18 +47,12 @@ afterEvaluate {
} }
} }
android { afterEvaluate {
afterEvaluate { publishing {
publishing { publications {
publications { create<MavenPublication>("android") {
create<MavenPublication>("android") { artifactId = "secp256k1-kmp-jni-android"
artifactId = "secp256k1-jni-android" from(components["release"])
from(components["release"])
}
// create<MavenPublication>("androidDebug") {
// artifactId = "secp256k1-jni-android-debug"
// from(components["debug"])
// }
} }
} }
} }

View File

@@ -14,7 +14,6 @@ kotlin {
dependencies { dependencies {
api(rootProject) api(rootProject)
implementation(kotlin("stdlib-jdk8"))
} }
val generateHeaders by tasks.creating(JavaCompile::class) { val generateHeaders by tasks.creating(JavaCompile::class) {
@@ -35,7 +34,7 @@ val generateHeaders by tasks.creating(JavaCompile::class) {
publishing { publishing {
publications { publications {
create<MavenPublication>("jvm") { create<MavenPublication>("jvm") {
artifactId = "secp256k1-jni-common" artifactId = "secp256k1-kmp-jni-common"
from(components["java"]) from(components["java"])
} }
} }

View File

@@ -1,7 +1,6 @@
plugins { plugins {
`java-library` `java-library`
// `maven-publish` `maven-publish`
id("ru.vyarus.pom") version "2.1.0"
} }
dependencies { dependencies {
@@ -13,7 +12,7 @@ dependencies {
publishing { publishing {
publications { publications {
create<MavenPublication>("jvm") { create<MavenPublication>("jvm") {
artifactId = "secp256k1-jni-jvm" artifactId = "secp256k1-kmp-jni-jvm"
from(components["java"]) from(components["java"])
} }
} }

View File

@@ -28,13 +28,12 @@ val buildNativeHost by tasks.creating(Exec::class) {
dependencies { dependencies {
api(project(":jni")) api(project(":jni"))
implementation(kotlin("stdlib-jdk8"))
} }
publishing { publishing {
publications { publications {
create<MavenPublication>("jvm") { create<MavenPublication>("jvm") {
artifactId = "secp256k1-jni-jvm-extract" artifactId = "secp256k1-kmp-jni-jvm-extract"
from(components["java"]) from(components["java"])
} }
} }

View File

@@ -23,7 +23,7 @@ val copyJni by tasks.creating(Sync::class) {
publishing { publishing {
publications { publications {
val pub = create<MavenPublication>("jvm") { val pub = create<MavenPublication>("jvm") {
artifactId = "secp256k1-jni-jvm-darwin" artifactId = "secp256k1-kmp-jni-jvm-darwin"
from(components["java"]) from(components["java"])
} }
if (!org.gradle.internal.os.OperatingSystem.current().isMacOsX) { if (!org.gradle.internal.os.OperatingSystem.current().isMacOsX) {

View File

@@ -23,7 +23,7 @@ val copyJni by tasks.creating(Sync::class) {
publishing { publishing {
publications { publications {
val pub = create<MavenPublication>("jvm") { val pub = create<MavenPublication>("jvm") {
artifactId = "secp256k1-jni-jvm-linux" artifactId = "secp256k1-kmp-jni-jvm-linux"
from(components["java"]) from(components["java"])
} }
if (!org.gradle.internal.os.OperatingSystem.current().isLinux) { if (!org.gradle.internal.os.OperatingSystem.current().isLinux) {

View File

@@ -23,7 +23,7 @@ val copyJni by tasks.creating(Sync::class) {
publishing { publishing {
publications { publications {
val pub = create<MavenPublication>("jvm") { val pub = create<MavenPublication>("jvm") {
artifactId = "secp256k1-jni-jvm-mingw" artifactId = "secp256k1-kmp-jni-jvm-mingw"
from(components["java"]) from(components["java"])
} }
if (!org.gradle.internal.os.OperatingSystem.current().isWindows) { if (!org.gradle.internal.os.OperatingSystem.current().isWindows) {

View File

@@ -1,6 +1,8 @@
import org.gradle.internal.os.OperatingSystem
evaluationDependsOn(":jni:android") evaluationDependsOn(":jni:android")
val currentOs = org.gradle.internal.os.OperatingSystem.current() val currentOs = OperatingSystem.current()
val bash = if (currentOs.isWindows) "bash.exe" else "bash" val bash = if (currentOs.isWindows) "bash.exe" else "bash"
val buildSecp256k1 by tasks.creating { group = "build" } val buildSecp256k1 by tasks.creating { group = "build" }
@@ -13,7 +15,7 @@ val buildSecp256k1Host by tasks.creating(Exec::class) {
currentOs.isLinux -> "linux" currentOs.isLinux -> "linux"
currentOs.isMacOsX -> "darwin" currentOs.isMacOsX -> "darwin"
currentOs.isWindows -> "mingw" currentOs.isWindows -> "mingw"
else -> error("UnsupportedmOS $currentOs") else -> error("Unsupported OS $currentOs")
} }
inputs.files(projectDir.resolve("build.sh")) inputs.files(projectDir.resolve("build.sh"))

View File

@@ -1,12 +1,11 @@
pluginManagement { pluginManagement {
repositories { repositories {
google() google()
maven("https://dl.bintray.com/kotlin/kotlin-eap")
gradlePluginPortal() gradlePluginPortal()
jcenter() jcenter()
} }
} }
rootProject.name = "secp256k1" rootProject.name = "secp256k1-kmp"
include( include(
":native", ":native",
@@ -18,4 +17,4 @@ include(
":jni:jvm:mingw", ":jni:jvm:mingw",
":jni:jvm:all", ":jni:jvm:all",
":tests" ":tests"
) )

View File

@@ -79,7 +79,7 @@ public object Secp256k1Native : Secp256k1 {
} }
public override fun signatureNormalize(sig: ByteArray): Pair<ByteArray, Boolean> { public override fun signatureNormalize(sig: ByteArray): Pair<ByteArray, Boolean> {
require(sig.size == 64 || sig.size in 70..73) require(sig.size >= 64){ "invalid signature ${Hex.encode(sig)}" }
memScoped { memScoped {
val nSig = allocSignature(sig) val nSig = allocSignature(sig)
val isHighS = secp256k1_ecdsa_signature_normalize(ctx, nSig.ptr, nSig.ptr) val isHighS = secp256k1_ecdsa_signature_normalize(ctx, nSig.ptr, nSig.ptr)

View File

@@ -8,7 +8,6 @@ kotlin {
val commonMain by sourceSets.getting { val commonMain by sourceSets.getting {
dependencies { dependencies {
implementation(kotlin("stdlib-common"))
implementation(rootProject) implementation(rootProject)
} }
} }
@@ -23,7 +22,6 @@ kotlin {
kotlinOptions.jvmTarget = "1.8" kotlinOptions.jvmTarget = "1.8"
} }
compilations["main"].dependencies { compilations["main"].dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(project(":jni:jvm:all")) implementation(project(":jni:jvm:all"))
} }
compilations["test"].dependencies { compilations["test"].dependencies {
@@ -36,13 +34,12 @@ kotlin {
kotlinOptions.jvmTarget = "1.8" kotlinOptions.jvmTarget = "1.8"
} }
sourceSets["androidMain"].dependencies { sourceSets["androidMain"].dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(project(":jni:android")) implementation(project(":jni:android"))
} }
sourceSets["androidTest"].dependencies { sourceSets["androidTest"].dependencies {
implementation(kotlin("test-junit")) implementation(kotlin("test-junit"))
implementation("androidx.test.ext:junit:1.1.1") implementation("androidx.test.ext:junit:1.1.2")
implementation("androidx.test.espresso:espresso-core:3.2.0") implementation("androidx.test.espresso:espresso-core:3.3.0")
} }
} }