31 Commits

Author SHA1 Message Date
sstone
0364ec762e
Use local secp256k1 callbacks in kotlin native code 2023-12-12 12:08:13 +01:00
sstone
8e17e7030a
Implement custom secp256k1 error callbacks
These callbacks are only triggered either by arguments do not match explicit rquirements of the sepc256k1 library, or by hardware failures, memory corruption
or bug in secp256k1, and not by misuse of the library.
In theory we do not need to implement them, except to find bugs in our own code, but the default callbacks print a message to stderr and call abort() which
is not nice especially on mobile apps.

=> Here we introduce 2 specific exceptions, Secp256k1ErrorCallbackException and Secp256k1IllegalCallbackException, which are thrown when the error callback or illegal callback are called.
2023-12-11 19:05:46 +01:00
sstone
929e2cda40
Check that the recovery id is valid
It must be 0,1,2 or 3, this is an explicit requirement of the secp256k1 library.
2023-12-11 11:54:07 +01:00
sstone
41eac9273f
Reformat JNI c code (no functional changes) 2023-12-11 10:46:43 +01:00
Fabrice Drouin
3706a546a2
Use secp256k1 0.4.0 (#85) 2023-09-18 14:05:36 +02:00
Fabrice Drouin
6fedb1577c
Update build for macos M1 (#77) 2023-04-13 09:15:43 +02:00
Fabrice Drouin
bf05a001fe
Update Android build plugin and tools (#75) 2023-04-11 18:42:06 +02:00
Fabrice Drouin
d4eba9fb96
Update to kotlin 1.6 (#63)
Use kotlin 1.6 (and gradle 7.5.1)
2022-09-21 16:00:19 +02:00
Fabrice Drouin
118c72064c
Update secp256k1 sources (#52)
We're now at 8746600eec5e7fcd35dabd480839a3a4bdfee87b, same as bitcoin core at 747cdf1d652d8587e9f2e3d4436c3ecdbf56d0a5
2022-04-11 13:34:59 +02:00
Fabrice Drouin
ac7d4983d5
Export Schnorr signature API (#32)
Implement Schnorr signatures (BIP 340)
2021-11-23 17:38:46 +01:00
Bastien Teinturier
2ae6abcf93
Clarify public key encoding and enrich tests (#37)
Don't throw in `seckey_verify`: it's inconsistent to have this function throw
for some invalid inputs and return false for other invalid inputs.

Document public key compression and add tests.
2021-11-05 10:45:49 +01:00
Bastien Teinturier
f695e7453d
Clean up and enrich tests (#35)
* Harmonize parameter names
* Document methods
* Replace pubKeyAdd with pubKeyCombine
* Clean-up tests
2021-10-26 17:16:36 +02:00
Fabrice Drouin
e7644b7ddb
Upgrade to kotlin 1.5 (#27)
* Upgrade to kotlin 1.5.31

* Upgrade dokka gradle plugins to 1.5.30
2021-09-22 15:22:05 +02:00
Fabrice Drouin
9c1afc715a
Fix Android build (#23)
* Upgrade Android NDK

* Use Android emulator 30.7.3 on macos
2021-06-28 10:31:57 +02:00
Fabrice Drouin
b544b24cc3
Fix memory leak in pubkeyCreate() (#20) 2021-06-22 16:16:08 +02:00
Fabrice Drouin
ad1979c11e
Update libsecp256k1 code (#16)
There are no external dependencies now
2021-03-19 19:07:05 +01:00
Romain Boisselle
f493edfdfb
New publication configuration (#14)
* add Dokka + align POM metadatas with sonatype requirements

* update snapshot CI

* update JNI publication

* update CI scripts

* remove maven-metadata-local.xml

* add snapshot publication with maven-publish plugin
2021-03-11 17:53:50 +01: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
Salomon BRYS
dbf8301f34
Android loading may fallback to standard JVM (#9)
* Android loading may fallback to standard JVM

* Java code must target JVM 1.8 in order to be compatible Android.

Co-authored-by: Salomon BRYS <salomon@kodein.net>
2020-07-16 22:21:30 +02:00
Fabrice Drouin
5af1807f38
Fix signature format detection (#6)
64 bytes means compact, less is invalid, other try DER and let the library handle the actual check.
2020-07-09 15:59:07 +02:00
Salomon BRYS
6c850eb2c4
Native jni build (#5)
* Each native library is in its own jar. Got rid of cross compilation. The project is `secp256k1` and not `secp256k1-kmp`.

* Updated CI to use all 3 OS VMs

Co-authored-by: Salomon BRYS <salomon@kodein.net>
2020-07-09 14:54:34 +02:00
Salomon BRYS
c5dbc42496
Kotlin 1.4-M3, fixed CI glitches & fixed build on Mac (#4)
* Kotlin 1.4-M3, fixed CI glitches & fixed build on Mac

* Fixes https://github.com/eskatos/gradle-command-action/issues/24

* Explicit mode requirements in Android tests

Co-authored-by: Salomon BRYS <salomon@kodein.net>
2020-07-06 21:45:17 +02:00
Salomon BRYS
fa425731a1
GitHub actions (#2)
* Updated readme, enabled automatc testing

* Snapshot support

* Release CI support

Co-authored-by: Salomon BRYS <salomon@kodein.net>
2020-07-03 19:12:38 +02:00
sstone
08d1692932 Add compact2der() method 2020-07-02 21:39:33 +02:00
Fabrice Drouin
3ee2635d93
Upgrade JNI interface (#1)
* Upgrade JNI interface

* Input signatures can be DER or compact format, output signatures are always in compact format

* Input public keys can be compressed or uncompressed, output public keys are always uncompressed

* Name and parameters match libsecp256k1's

* JNI implementation is now straightforward

  No more ByteBuffers
  Exceptions are thrown in case of failures

* Update src/nativeMain/kotlin/fr/acinq/secp256k1/Secp256k1Native.kt

* Add public key compression method

Co-authored-by: Salomon BRYS <salomon.brys@gmail.com>
2020-07-02 17:52:21 +02:00
Salomon BRYS
ffe4cc41dc Maven publications 2020-07-02 11:39:42 +02:00
Salomon BRYS
3b3d67a4fe JNI built in JNI 2020-07-01 18:26:24 +02:00
Salomon BRYS
6e4763e55b Using javac to generate header 2020-07-01 13:53:26 +02:00
Salomon BRYS
720637ec24 JNI Implementation in their own package 2020-07-01 12:56:48 +02:00
Salomon BRYS
1d9d57ca0a Android & JVM loader in their own modules 2020-07-01 12:15:04 +02:00