Recommend this page to a friend! |
Classes of Scott Arciszewski | sapient | docs/Internals/Simple.md | Download |
|
DownloadSimple Encryption AbstractionCanonical name: Shared-Key EncryptionShared-key encryption uses XChaCha20-Poly1305 with a 192-bit random
nonce. The nonce is used as the Additional Data argument to libsodium's
After encryption, the nonce is prepended to the ciphertext. The encrypted message (in raw binary) is formatted like this.
Messages are Base64url encoded in transmission.
Public-Key EncryptionSapient's public-key encryption interface is a sealing API:
Under the hood, it does a little bit more work. First, generate a random X25519 keypair (
That is to say, the derived key will be the first 32 bytes of a 56-byte BLAKE2b hash of the X25519 shared secret and both public keys. The nonce for the message will be the remaining 24 bytes. The message is then encrypted with XChaCha20-Poly1305, with the ephemeral public key prepended to the message (and used as addition data). The encrypted message (in raw binary) is formatted like this.
Messages are Base64url encoded in transmission.
|