oxen-io / libsession-util

Session utilities library
GNU General Public License v3.0
15 stars 16 forks source link

Add signing and verification to encrypt_message/decrypt_message #59

Closed jagerman closed 1 year ago

jagerman commented 1 year ago

This redoes how we encode the result of encrypt_message to add sender identify and verification (entirely contained within libsession). These functions now produce/consume:

encrypted(
    padded(
        bt-encoded(
            possibly-compressed-data,
            sender-ed25519-pubkey,
            ed25519-signature
        )
    )
)

with signature verification on decryption.

The decryption function thus now returns a pair instead of an optional value: the session id, and the original value, assuming that value was signed by the session id. Upon failure for any reason, an exception is thrown (rather than, previously, returning a nullopt without any way to get an informative reason for the failure for diagnostics).