From 108b4309a8ace111aeb1664b1656d8564efcf1c4 Mon Sep 17 00:00:00 2001 From: sstone Date: Thu, 18 Sep 2025 17:03:35 +0200 Subject: [PATCH] Use bitcoin-kmp 0.26.0 and set version to 0.43 bitcoin-kmp 0.26.0 uses secp256k1-kmp 0.19.0 which includes https://github.com/ACINQ/secp256k1-kmp/pull/126. --- pom.xml | 6 +++--- .../scala/fr/acinq/bitcoin/scalacompat/KotlinUtils.scala | 5 +++++ src/main/scala/fr/acinq/bitcoin/scalacompat/Musig2.scala | 6 +----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 147e4935..c564eb6d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ fr.acinq bitcoin-lib_2.13 jar - 0.42 + 0.43 Simple Scala Bitcoin library https://github.com/ACINQ/bitcoin-lib bitcoin-lib @@ -152,12 +152,12 @@ fr.acinq.bitcoin bitcoin-kmp-jvm - 0.25.1 + 0.26.0 fr.acinq.secp256k1 secp256k1-kmp-jni-jvm - 0.18.0 + 0.19.0 org.scodec diff --git a/src/main/scala/fr/acinq/bitcoin/scalacompat/KotlinUtils.scala b/src/main/scala/fr/acinq/bitcoin/scalacompat/KotlinUtils.scala index f575df8c..9917cb9a 100644 --- a/src/main/scala/fr/acinq/bitcoin/scalacompat/KotlinUtils.scala +++ b/src/main/scala/fr/acinq/bitcoin/scalacompat/KotlinUtils.scala @@ -101,6 +101,11 @@ object KotlinUtils { implicit def eitherkmp2either[L, R](input: fr.acinq.bitcoin.utils.Either[L, R]): Either[L, R] = if (input.isLeft) Left(input.getLeft) else Right(input.getRight) + implicit def either2keitherkmp[L, R](input: Either[L, R]): fr.acinq.bitcoin.utils.Either[L, R] = input match { + case Left(l) => new fr.acinq.bitcoin.utils.Either.Left[L](l).asInstanceOf[fr.acinq.bitcoin.utils.Either[L, R]] + case Right(r) => new fr.acinq.bitcoin.utils.Either.Right[R](r).asInstanceOf[fr.acinq.bitcoin.utils.Either[L, R]] + } + implicit def scala2kmp(input: ScriptElt): bitcoin.ScriptElt = input match { case OP_PUSHDATA(data, _) => new bitcoin.OP_PUSHDATA(data) case _ => scriptEltMapScala2Kmp(input) diff --git a/src/main/scala/fr/acinq/bitcoin/scalacompat/Musig2.scala b/src/main/scala/fr/acinq/bitcoin/scalacompat/Musig2.scala index 3f7ffb59..3d7e4823 100644 --- a/src/main/scala/fr/acinq/bitcoin/scalacompat/Musig2.scala +++ b/src/main/scala/fr/acinq/bitcoin/scalacompat/Musig2.scala @@ -26,11 +26,7 @@ object Musig2 { * @param extraInput_opt (optional) additional random data. */ def generateNonce(sessionId: ByteVector32, signingKey: Either[PrivateKey, PublicKey], publicKeys: Seq[PublicKey], message_opt: Option[ByteVector32], extraInput_opt: Option[ByteVector32]): (SecretNonce, IndividualNonce) = { - val (privateKey, publicKey) = signingKey match { - case Left(priv) => (scala2kmp(priv), priv.publicKey) - case Right(pub) => (null, pub) - } - val nonce = fr.acinq.bitcoin.crypto.musig2.Musig2.generateNonce(sessionId, privateKey, publicKey, publicKeys.map(scala2kmp).asJava, message_opt.map(scala2kmp).orNull, extraInput_opt.map(scala2kmp).orNull) + val nonce = fr.acinq.bitcoin.crypto.musig2.Musig2.generateNonce(sessionId, either2keitherkmp(signingKey.map(scala2kmp).left.map(scala2kmp)), publicKeys.map(scala2kmp).asJava, message_opt.map(scala2kmp).orNull, extraInput_opt.map(scala2kmp).orNull) (nonce.getFirst, nonce.getSecond) }