What is most secure way for one party to encrypt 4 bytes in less than 40 bytes, which will be publicly available? I have a project where a user needs to store a U32 encrypted on a blockchain such that they can recover it themselves: the user will always have their key available but may &quot;forget&quot; the U32 value. No other party needs to decode the information, but the plaintext will eventually also be public on the chain.
The user has an entropy seed from which an infinite number of keys of any size can be deterministically derived. I was looking to using a single block of AES but it occurred to me that a simple XOR would also suffice. Assuming the user derives a unique &quot;key&quot; every time they perform this type of operation, is there any reason to do anything more complicated than that?
The obvious answer is to use a one time pad.  If you are truly using a unique random 4 byte key for each 4 byte block then it is provably secure.

The user has an entropy seed from which an infinite number of keys of any size can be deterministically derived.

The real problem is this &quot;derived&quot; randomness and how random it truly is.  I'm not aware of any infinite source of it.
With Salsa/ChaCha you could generate up 2^64 512 bit keys, each key being able to encrypt 16 different 4-byte blocks.  So I suppose infinite enough.
Users would need to seed it with a 320 bit key.  They need to change their their key after 2^68 (if my maths isn't wrong) encryptions. Using a setup similar to XChaCha allows you to extend this to 2^132.
In summary, if you have a cryptographically secure source of randomness you can just XOR.