ntru_elixir v0.0.0 NtruElixir

Documentation for NtruElixir.

Link to this section Summary

Functions

Decrypts a given binary with a keypair

Bang version of decrypt

Encrypts a given binary with a keypair

Bang version of encrypt

Generates an NTRU key pair with given ntru_params and private key

Link to this section Functions

Link to this function decrypt(kp, enc_data, ntru_params)
decrypt(NtruElixir.KeyPair.t(), binary(), NtruElixir.Base.ntru_params_t()) ::
  {:ok, binary()} |
  {:error, atom()}

Decrypts a given binary with a keypair

Note that the KeyPair should contain the priv_key in order to decrypt!

Parameters

  • kp: The KeyPair which holds the public key, private_key and ntru_params
  • enc_data: the binary to decry[t]
  • ntru_params(optional): ntru params. if not provided the params in kp will be used

Returns a tuple like {:ok, encrypted_bin} on success.

Link to this function decrypt!(kp, enc_data, ntru_params)
decrypt!(NtruElixir.KeyPair.t(), binary(), NtruElixir.Base.ntru_params_t()) :: binary()

Bang version of decrypt

Link to this function encrypt(kp, data_bin, ntru_params)

Encrypts a given binary with a keypair

Parameters

  • kp: The KeyPair which holds the public key and ntru_params
  • data_bin: the binary to encrypt
  • ntru_params(optional): ntru params. if not provided the params in kp will be used

Returns a tuple like {:ok, encrypted_bin} on success.

Link to this function encrypt!(kp, data_bin, ntru_params)
encrypt!(NtruElixir.KeyPair.t(), binary(), NtruElixir.Base.ntru_params_t()) :: binary()

Bang version of encrypt

Link to this function generate_key_pair(pub_count \\ 1, ntru_params \\ :NTRU_DEFAULT_PARAMS_128_BITS)

Generates an NTRU key pair with given ntru_params

For more information on ntru_params please visit libntru - Parameter Sets

Parameters

  • pub_count: Number of public keys to generate
  • ntru_params: An atom representing the params of generated NTRU keypair.

Returns a tuple like {:ok, %KeyPair{…}} on success

Link to this function generate_key_pair(priv_key, pub_count, ntru_params)
generate_key_pair(binary(), Integer.t(), NtruElixir.Base.ntru_params_t()) ::
  {:ok, List.t()} |
  {:error, atom()}

Generates an NTRU key pair with given ntru_params and private key

Note that in NTRU a single private key can have multiple public keys. But you’ll need the public key whick encrypted the data in order to decrypt it.

For more information on ntru_params please visit libntru - Parameter Sets

Parameters

  • priv_key: Binary of the private key
  • pub_count: Number of public keys to generate
  • ntru_params: An atom representing the params of generated NTRU keypair.

Returns a tuple like {:ok, %KeyPair{…}} on success