Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import EncryptedDirectMessage fails using python3.10, nostr 0.0.2 #100

Open
proofofjogi opened this issue May 12, 2023 · 5 comments
Open

Comments

@proofofjogi
Copy link

Hi

I cannot import EncryptedDirectMessage. Here's the environment:
$ pip freeze
cffi==1.15.1
cryptography==40.0.2
nostr==0.0.2
pycparser==2.21
secp256k1==0.14.0
websocket-client==1.5.1

The python code:

from nostr.event import EncryptedDirectMessage

The error:

ImportError: cannot import name 'EncryptedDirectMessage' from 'nostr.event' (/home/jogi/nostr-message/env/lib/python3.10/site-packages/nostr/event.py)

@proofofjogi
Copy link
Author

I dug a little and turns out that when you pip install nostr, the nostr.event.py is currently lacking EncryptedDirectMessage.

@ricardowaldow
Copy link

ricardowaldow commented May 17, 2023

Same is happening to me. It is outdated in pypi, the EncryptedDirectMessage was added at Feb 4 and the latest version on pypi is from Jan 26.

@proofofjogi
Copy link
Author

I am using CalleBTC fork now. That has DMs working.

@ricardowaldow
Copy link

ricardowaldow commented May 19, 2023

I installed and i can send the DMs but an error always occurs when i try to decrypt the message content.

Traceback (most recent call last):
  File "/home/user/folder/nostr-py-test/test.py", line 46, in <module>
    print(private_key.decrypt_message(event_msg.event.content, public_key.hex()))
  File "/home/user/folder/nostr-py-test/venv/lib/python3.10/site-packages/nostr/key.py", line 102, in decrypt_message
    unpadded_data = unpadder.update(decrypted_message) + unpadder.finalize()
  File "/home/user/folder/nostr-py-test/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/padding.py", line 159, in finalize
    result = _byte_unpadding_check(
  File "/home/user/folder/nostr-py-test/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/padding.py", line 101, in _byte_unpadding_check
    raise ValueError("Invalid padding bytes.")
ValueError: Invalid padding bytes.

Edit: I was using the wrong pubkey to decrypt. Now its working.

@escapedcat
Copy link

I am using CalleBTC fork now. That has DMs working.

💁‍♂️ https://github.com/callebtc/python-nostr

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

No branches or pull requests

3 participants