0

I'm encrypting something with a public key generated using the ed25519 curve, with OpenPGP.js. It goes something like this:

var options = {
    data: str,
    publicKeys: publicKeys,
    armor: false
};

openpgp.encrypt(options).then(function(ciphertext) {
    var bytes = ciphertext.message.packets.write();
});

From what I can observe, the output is deterministic -- i.e. it's the same output every time without a random component. I'm exploiting this fact in my database design, and thus I need it to always be deterministic.

Is this something I can assume? Is this documented anywhere? Is it a correct behaviour for OpenPGP?

I'm kind of in doubt now because this post specifies that it should have a random component: Will encrypting the same file with GnuPG and the same key produce the same ciphertext?

0

It should have a random component. The way encryption with asymmetric keys usually works is that you generate random AES key, encrypt the data using AES and then encrypt the random key with your asymmetric key. This is done for performance reasons. However, because the key is random each time, the resulting cipher-text should be different each time. I am not sure why it is not in your case.

  • ah, nevermind :) I made the silly mistake of just checking the first part of the base 64 encoded string which I'm assuming contains metadata. thanks for the reply! – HelloWorld May 6 '18 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.