kpdemetriou / pqcrypto

👻 Post-quantum cryptography for Python.
BSD 3-Clause "New" or "Revised" License
58 stars 20 forks source link

Use of field plaintext_original #8

Open claudefalbriard opened 2 years ago

claudefalbriard commented 2 years ago

I would like to clarify a conceptual doubt regarding use of the "encrypt" function described in the sample section of "Key Encapsulation". The execution confirms successful execution of the "assert" command, confirming encrypt and decrypt operations. When validating the field named plaintext_original with a Python print command, I get a binary field which does not match any standard decode methods like: UTF-8, or ISO-8859-1. After calling the encrypt function, the plaintext_original gets unreadable, likely the field gets modified by the C language processing. Is there a way to set a value for plaintext_original and keep it unmodified and validate it at the end of the encode/decode process?

kpdemetriou commented 1 year ago

No, and this is intentional. That said, you can use the "plaintext" as a key to a symmetric cipher to achieve the desired effect.

neomn commented 1 year ago

@kpdemetriou in some cases , this is required to encrypt a custom message(plain_text) using public key , so there is no way to do that ? or should i implement it myself ?

kpdemetriou commented 1 year ago

The KEMs provided in this module are not meant to encrypt arbitrary plaintext directly. Rather, you can use plaintext_original and plaintext_recovered to key a symmetric cipher like AES to achieve bulk encryption of content.

neomn commented 1 year ago

@kpdemetriou then what about asymmetric ? what if i want to encrypt a message using public key such that could be decrypted only using private key ?

Artucuno commented 1 year ago

The KEMs provided in this module are not meant to encrypt arbitrary plaintext directly. Rather, you can use plaintext_original and plaintext_recovered to key a symmetric cipher like AES to achieve bulk encryption of content.

Are you able to give an example of how this is done?