Skip to content

Support more Schnorr schemes besides BIP340 #1070

@Sajjon

Description

@Sajjon

There are two different Schnorr signature variants in bitcoin-core/secp256k1, the "default" one named secp256k1_schnorrsig_sign and another more customizable with the appropriate name secp256k1_schnorrsig_sign_custom. Both functions calls secp256k1_schnorrsig_sign_internal. Using secp256k1_schnorrsig_sign_custom we can pass custom nonce data through the secp256k1_schnorrsig_extraparams parameter, which has a member for a custom nonce function, secp256k1_nonce_function_hardened noncefp. This looks great at first glance! Looks like I can use bitcoin-core/secp256k1 as a provider of a great Schnorr sig implementation! However, the secp256k1_schnorrsig_sign_custom is not as customizable as it could be, or as I want to be, because secp256k1_schnorrsig_sign_internal hardcodes the algo to bip340_algo (with value "BIP0340/nonce"), when calling the nonce function:

    ret &= !!noncefp(buf, msg, msglen, seckey, pk_buf, bip340_algo, sizeof(bip340_algo), ndata);

I propose we change this hardcoded value, to allow consumers of this amazing lib, to pass along a custom algo string.

I've recently started writing a Swift wrapper called K1. The earliest (AFAIK) adopter of Schnorr signatures amongst cryptocurrency community is Zilliqa, which has been using Schnorr since 2017/2018. The Zilliqa-JS javascript library has in earlier commits bundled 1000 test vectors which I thought to be useful.

I would also like to make it possible for my library K1 to replace my own, unsafe, EC library called EllipticCurveKit, which currently is used (potentially unsafe for end users, which they are informed about) by the iOS Zilliqa wallet Zhip (open source) (also on AppStore).

The bad news is that Zilliqa uses the ALGO name "Schnorr+SHA256 ". So I cannot replace EllipticCurveKit in Zhip with K1 until I'm able to pass a custom ("Schnorr+SHA256 ") ALGO to secp256k1_schnorrsig_sign_custom.

Furthermore, Zilliqa uses this HMAC-DRBG as nonce function, but I should be able to implement that in C and pass through the noncefp member in secp256k1_schnorrsig_extraparams, right?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions