Commit Graph
32 Commits
Author SHA1 Message Date
kngako b064c0bcf0 Check arguments to constraints 2024-08-06 00:19:55 +02:00
kngako 9e287feb26 Cinterop for arrays of pointers 2024-08-05 22:34:45 +02:00
kngako 3c01a2aad4 Use frost in Secp256k1 native logic 2024-08-04 23:53:28 +02:00
Kgothatso 099dcccf49 Make use of libsecp256k1 for musig+frost functions 2024-08-01 02:45:16 +02:00
Fabrice Drouin 567f411e12 Verify musig2 secret nonces (#108)
* Verify musig2 secret nonces

Trying to generate a musig2 partial signature with a secret nonce that was generated with a public key that does not match the signing key's public key will trigger secp256k1's illegal callback (which calls abort()) and crash the application.

=> Here we verify that the secret nonce matches the signing key before we call secp256k1_musig_partial_sign().
The verification method is a bit hackish (we extract the public key from the secret nonce blob) because secp256k1 does not export the methods we need to do this cleanly.
2024-04-18 09:54:51 +02:00
Fabrice Drouin bae4744bcb Add macos build targets (#104)
* Add macos build targets

* Update snapshot publishing script
2024-03-04 17:58:20 +01:00
Fabrice DrouinandBastien Teinturier 202b0c94b6 Add support for musig2 (#93)
* Use Jonas Nick's musig2 branch

* Reformat c code (no functional changes)

* Implement musig2

* Add documentation to musig2 functions (#97)

Usage of the Musig2 functions isn't intuitive at all, especially with
the key aggregation cache and session data. It's important to provide
accurate documentation to help users understand how to correctly produce
musig2 signatures.

We also change argument names to match Kotlin best practices instead of
using the same argument names as C functions.

* Add musig2 reference tests (no functional changes)

---------

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2024-02-14 13:28:22 +01:00
Fabrice Drouin 8ba5d4652e Use kotlin 1.9 (#92)
Use kotlin 1.9
2024-01-23 15:44:06 +01:00
Fabrice Drouin f242b4ffe8 Check arguments passed to secp256k1 methods (#94)
* Check arguments passed to secp256k1 methods

Illegal arguments will trigger an internal callback that prints to stderr and calls abort.
We already check arguments in our JNI and kotlin native code but had missed 2 checks (recid in ecdsaRecover, empty arrays in pubkeyCombine).

* Implement the same "tweak" checks in the native code and JNI code

The native code was missing checks on the "tweak" size (which must be 32 bytes)
2023-12-13 13:42:14 +01: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 ad1979c11e Update libsecp256k1 code (#16)
There are no external dependencies now
2021-03-19 19:07:05 +01:00
sstone 6a67dbe9f6 signatureNormalize: relax check on signature size
Checking that the sig size is >= 64 is enough, this is just a quick check before the actual library method is called.
2020-09-10 20:21:58 +02:00
Salomon BRYSandSalomon 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 0cc4c251f9 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
2020-07-09 20:16:39 +02:00
Salomon BRYSandSalomon 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
sstone 08d1692932 Add compact2der() method 2020-07-02 21:39:33 +02:00
Salomon BRYS 244673b04c Reset version number 2020-07-02 18:07:28 +02:00
Fabrice DrouinandSalomon BRYS 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 17dd83e476 Tests in their own module so that they can run on Android with the connectedCheck task 2020-07-02 12:19:29 +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
Salomon BRYS 4bdc836556 Explicit Signature & PubKey formats + bug fixes 2020-06-29 17:10:58 +02:00
Salomon BRYS 548fb27c33 Compat with linux host 2020-06-29 11:41:34 +02:00
Salomon BRYS ff37b86ff3 Android implementation 2020-06-26 20:50:32 +02:00
Salomon BRYS 08b6d16836 Native & iOS implementation 2020-06-26 17:10:48 +02:00
Salomon BRYS 54abe2a397 JVM implementation 2020-06-26 13:48:50 +02:00