Skip to content

Conversation

@Dzeranov
Copy link
Contributor

@Dzeranov Dzeranov commented Oct 31, 2024

Description

Encryption module now can work not only with strings

Summary of changes

  1. Both sign_and_encrypt and sign methods now can work both with str and bytes types.
  2. decrypt method now returns bytes instead of str

Related issues

Part of the #2717

NOTE: Don't merge this PR.

@Dzeranov Dzeranov added the SDK label Oct 31, 2024
@Dzeranov Dzeranov requested review from dnechay and portuu3 October 31, 2024 08:44
@Dzeranov Dzeranov self-assigned this Oct 31, 2024
@vercel
Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
human-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 8:50am
human-dashboard-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 8:50am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
faucet-frontend ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 8:50am
faucet-server ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 8:50am

Copy link
Collaborator

@dnechay dnechay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, 2 questions:

  • does it make sense to add a unit test on encrypt/decrypt of actual bytes? Maybe some dumb object converted to bytes
  • do we expect the same 1:1 behavior from JS sdk, i.e. decrypt to return binary if encrypted message is string and encrypt to accept both? I thought for these methods we were going to use just bytes and potentially provide some convenience methods like encryptStrMessage, decryptStrMessage

@Dzeranov
Copy link
Contributor Author

@dnechay

  1. I'll add it, this PR is not ready to be merged yet, simply to show what will be the behavior.
  2. decrypt method returns bytes in this implementation for both str and bytes. As for input parameters, pgpy package doesn't care what is the data you need to encrypt, Union[str, bytes] is simply for a type hint here.

@Dzeranov Dzeranov merged commit a9f4c9b into develop Nov 5, 2024
14 checks passed
@Dzeranov Dzeranov deleted the fix/sdk-encryption-python branch January 14, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SDK] Treat messages/files for encryption/decryption as binaries not strings

4 participants