0

I have short messages (<=256bit) that need to be encrypted and published as a (HTTP URL) QR code, along with the public key(s). Because of the QR requirement the result should also stay 256bits long - with the scheme, servername, and base64 encoding the resulting URL already has quite a length, and so the QR becomes "too" big easily.

  1. RSA is out of the question for that key size.
  2. libsodium provides crypto_box functions using ED25519; but for these I need to transport the nonce (24 bytes) as well, and the result is eg. 48 bytes - this makes the QR code already a bit unwieldy.
    • Furthermore, using one (constant) key pair and another randomly generated per message means the random key needs to be embedded as well, enlarging the result
    • Using a single key pair doesn't work - If I encrypt with sec1 and pub1, I need to publish exactly these values for decrypting too.
  3. So I'm pondering using plain, raw ED25519 en- and decryption. Are there any pitfalls like with RSA (padding, bad keys (like pub exp 3)) that I need to look out for?

My plan would be to take the input, do an SHA256 of it, use the hash value to pad the input to 256 bits, and then do a plain ED25519 encryption. (I'll prepend a key marker to the result to make key rotation possible.)

What can go wrong? After all, all the complexity in libsodium has to have a reason, right?

Thanks a lot for any help!

fl64738
  • 11
  • 2
  • [ED25519](https://crypto.stackexchange.com/a/84435/18298) is the Edwards-coordinate signature system, not an encryption. What is the max byte of your QR system? crypto_box is crypto_box_curve25519xsalsa20poly1305 where the X25519 is the key aggrement. – kelalaka Dec 11 '20 at 22:41
  • Ah yeah, sorry, I meant X25519 - or any similar EC encryption with 256bit keys. – fl64738 Dec 12 '20 at 09:27
  • 1
    Still problematic X25519 is for the Elliptic curve Diffie-Hellman key exchange. If you are looking for ECC encryption you need to talk ECC Elgamal encryption. Still, what is your QR code? Edit your question to make it more clear about the issues. – kelalaka Dec 12 '20 at 09:39

0 Answers0