Encryption and digests under keys derived from the host's
secret_key_base (Countersign.Config).
- Addresses and tokens are encrypted with
Plug.Crypto.MessageEncryptor(AES-256-GCM), each purpose under its own derived key pair, so a token ciphertext can never be decrypted as an address or the other way round. - An address digest is HMAC-SHA256 of the normalised address under its own derived key: equal addresses give equal digests, and the digest reveals nothing without the secret.
Summary
Types
Functions
@spec decrypt(Countersign.Config.t(), purpose(), binary() | nil) :: {:ok, String.t()} | :error
Decrypts what encrypt/3 produced for the same purpose.
@spec digest(Countersign.Config.t(), String.t(), String.t()) :: binary()
HMAC-SHA256 (32 bytes) of the normalised address on channel.
An email is trimmed and lowercased; a phone number keeps its digits only,
with a leading US country code 1 dropped from an 11-digit number.
@spec encrypt(Countersign.Config.t(), purpose(), String.t()) :: binary()
Encrypts plaintext for purpose.
The normalised form of address that digest/3 hashes.