Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75f45e9191 | ||
|
|
118c72064c | ||
|
|
7af7b7760e | ||
|
|
4df49dd8f6 | ||
|
|
48c3e4723b |
@@ -22,7 +22,7 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "fr.acinq.secp256k1"
|
group = "fr.acinq.secp256k1"
|
||||||
version = "0.6.3"
|
version = "0.6.4"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
|||||||
@@ -307,9 +307,9 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
if (jseckey == NULL) return 0;
|
if (jseckey == NULL) return 0;
|
||||||
CHECKRESULT((*penv)->GetArrayLength(penv, jseckey) != 32, "secret key must be 32 bytes");
|
CHECKRESULT((*penv)->GetArrayLength(penv, jseckey) != 32, "secret key must be 32 bytes");
|
||||||
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
|
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
|
||||||
result = secp256k1_ec_privkey_negate(ctx, (unsigned char*)seckey);
|
result = secp256k1_ec_seckey_negate(ctx, (unsigned char*)seckey);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
|
||||||
CHECKRESULT(!result, "secp256k1_ec_privkey_negate failed");
|
CHECKRESULT(!result, "secp256k1_ec_seckey_negate failed");
|
||||||
return jseckey;
|
return jseckey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,10 +369,10 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
CHECKRESULT((*penv)->GetArrayLength(penv, jtweak) != 32, "tweak must be 32 bytes");
|
CHECKRESULT((*penv)->GetArrayLength(penv, jtweak) != 32, "tweak must be 32 bytes");
|
||||||
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
|
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
|
||||||
tweak = (*penv)->GetByteArrayElements(penv, jtweak, 0);
|
tweak = (*penv)->GetByteArrayElements(penv, jtweak, 0);
|
||||||
result = secp256k1_ec_privkey_tweak_add(ctx, (unsigned char*)seckey, (unsigned char*)tweak);
|
result = secp256k1_ec_seckey_tweak_add(ctx, (unsigned char*)seckey, (unsigned char*)tweak);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jtweak, tweak, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jtweak, tweak, 0);
|
||||||
CHECKRESULT(!result, "secp256k1_ec_privkey_tweak_add failed");
|
CHECKRESULT(!result, "secp256k1_ec_seckey_tweak_add failed");
|
||||||
return jseckey;
|
return jseckey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,8 +437,8 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
CHECKRESULT((*penv)->GetArrayLength(penv, jtweak) != 32, "tweak must be 32 bytes");
|
CHECKRESULT((*penv)->GetArrayLength(penv, jtweak) != 32, "tweak must be 32 bytes");
|
||||||
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
|
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
|
||||||
tweak = (*penv)->GetByteArrayElements(penv, jtweak, 0);
|
tweak = (*penv)->GetByteArrayElements(penv, jtweak, 0);
|
||||||
result = secp256k1_ec_privkey_tweak_mul(ctx, (unsigned char*)seckey, (unsigned char*)tweak);
|
result = secp256k1_ec_seckey_tweak_mul(ctx, (unsigned char*)seckey, (unsigned char*)tweak);
|
||||||
CHECKRESULT(!result, "secp256k1_ec_privkey_tweak_mul failed");
|
CHECKRESULT(!result, "secp256k1_ec_seckey_tweak_mul failed");
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jtweak, tweak, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jtweak, tweak, 0);
|
||||||
return jseckey;
|
return jseckey;
|
||||||
@@ -702,7 +702,7 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
auxrand32 = (*penv)->GetByteArrayElements(penv, jauxrand32, 0);
|
auxrand32 = (*penv)->GetByteArrayElements(penv, jauxrand32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = secp256k1_schnorrsig_sign(ctx, signature, (unsigned char*)msg, &keypair, auxrand32);
|
result = secp256k1_schnorrsig_sign32(ctx, signature, (unsigned char*)msg, &keypair, auxrand32);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jmsg, msg, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jmsg, msg, 0);
|
||||||
if (auxrand32 != 0) {
|
if (auxrand32 != 0) {
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jauxrand32, auxrand32, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jauxrand32, auxrand32, 0);
|
||||||
|
|||||||
Submodule native/secp256k1 updated: 0559fc6e41...8746600eec
42
publishing/PUBLISHING.md
Normal file
42
publishing/PUBLISHING.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Publishing secp256k1-kmp artifacts
|
||||||
|
|
||||||
|
## snapshots
|
||||||
|
|
||||||
|
Snapshots are published to the Sonatype snapshot repository (https://oss.sonatype.org/content/repositories/snapshots/).
|
||||||
|
To publish snapshot, you must add your sonatype credentials for the `ossrh` server to your local maven settings (typically in $HOME/.m2/settings.xml)
|
||||||
|
|
||||||
|
- Download `snapshot.zip` generated by the `Publish snapshot` github action
|
||||||
|
- unzip `snapshot.zip` in the `publishing` directory
|
||||||
|
- add additional JNI bindings (optional, see below)
|
||||||
|
- edit `secp256k1-kmp-snapshot-deploy.sh` and update the `VERSION` environment variable if needed
|
||||||
|
- run `secp256k1-kmp-snapshot-deploy.sh`
|
||||||
|
|
||||||
|
## releases
|
||||||
|
|
||||||
|
Releases are published to the Sonatype staging repository. If all items are valid they will be published to `maven central` repository.
|
||||||
|
You must edit `secp256k1-kmp-staging-upload.sh` and add your sonatype credentials. You must also have a valid GPG key.
|
||||||
|
|
||||||
|
- Download `release.zip` generated by the `Publish release` github action (which is triggered every time you publish a github release)
|
||||||
|
- unzip `release.zip` in the `publishing` directory
|
||||||
|
- add additional JNI bindings (optional, see below)
|
||||||
|
- edit `secp256k1-kmp-staging-upload.sh` and update the `VERSION` environment variable if needed
|
||||||
|
- sign all artifacts with a valid gpg key: `find release -type f -print -exec gpg -ab {} \;`
|
||||||
|
- run `secp256k1-kmp-staging-upload.sh`
|
||||||
|
- log into sonatype, close and publish your staging repository. Artifacts will be available on Maven Central within a few hours.
|
||||||
|
|
||||||
|
## Adding custom JNI bindings
|
||||||
|
|
||||||
|
Github CI currently generates JNI bindings for Windows x64, Linux x64 and iOS x64. But it is possible to add custom bindings to JNI packages before
|
||||||
|
they are published to maven central. This is how we add linux arm64 bindings:
|
||||||
|
- compile JNI bindings for Linux Arm64 (on a Linux Arm64 machine, cross-compilation is not supported)
|
||||||
|
- git clone --recursive https://github.com/ACINQ/secp256k1-kmp.git
|
||||||
|
- cd secp256k1-kmp
|
||||||
|
- TARGET=linux ./native/build.sh
|
||||||
|
- mkdir -p jni/jvm/build/linux
|
||||||
|
- TARGET=linux ./jni/jvm/build.sh
|
||||||
|
- JNI library is: jni/jvm/build/linux/libsecp256k1-jni.so
|
||||||
|
- copy libsecp256k1-jni.so to fr/acinq/secp256k1/jni/native/linux-aarch64/libsecp256k1-jni.so
|
||||||
|
- run `secp256k1-kmp-add-linuxarm64.sh` and specify either `release` or `snapshot` and the `VERSION` environment variable, for example:
|
||||||
|
- VERSION=0.6.4-SNAPSHOT ./secp256k1-kmp-add-linuxarm64.sh snapshot
|
||||||
|
- VERSION=0.6.3 ./secp256k1-kmp-add-linuxarm64.sh release
|
||||||
|
|
||||||
17
publishing/secp256k1-kmp-add-linuxarm64.sh
Executable file
17
publishing/secp256k1-kmp-add-linuxarm64.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "specify either snapshot or release"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add aarch64 (ARM64) library to the linux jar
|
||||||
|
if [ -e fr/acinq/secp256k1/jni/native/linux-aarch64/libsecp256k1-jni.so ]
|
||||||
|
then
|
||||||
|
jar -uf $1/fr/acinq/secp256k1/secp256k1-kmp-jni-jvm-linux/$VERSION/secp256k1-kmp-jni-jvm-linux-$VERSION.jar fr || exit
|
||||||
|
else
|
||||||
|
libsecp256k1-jni.so for arch64 is missing
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
53
publishing/secp256k1-kmp-snapshot-deploy.sh
Executable file
53
publishing/secp256k1-kmp-snapshot-deploy.sh
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
GROUP_ID=fr.acinq.secp256k1
|
||||||
|
ARTIFACT_ID_BASE=secp256k1-kmp
|
||||||
|
VERSION=0.6.3-SNAPSHOT
|
||||||
|
|
||||||
|
cd snapshot
|
||||||
|
pushd .
|
||||||
|
cd fr/acinq/secp256k1/secp256k1-kmp/$VERSION
|
||||||
|
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
|
||||||
|
-DpomFile=$ARTIFACT_ID_BASE-$VERSION.pom \
|
||||||
|
-Dfile=$ARTIFACT_ID_BASE-$VERSION.jar \
|
||||||
|
-Dfiles=$ARTIFACT_ID_BASE-$VERSION.module,$ARTIFACT_ID_BASE-$VERSION-kotlin-tooling-metadata.json \
|
||||||
|
-Dtypes=module,json \
|
||||||
|
-Dclassifiers=,kotlin-tooling-metadata \
|
||||||
|
-Dsources=$ARTIFACT_ID_BASE-$VERSION-sources.jar \
|
||||||
|
-Djavadoc=$ARTIFACT_ID_BASE-$VERSION-javadoc.jar
|
||||||
|
popd
|
||||||
|
pushd .
|
||||||
|
for i in iosarm64 iosx64 jni-android jni-common jni-jvm-darwin jni-jvm-extract jni-jvm-linux jni-jvm-mingw jni-jvm jvm linux
|
||||||
|
do
|
||||||
|
cd fr/acinq/secp256k1/secp256k1-kmp-$i/$VERSION
|
||||||
|
if [ $i == iosarm64 ] || [ $i == iosx64 ] || [ $i == linux ]; then
|
||||||
|
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
|
||||||
|
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
|
||||||
|
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
|
||||||
|
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module,$ARTIFACT_ID_BASE-$i-$VERSION-cinterop-libsecp256k1.klib \
|
||||||
|
-Dtypes=module,klib \
|
||||||
|
-Dclassifiers=,cinterop-libsecp256k1 \
|
||||||
|
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
|
||||||
|
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
|
||||||
|
elif [ $i == jni-android ]; then
|
||||||
|
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
|
||||||
|
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
|
||||||
|
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.aar \
|
||||||
|
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
|
||||||
|
-Dtypes=module \
|
||||||
|
-Dclassifiers= \
|
||||||
|
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
|
||||||
|
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
|
||||||
|
else
|
||||||
|
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
|
||||||
|
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
|
||||||
|
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.jar \
|
||||||
|
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
|
||||||
|
-Dtypes=module \
|
||||||
|
-Dclassifiers= \
|
||||||
|
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
|
||||||
|
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
pushd .
|
||||||
|
done
|
||||||
28
publishing/secp256k1-kmp-staging-upload.sh
Executable file
28
publishing/secp256k1-kmp-staging-upload.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
#
|
||||||
|
# first you must sign all files:
|
||||||
|
# find release -type f -print -exec gpg -ab {} \;
|
||||||
|
|
||||||
|
VERSION=0.6.2
|
||||||
|
for i in secp256k1-kmp \
|
||||||
|
secp256k1-kmp-iosarm64 \
|
||||||
|
secp256k1-kmp-iosx64 \
|
||||||
|
secp256k1-kmp-jni-android \
|
||||||
|
secp256k1-kmp-jni-common \
|
||||||
|
secp256k1-kmp-jni-jvm \
|
||||||
|
secp256k1-kmp-jni-jvm-darwin \
|
||||||
|
secp256k1-kmp-jni-jvm-extract \
|
||||||
|
secp256k1-kmp-jni-jvm-linux \
|
||||||
|
secp256k1-kmp-jni-jvm-mingw \
|
||||||
|
secp256k1-kmp-jvm \
|
||||||
|
secp256k1-kmp-linux
|
||||||
|
do
|
||||||
|
pushd .
|
||||||
|
cd release/fr/acinq/secp256k1/$i/$VERSION
|
||||||
|
pwd
|
||||||
|
jar -cvf bundle.jar *
|
||||||
|
# use correct sonatype credentials here
|
||||||
|
curl -v -XPOST -u USER:PASSWORD --upload-file bundle.jar https://oss.sonatype.org/service/local/staging/bundle_upload
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ public object Secp256k1Native : Secp256k1 {
|
|||||||
memScoped {
|
memScoped {
|
||||||
val negated = privkey.copyOf()
|
val negated = privkey.copyOf()
|
||||||
val negPriv = toNat(negated)
|
val negPriv = toNat(negated)
|
||||||
secp256k1_ec_privkey_negate(ctx, negPriv).requireSuccess("secp256k1_ec_privkey_negate() failed")
|
secp256k1_ec_seckey_negate(ctx, negPriv).requireSuccess("secp256k1_ec_seckey_negate() failed")
|
||||||
return negated
|
return negated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ public object Secp256k1Native : Secp256k1 {
|
|||||||
val added = privkey.copyOf()
|
val added = privkey.copyOf()
|
||||||
val natAdd = toNat(added)
|
val natAdd = toNat(added)
|
||||||
val natTweak = toNat(tweak)
|
val natTweak = toNat(tweak)
|
||||||
secp256k1_ec_privkey_tweak_add(ctx, natAdd, natTweak).requireSuccess("secp256k1_ec_privkey_tweak_add() failed")
|
secp256k1_ec_seckey_tweak_add(ctx, natAdd, natTweak).requireSuccess("secp256k1_ec_seckey_tweak_add() failed")
|
||||||
return added
|
return added
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,7 @@ public object Secp256k1Native : Secp256k1 {
|
|||||||
val nSig = allocArray<UByteVar>(64)
|
val nSig = allocArray<UByteVar>(64)
|
||||||
val keypair = alloc<secp256k1_keypair>()
|
val keypair = alloc<secp256k1_keypair>()
|
||||||
secp256k1_keypair_create(ctx, keypair.ptr, nSec).requireSuccess("secp256k1_keypair_create() failed")
|
secp256k1_keypair_create(ctx, keypair.ptr, nSec).requireSuccess("secp256k1_keypair_create() failed")
|
||||||
secp256k1_schnorrsig_sign(ctx, nSig, nData, keypair.ptr, nAuxrand32).requireSuccess("secp256k1_ecdsa_sign() failed")
|
secp256k1_schnorrsig_sign32(ctx, nSig, nData, keypair.ptr, nAuxrand32).requireSuccess("secp256k1_ecdsa_sign() failed")
|
||||||
return nSig.readBytes(64)
|
return nSig.readBytes(64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user