Skip to content

Commit

Permalink
Prepare 0.1.0-rc release (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaslong authored Sep 19, 2020
1 parent b332eb1 commit 3c07990
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 14 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Elixir wrapper for [Olm](https://gitlab.matrix.org/matrix-org/olm).

## Installation

### Install Olm

Olm is a native C library. The library is packaged by several distributions.

On Debian one can install it like so:
Expand All @@ -18,17 +16,14 @@ On Darwin:

NOTE: one must set the `ERL_ROOT` environment var, usually `/usr/local/lib/erlang/erts-version`

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `olm` to your list of dependencies in `mix.exs`:
Once this is done, the package can be installed by adding `olm` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:olm, "~> 0.1.0"}
{:olm, "~> 0.1.0-rc"}
]
end
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/olm](https://hexdocs.pm/olm).
The docs can be found at [https://hexdocs.pm/olm](https://hexdocs.pm/olm).
2 changes: 1 addition & 1 deletion lib/olm.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Olm do
@moduledoc """
Documentation for `Olm`.
Elixir/Erlang bindings to the olm and megolm cryptographic ratchets.
"""

alias Olm.NIF
Expand Down
2 changes: 2 additions & 0 deletions lib/olm/nif.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ defmodule Olm.NIFError do
end

defmodule Olm.NIF do
@moduledoc false

@on_load :load_nifs

def load_nifs(), do: :erlang.load_nif('priv/olm_nif', 0)
Expand Down
10 changes: 8 additions & 2 deletions lib/olm/session.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Olm.Session do
@moduledoc """
Functions for working with Olm Sessions
Functions for working with Olm Sessions.
"""

alias Olm.{NIF, NIFError}
Expand All @@ -17,7 +17,7 @@ defmodule Olm.Session do
end

@doc """
Create a new in-bound session for sending/receiving messages from an incoming PRE_KEY message.
Creates a new in-bound session for sending/receiving messages from an incoming pre key message.
"""
def new_inbound(account_ref, message) when is_reference(account_ref) and is_binary(message) do
case NIF.create_inbound_session(account_ref, message) do
Expand All @@ -26,6 +26,9 @@ defmodule Olm.Session do
end
end

@doc """
Creates a new in-bound session for sending/receiving messages from an incoming pre key message and includes an identity key check.
"""
def new_inbound(account_ref, message, peer_id_key)
when is_reference(account_ref) and is_binary(message) and is_binary(peer_id_key) do
case NIF.create_inbound_session_from(account_ref, message, peer_id_key) do
Expand Down Expand Up @@ -56,6 +59,9 @@ defmodule Olm.Session do
end
end

@doc """
Checks if the pre key message is for this in-bound session and includes an identity key check.
"""
def match_inbound(session_ref, message, peer_id_key)
when is_reference(session_ref) and is_binary(message) and is_binary(peer_id_key) do
case NIF.match_inbound_session_from(session_ref, message, peer_id_key) do
Expand Down
6 changes: 6 additions & 0 deletions lib/olm/utility.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ defmodule Olm.Utility do

alias Olm.{NIF, NIFError}

@doc """
Calculates the SHA-256 hash of the input and encodes it as base64.
"""
def sha256(to_hash) when is_binary(to_hash) do
case NIF.utility_sha256(to_hash) do
{:ok, hash} -> hash
{:error, error} -> raise NIFError, error
end
end

@doc """
Verifies an ed25519 signature.
"""
def verify_ed25519(key, message, signature)
when is_binary(key) and is_binary(message) and is_binary(signature) do
case NIF.utility_ed25519_verify(key, message, signature) do
Expand Down
34 changes: 31 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ defmodule Olm.MixProject do
def project do
[
app: :olm,
version: "0.1.0",
version: "0.1.0-rc",
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
deps: deps(),
compilers: [:olm_nifs] ++ Mix.compilers(),
aliases: aliases()
aliases: aliases(),
description: description(),
docs: docs(),
package: package()
]
end

Expand All @@ -23,13 +26,38 @@ defmodule Olm.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:jason, "~> 1.2"}
{:jason, "~> 1.2"},
{:ex_doc, "~> 0.22", only: :dev, runtime: false}
]
end

defp aliases do
[fmt: ["format", "cmd clang-format -i c_src/*.[ch]"]]
end

defp description() do
"""
Elixir/Erlang NIF bindings for the olm and megolm cryptographic ratchets
"""
end

defp docs do
[
main: "readme",
name: "Olm",
source_url: "https://github.com/niklaslong/olm-elixir",
extras: ["README.md"]
]
end

defp package() do
[
maintainers: ["Niklas Long"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/niklaslong/olm-elixir"},
files: ~w(lib priv .formatter.exs mix.exs README* LICENSE* CHANGELOG* src c_src Makefile)
]
end
end

defmodule Mix.Tasks.Compile.OlmNifs do
Expand Down
5 changes: 5 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
%{
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"ex_doc": {:hex, :ex_doc, "0.22.6", "0fb1e09a3e8b69af0ae94c8b4e4df36995d8c88d5ec7dbd35617929144b62c00", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "1e0aceda15faf71f1b0983165e6e7313be628a460e22a031e32913b98edbd638"},
"jason": {:hex, :jason, "1.2.1", "12b22825e22f468c02eb3e4b9985f3d0cb8dc40b9bd704730efa11abd2708c44", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b659b8571deedf60f79c5a608e15414085fa141344e2716fbd6988a084b5f993"},
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
"nimble_parsec": {:hex, :nimble_parsec, "0.6.0", "32111b3bf39137144abd7ba1cce0914533b2d16ef35e8abc5ec8be6122944263", [:mix], [], "hexpm", "27eac315a94909d4dc68bc07a4a83e06c8379237c5ea528a9acff4ca1c873c52"},
}

0 comments on commit 3c07990

Please sign in to comment.