KCl v1.2.0 Kcl View Source

pure Elixir NaCl crypto suite substitute

The box and unbox functions exposed here are the equivalent of NaCl's:

  • crypto_box_curve25519xsalsa20poly1305
  • crypto_box_curve25519xsalsa20poly1305_open

Link to this section Summary

Types

public or private key

key varieties

shared nonce

computed signature

Functions

crypto_auth equivalent

box up an authenticated packet

derive a public key from a private key

generate a {private, public} key pair

create an inital state for a peer connection

box based on a shared secret

unbox based on a shared secret

pre-compute a shared key

unbox an authenticated packet

Link to this section Types

public or private key

Link to this type

key_variety()

View Source
key_variety() :: :sign | :encrypt

key varieties

shared nonce

Link to this type

signature()

View Source
signature() :: binary()

computed signature

Link to this section Functions

Link to this function

auth(message, key)

View Source
auth(binary(), key()) :: signature()

crypto_auth equivalent

Link to this function

box(msg, nonce, state)

View Source
box(binary(), nonce(), Kcl.State.t()) :: {binary(), Kcl.State.t()}
Link to this function

box(msg, nonce, our_private, their_public)

View Source
box(binary(), nonce(), key(), key()) :: {binary(), Kcl.State.t()}

box up an authenticated packet

Link to this function

derive_public_key(private_key, variety \\ :encrypt)

View Source
derive_public_key(key(), key_variety()) :: key() | :error

derive a public key from a private key

Link to this function

generate_key_pair(variety \\ :encrypt)

View Source
generate_key_pair(key_variety()) :: {key(), key()} | :error

generate a {private, public} key pair

Link to this function

new_connection_state(our_private, our_public \\ nil, their_public)

View Source
new_connection_state(key(), key() | nil, key()) :: Kcl.State.t()

create an inital state for a peer connection

A convenience wrapper around Kcl.State.init and Kcl.State.new_peer

Link to this function

secretbox(msg, nonce, key)

View Source
secretbox(binary(), nonce(), key()) :: binary()

box based on a shared secret

Link to this function

secretunbox(packet, nonce, key)

View Source
secretunbox(binary(), nonce(), key()) :: binary() | :error

unbox based on a shared secret

Link to this function

shared_secret(our_private, their_public)

View Source

pre-compute a shared key

Mainly useful in a situation where many messages will be exchanged.

Link to this function

sign(message, secret_key, public_key \\ nil)

View Source
sign(binary(), key(), key()) :: signature()

sign a message

If only the secret key is provided, the public key will be derived therefrom. This can add significant overhead to the signing operation.

Link to this function

unbox(packet, nonce, state)

View Source
Link to this function

unbox(packet, nonce, our_private, their_public)

View Source
unbox(binary(), nonce(), key(), key()) :: {binary(), Kcl.State.t()} | :error

unbox an authenticated packet

Returns :error when the packet contents cannot be authenticated, otherwise the decrypted payload and updated state.

Link to this function

valid_auth?(signature, message, key)

View Source
valid_auth?(signature(), binary(), key()) :: boolean()

Compare auth HMAC

Link to this function

valid_signature?(signature, message, public_key)

View Source
valid_signature?(signature(), binary(), key()) :: boolean()

validate a message signature