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
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
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
uses: actions/setup-java@v1
with:
@@ -35,11 +64,6 @@ jobs:
- name: Install Automake
if: matrix.os == 'macOS-latest'
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
shell: bash
run: ./gradlew jvmTest
@@ -56,7 +80,7 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
ndk: 21.3.6528147
ndk: ${{ env.ANDROID_NDK_VERSION }}
cmake: 3.10.2.4988404
script: ./gradlew connectedCheck
- name: Publish Linux

View File

@@ -36,6 +36,35 @@ jobs:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
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
uses: actions/setup-java@v1
with:
@@ -43,11 +72,6 @@ jobs:
- name: Install Automake
if: matrix.os == 'macOS-latest'
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
shell: bash
run: ./gradlew jvmTest
@@ -64,7 +88,7 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
ndk: 21.3.6528147
ndk: ${{ env.ANDROID_NDK_VERSION }}
cmake: 3.10.2.4988404
script: ./gradlew connectedCheck
- name: Publish Linux

View File

@@ -42,6 +42,35 @@ jobs:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
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
uses: actions/setup-java@v1
with:
@@ -49,11 +78,6 @@ jobs:
- name: Install Automake
if: matrix.os == 'macOS-latest'
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
shell: bash
run: ./gradlew jvmTest
@@ -70,6 +94,6 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
ndk: 21.3.6528147
ndk: ${{ env.ANDROID_NDK_VERSION }}
cmake: 3.10.2.4988404
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.impl.auth.BasicScheme
import org.apache.http.auth.UsernamePasswordCredentials
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform") version "1.4.0"
kotlin("multiplatform") version "1.4.31"
`maven-publish`
}
buildscript {
repositories {
google()
maven("https://dl.bintray.com/kotlin/kotlin-eap")
jcenter()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.0")
classpath("com.android.tools.build:gradle:4.0.2")
}
}
allprojects {
group = "fr.acinq.secp256k1"
version = "0.3.0-1.4"
version = "0.5.0"
repositories {
jcenter()
google()
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
}
}
val currentOs = org.gradle.internal.os.OperatingSystem.current()
val currentOs = OperatingSystem.current()
kotlin {
explicitApi()
val commonMain by sourceSets.getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val commonMain by sourceSets.getting
jvm {
compilations.all {
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 {
val libsecp256k1 by creating {
includeDirs.headerFilterOnly(project.file("native/secp256k1/include/"))
@@ -66,16 +59,16 @@ kotlin {
linuxX64("linux") {
secp256k1CInterop("host")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
// https://youtrack.jetbrains.com/issue/KT-39396
compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/linux/libsecp256k1.a")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
}
ios {
secp256k1CInterop("ios")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
// https://youtrack.jetbrains.com/issue/KT-39396
compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/ios/libsecp256k1.a")
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
}
sourceSets.all {
@@ -88,13 +81,13 @@ kotlin {
allprojects {
plugins.withId("org.jetbrains.kotlin.multiplatform") {
afterEvaluate {
val currentOs = org.gradle.internal.os.OperatingSystem.current()
val currentOs = OperatingSystem.current()
val targets = when {
currentOs.isLinux -> listOf()
currentOs.isMacOsX -> listOf("linux")
currentOs.isWindows -> 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) {
compilations.all {
@@ -189,12 +182,14 @@ if (hasBintray) {
}
}
afterEvaluate {
tasks.withType<AbstractTestTask>() {
testLogging {
events("passed", "skipped", "failed", "standard_out", "standard_error")
showExceptions = true
showStackTraces = true
allprojects {
afterEvaluate {
tasks.withType<AbstractTestTask>() {
testLogging {
events("passed", "skipped", "failed", "standard_out", "standard_error")
showExceptions = true
showStackTraces = true
}
}
}
}

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
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
zipStorePath=wrapper/dists

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -79,7 +79,7 @@ public object Secp256k1Native : Secp256k1 {
}
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 {
val nSig = allocSignature(sig)
val isHighS = secp256k1_ecdsa_signature_normalize(ctx, nSig.ptr, nSig.ptr)

View File

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