Skip to content

Fix TPAP EC point coords when ecdsa returns gmpy2.mpz - #7

Open
jimboca wants to merge 1 commit into
ZeliardM:feature/tpapfrom
jimboca:tpap-gmpy2-mpz-fix
Open

jimboca wants to merge 1 commit into
ZeliardM:feature/tpapfrom
jimboca:tpap-gmpy2-mpz-fix

Conversation

@jimboca

@jimboca jimboca commented Aug 7, 2026

Copy link
Copy Markdown

Summary

FreeBSD (and any host with gmpy2 installed) can make ecdsa return gmpy2.mpz from Point.x() / Point.y(). cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicNumbers requires builtin int, so TPAP handshake fails with:

TypeError: argument 'x': 'mpz' object is not an instance of 'int'

Cast coordinates to int in _xy_to_uncompressed before building the public key.

Verified against a KP125M(US) (encrypt_type=TPAP) on FreeBSD 14: discover_single + update() succeed after this change.

Test plan

  • On a system with gmpy2 (or FreeBSD py311-ecdsa using mpz): connect to a TPAP device and await device.update()
  • Confirm handshake still works on Linux without gmpy2

cryptography EllipticCurvePublicNumbers requires builtin int; on
FreeBSD with gmpy2 installed, ecdsa Point.x()/y() return mpz.

Co-authored-by: Cursor <[email protected]>
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.

1 participant