Skip to content

[secp256k1] Update test_taproot vectors and secp256k1 support #97

@alvroble

Description

@alvroble

While testing embit ctypes bindings for the latest secp256k1 release, I found out that several tests are failing:

tests/tests/test_taproot.py::TaprootTest::test_sign_internal
tests/tests/test_taproot.py::TaprootTest::test_sign_verify
tests/tests/test_taproot.py::TaprootTest::test_sign_taptree

The main Schnorr signing ctypes bindings changed since the prebuilt version that embit has hardcoded, so there may be some incompatibility between that prebuilt binary that SeedSigner uses and the current libsecp256k1 release.

test_sign_internal

I tried to decode this PSBT from the test vector but an error was shown:

error code: -22
error message:
TX decode failed Output Taproot tree must not be empty: iostream error

test_sign_taptree

I tried to run the PSBT signatures on test_sign_taptree using the latest Bitcoin Core release, finding that the signatures bitcoin-cli returns are the same as the new bindings were returning. These would be the up-to-date signatures expected (if anyone can cross check):

TAPTREE_SIGS = [
    unhexlify(
        "005c3c4c9016474fc9553f232cb20b5e0c1731d957b8a27534878ef37da1f9847b5559b61feade4815b68de59d82d8d6faec0bb60821060197c72c8deda5f42c"
    ),  # internal
    unhexlify(
        "eb2b15ead94249238eddb6132218b9989fc1fb9a0e5600f075dfdc2953b8108d46a9acc2c7e7530c090bc862b40f2cb0cbf6e048fc0ec10232eaf3b2670d7adb"
    ),  # keyA
    unhexlify(
        "93885fa6608fc73243966cd82d561ed522210f2c67c408ce3c03d5ce45ccb178181104bc135bfc02543404891dad93cb9a528b2c5e032157809ab408cbd1db1b"
    ),  # keyB
    unhexlify(
        "53b0aa4eee52e5c7c49ba511810cff137717b7e88fae15a0ae99fa9570393fc3c5bc533e20ec7f2f4d2f8cf3f9a053a8928c90a508959cec28e1517018971482"
    ),  # keyC
]

The goal of this issue is to find out what's exactly the problem and if a deeper refactor is needed in embit's code. And, of course, to see if any users have found any issue while signing PSBTs using taproot scripts.

I'll probably upload a draft PR to embit soon I updated PR #99 to show the bindings changes needed for the secp256k1 updates.

Related: SeedSigner/seedsigner-os#90

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