Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

seek, locate and destroy direct imports of pynacl #12325

Closed
DMRobertson opened this issue Mar 29, 2022 · 1 comment · Fixed by #12902
Closed

seek, locate and destroy direct imports of pynacl #12325

DMRobertson opened this issue Mar 29, 2022 · 1 comment · Fixed by #12902
Labels
good first issue Good for newcomers T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@DMRobertson
Copy link
Contributor

DMRobertson commented Mar 29, 2022

For reasons, signedjson generates instances of pynacl's SigningKey and VerifyKey and then monkey patches new alg and version attributes onto them.

We (Synapse) never use pynacl directly as far as I can see. There are a number of type hint instances which refer to nacl.* when they should instead refer to signedjson.types.*.

I think we should

  • replace any uses (including type hints) of stuff from pynacl with their signedjson equivalents
  • no longer have synapse directly depend on pynacl.

(Ideally, signedjson would have its own types/classes etc rather than resort to monkeypatching. But one thing at a time.)

Crossref: #12324.

inspiration

@babolivier babolivier added the T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. label Mar 29, 2022
@clokep clokep added the good first issue Good for newcomers label Mar 30, 2022
@DMRobertson
Copy link
Contributor Author

In more detail, searching the source tree for nacl yields three hits.

  1. test_event_signing.py. I think we can use signedjson.decode_signing_key_base64 to create self.signing_key in the test setup method.
  2. test_keyring.py. Only used for a type annotation. I think this type annotation is wrong and it should be signedjson.types.SigningKey. Likely unspotted because this file is ignored by mypy.
  3. contrib/cmdclient. We generate a nacl.signing.VerifyKey but pass it to a function expecting a signedjson.types.VerifyKey. I think this is just broken; I suspect no-one has used this script in a long time. I think signedjson.decode_verify_key_bytes together with binascii.unhexlify might be enough to fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants