paseto v1.0.0 Paseto.V2
The Version2 implementation of the Paseto protocol.
More information about the implementation can be found here: 1.) https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Version2.md
In short, asymmetric encryption is handled by Ed25519, whereas symmetric encryption is handled by xchachapoly1305 Libsodium bindings are used for these crypto functions.
Link to this section Summary
Functions
Handles decrypting a token payload given the correct key
Handles encrypting the payload and returning a valid token
Callback implementation for c:Paseto.VersionBehaviour.from_token/1
Handles signing the token for public use
Handles verifying the signature belongs to the provided key
Link to this section Functions
Handles decrypting a token payload given the correct key.
Examples:
iex> key = <<56, 165, 237, 250, 173, 90, 82, 73, 227, 45, 166, 36, 121, 213, 122, 227, 188, 168, 248, 190, 39, 11, 243, 40, 236, 206, 123, 237, 189, 43, 220, 66>>
iex> Paseto.V2.decrypt("AUfxx2uuiOXEXnYlMCzesBUohpewQTQQURBonherEWHcRgnaJfMfZXCt96hciML5PN9ozels1bnPidmFvVc", key)
"{:ok, "This is a test message"}"
Handles encrypting the payload and returning a valid token
Examples:
iex> key = <<56, 165, 237, 250, 173, 90, 82, 73, 227, 45, 166, 36, 121, 213, 122, 227, 188, 168, 248, 190, 39, 11, 243, 40, 236, 206, 123, 237, 189, 43, 220, 66>>
iex> Paseto.V2.encrypt("This is a test message", key)
Callback implementation for c:Paseto.VersionBehaviour.from_token/1
.
Handles signing the token for public use.
Examples:
iex> {:ok, pk, sk} = Salty.Sign.Ed25519.keypair()
iex> Paseto.V2.sign("Test Message", sk)
"v2.public.VGVzdAJxQsXSrgYBkcwiOnWamiattqhhhNN_1jsY-LR_YbsoYpZ18-ogVSxWv7d8DlqzLSz9csqNtSzDk4y0JV5xaAE"
Handles verifying the signature belongs to the provided key.
Examples:
iex> {:ok, pk, sk} = Salty.Sign.Ed25519.keypair()
iex> Paseto.V2.sign("Test Message", sk)
"v2.public.VGVzdAJxQsXSrgYBkcwiOnWamiattqhhhNN_1jsY-LR_YbsoYpZ18-ogVSxWv7d8DlqzLSz9csqNtSzDk4y0JV5xaAE"
iex> Paseto.V2.verify("VGVzdAJxQsXSrgYBkcwiOnWamiattqhhhNN_1jsY-LR_YbsoYpZ18-ogVSxWv7d8DlqzLSz9csqNtSzDk4y0JV5xaAE", pk)
"{:ok, "Test"}"