Skip to content

Conversation

@miketlk
Copy link

@miketlk miketlk commented Jun 10, 2025

🚧 Work in Progress – Early Draft

This pull request is opened early to:

  • Share current progress
  • Gather feedback from contributors
  • Discuss implementation approaches

πŸ’‘ Note: This PR is not ready for review or merging. Some parts may be incomplete, untested, or non-buildable at this stage. Feel free to comment on design decisions, request clarifications, or suggest alternatives.

Summary

This PR updates the secp256k1 user C module to ensure compatibility with MicroPython v1.25. It addresses breaking changes introduced in the MicroPython API and refactors the module structure to align with the latest user C module guidelines.

Changes

  • WIP: The underlying library secp256k1-zkp being upgraded to 6152622
  • Updated module initialization to match MicroPython v1.25 API
  • Replaced deprecated macros and types with their v1.25 equivalents
  • TODO: Ensure compatibility with the new module registration mechanism
  • TODO: Cleanup of legacy code and unused includes
  • TODO: Update README.md with v1.25-specific build instructions

Testing

  • TODO: Build the module against MicroPython v1.25 on Unix and STM32 ports without compilation errors
  • TODO: Verify that secp256k1 functions (verify, sign, pubkey_create, etc.) work as expected via REPL tests
  • TODO: Add test script under tests/usercmodules/secp256k1_test.py with basic signing and verification use cases

Checklist

  • Code builds without errors
  • Tests added or updated
  • Documentation updated if necessary
  • Code reviewed for security and edge cases

@miketlk miketlk changed the title Update for Micropython v1.25 [WIP] Update for Micropython v1.25 Jun 13, 2025
@kdmukai
Copy link

kdmukai commented Jul 2, 2025

I'm on a parallel track to get to MicroPython 1.25.x compatibility.

I think it would be a little simpler (well, at least more convenient for me!) to tackle this in two PRs: One just for the MicroPython changes but pinned to the same secp256k1-zkp commit and then a follow-up for updating to the more recent secp256k1-zkp.

@miketlk
Copy link
Author

miketlk commented Jul 2, 2025

@kdmukai , thank you for the suggestion. I tried to avoid redundant work as either version of secp256k1-zkp requires updating secp256k1 user module, but in a slightly different way. Also, the older version of secp256k1-zkp now has build issues with modern toolchains, so keeping it supported as a transitional step doesn't make much sense to me.

@kdmukai
Copy link

kdmukai commented Jul 2, 2025

Also, the older version of secp256k1-zkp now has build issues with modern toolchains, so keeping it supported as a transitional step doesn't make much sense to me.

Understood. I'll be counting on you to sort through this then!

I'm currently trying to remember how to debug this stuff to get uhashlib from MicroPython 1.24.x to 1.25.x.

diybitcoinhardware/uhashlib#2

@kdmukai
Copy link

kdmukai commented Jul 2, 2025

cc @alvroble. The work Mike is doing here to get our secp256k1 up to date with a more recent version (of the -zkp fork) might interest you.

@alvroble
Copy link

alvroble commented Jul 3, 2025

Thanks @kdmukai and @miketlk, good to know! This is far ahead of my rusty C skills, but I’ll definitely keep an eye on this PR. Right now, the main issue when upgrading secp256k1 in embit is with Schnorr signatures: the results differ between the C bindings and the Python fallback implementation, probably due to modifications done in the main secp256k1's code for Schnorr signatures since the 2021-ish implementation from the prebuilt binaries.

@kdmukai
Copy link

kdmukai commented Jul 15, 2025

fyi @miketlk I have the pinned version of secp256k1-zkp compiling for MicroPython v1.25.0 here:

https://github.com/diybitcoinhardware/secp256k1-embedded/compare/master...kdmukai:secp256k1-embedded:micropython_1.25.0?expand=1

I build everything in a Docker container defined here:
https://github.com/kdmukai/micropython_builder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants