diff --git a/build.gradle.kts b/build.gradle.kts index fdfb0b0..8d2dec8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.dokka.Platform plugins { - kotlin("multiplatform") version "1.5.31" - id("org.jetbrains.dokka") version "1.5.30" + kotlin("multiplatform") version "1.6.21" + id("org.jetbrains.dokka") version "1.6.21" `maven-publish` } @@ -15,14 +15,14 @@ buildscript { } dependencies { - classpath("com.android.tools.build:gradle:4.0.2") - classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.5.30") + classpath("com.android.tools.build:gradle:4.2.2") + classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.6.21") } } allprojects { group = "fr.acinq.secp256k1" - version = "0.6.5-SNAPSHOT" + version = "0.7.0-SNAPSHOT" repositories { google() @@ -69,7 +69,7 @@ kotlin { } sourceSets.all { - languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn") + languageSettings.optIn("kotlin.RequiresOptIn") } } diff --git a/gradle.properties b/gradle.properties index 3feb490..898869e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,8 @@ org.gradle.parallel = true # kotlin kotlin.code.style = official -kotlin.incremental.multiplatform = true -kotlin.parallel.tasks.in.project = true -#kotlin.mpp.enableGranularSourceSetsMetadata = true -kotlin.native.enableDependencyPropagation = false kotlin.native.ignoreDisabledTargets = true - -# https://github.com/gradle/gradle/issues/11412 -systemProp.org.gradle.internal.publish.checksums.insecure = true +kotlin.mpp.enableCInteropCommonization=true # Android android.useAndroidX = true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 490fda8..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8cf6eb5..5116c5b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7..4f906e0 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index 62bd9b9..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,103 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jni/android/build.gradle.kts b/jni/android/build.gradle.kts index 2243607..28996b7 100644 --- a/jni/android/build.gradle.kts +++ b/jni/android/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.dokka.Platform - plugins { id("com.android.library") kotlin("android") @@ -32,7 +30,7 @@ android { externalNativeBuild { cmake { - setPath("src/main/CMakeLists.txt") + path("src/main/CMakeLists.txt") } } ndkVersion = "21.4.7075529" diff --git a/jni/build.gradle.kts b/jni/build.gradle.kts index 613ed86..0f434aa 100644 --- a/jni/build.gradle.kts +++ b/jni/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.dokka.Platform - plugins { kotlin("jvm") id("org.jetbrains.dokka") @@ -22,7 +20,7 @@ dependencies { val generateHeaders by tasks.creating(JavaCompile::class) { group = "build" classpath = sourceSets["main"].compileClasspath - destinationDir = file("${buildDir}/generated/jni") + destinationDirectory.set(file("${buildDir}/generated/jni")) source = sourceSets["main"].java options.compilerArgs = listOf( "-h", file("${buildDir}/generated/jni").absolutePath, diff --git a/jni/src/main/java/fr/acinq/secp256k1/Secp256k1CFunctions.java b/jni/src/main/java/fr/acinq/secp256k1/Secp256k1CFunctions.java index 2078ca1..d82a294 100644 --- a/jni/src/main/java/fr/acinq/secp256k1/Secp256k1CFunctions.java +++ b/jni/src/main/java/fr/acinq/secp256k1/Secp256k1CFunctions.java @@ -5,29 +5,29 @@ public class Secp256k1CFunctions { * All flags' lower 8 bits indicate what they're for. Do not use directly. */ public static int SECP256K1_FLAGS_TYPE_MASK = ((1 << 8) - 1); - public static int SECP256K1_FLAGS_TYPE_CONTEXT = (1 << 0); - public static int SECP256K1_FLAGS_TYPE_COMPRESSION = (1 << 1); + public static final int SECP256K1_FLAGS_TYPE_CONTEXT = (1 << 0); + public static final int SECP256K1_FLAGS_TYPE_COMPRESSION = (1 << 1); /** * The higher bits contain the actual data. Do not use directly. */ - public static int SECP256K1_FLAGS_BIT_CONTEXT_VERIFY = (1 << 8); - public static int SECP256K1_FLAGS_BIT_CONTEXT_SIGN = (1 << 9); - public static int SECP256K1_FLAGS_BIT_COMPRESSION = (1 << 8); + public static final int SECP256K1_FLAGS_BIT_CONTEXT_VERIFY = (1 << 8); + public static final int SECP256K1_FLAGS_BIT_CONTEXT_SIGN = (1 << 9); + public static final int SECP256K1_FLAGS_BIT_COMPRESSION = (1 << 8); /** * Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and * secp256k1_context_preallocated_create. */ - public static int SECP256K1_CONTEXT_VERIFY = (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_VERIFY); - public static int SECP256K1_CONTEXT_SIGN = (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_SIGN); - public static int SECP256K1_CONTEXT_NONE = (SECP256K1_FLAGS_TYPE_CONTEXT); + public static final int SECP256K1_CONTEXT_VERIFY = (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_VERIFY); + public static final int SECP256K1_CONTEXT_SIGN = (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_SIGN); + public static final int SECP256K1_CONTEXT_NONE = (SECP256K1_FLAGS_TYPE_CONTEXT); /** * Flag to pass to secp256k1_ec_pubkey_serialize. */ - public static int SECP256K1_EC_COMPRESSED = (SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BIT_COMPRESSION); - public static int SECP256K1_EC_UNCOMPRESSED = (SECP256K1_FLAGS_TYPE_COMPRESSION); + public static final int SECP256K1_EC_COMPRESSED = (SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BIT_COMPRESSION); + public static final int SECP256K1_EC_UNCOMPRESSED = (SECP256K1_FLAGS_TYPE_COMPRESSION); public static native long secp256k1_context_create(int flags); diff --git a/settings.gradle.kts b/settings.gradle.kts index a375d68..086595c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,7 +2,6 @@ pluginManagement { repositories { google() gradlePluginPortal() - jcenter() } } rootProject.name = "secp256k1-kmp" diff --git a/src/commonMain/kotlin/fr/acinq/secp256k1/Secp256k1.kt b/src/commonMain/kotlin/fr/acinq/secp256k1/Secp256k1.kt index dafa4df..8911051 100644 --- a/src/commonMain/kotlin/fr/acinq/secp256k1/Secp256k1.kt +++ b/src/commonMain/kotlin/fr/acinq/secp256k1/Secp256k1.kt @@ -41,16 +41,16 @@ public interface Secp256k1 { * Verify a Schnorr signature. * * @param signature 64 bytes signature. - * @param message message signed. - * @param pubkey signer's x-only public key (32 bytes). + * @param data message signed. + * @param pub signer's x-only public key (32 bytes). */ public fun verifySchnorr(signature: ByteArray, data: ByteArray, pub: ByteArray): Boolean /** * Create a Schnorr signature. * - * @param message message to sign. - * @param privkey signer's private key. + * @param data message to sign. + * @param sec signer's private key. * @param auxrand32 32 bytes of fresh randomness (optional). */ public fun signSchnorr(data: ByteArray, sec: ByteArray, auxrand32: ByteArray?): ByteArray