Fixup for #6 (native signature format detection) (#8)

* Fixup for #6

Behaviour was changed in the JNI wapper but not in Kotlin native code.

* Set version to 0.2.1-1.4-M3
This commit is contained in:
Fabrice Drouin
2020-07-09 20:16:39 +02:00
committed by GitHub
parent eeac972785
commit 0cc4c251f9
3 changed files with 26 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
package fr.acinq.secp256k1
import kotlin.random.Random
import kotlin.test.*
@@ -265,4 +266,24 @@ class Secp256k1Test {
Hex.encode(der).toUpperCase(),
)
}
@Test
fun testFormatConversion() {
val random = Random.Default
fun randomBytes(length: Int): ByteArray {
val buffer = ByteArray(length)
random.nextBytes(buffer)
return buffer
}
repeat(200) {
val priv = randomBytes(32)
val pub = Secp256k1.pubkeyCreate(priv)
val data = randomBytes(32)
val sig = Secp256k1.sign(data, priv)
val der = Secp256k1.compact2der(sig)
Secp256k1.verify(der, data, pub)
}
}
}