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

Why is the length of plaintext fixed #125

Closed
elvin-du opened this issue Aug 4, 2020 · 1 comment
Closed

Why is the length of plaintext fixed #125

elvin-du opened this issue Aug 4, 2020 · 1 comment

Comments

@elvin-du
Copy link

elvin-du commented Aug 4, 2020

Why is the length of plaintext fixed

@BobWall23
Copy link
Member

The encryption algorithm we use requires the plaintext to be one of a set of very specific values - the "rth roots of unity" for the field over our elliptic curve. The library provides a gen_plaintext function that will generate one of these values randomly, and a derive_symmetric_key function that will convert this random value to a 32-byte value that can be used as an AES256 encryption key.

To encrypt an arbitrarily long plaintext message, you use these two functions to generate a random symmetric key, then use AES256-GCM to encrypt your data (which we refer to as a document). You can then encrypt the original Plaintext value from gen_plaintext (which is referred to as a Document Encryption Key, or DEK), using the encrypt function in this library, creating an Encrypted Document Encryption Key, or EDEK. You need to keep this EDEK together with your encrypted document - to retrieve the document, you use the recrypt-rs library's decrypt function to retrieve the DEK, then use AES256 and that key on the encrypted document to retrieve the original document.

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

2 participants