diff --git a/lib/ex_ucan/plugins/ed25519/crypto.ex b/lib/ex_ucan/plugins/ed25519/crypto.ex new file mode 100644 index 0000000..e69de29 diff --git a/lib/ex_ucan/plugins/ed25519/keypair.ex b/lib/ex_ucan/plugins/ed25519/keypair.ex new file mode 100644 index 0000000..1cf2812 --- /dev/null +++ b/lib/ex_ucan/plugins/ed25519/keypair.ex @@ -0,0 +1,32 @@ +defmodule ExUcan.Plugins.Ed25519.Keypair do + @moduledoc """ + Encapsulates Ed25519 Keypair generation and other utilities + """ + # TODO: more doc.. + + @type t :: %__MODULE__{ + jwt_alg: String.t(), + secret_key: binary(), + public_key: binary(), + exportable: boolean() + } + + defstruct( + jwt_alg: "EdDSA", + secret_key: <<>>, + public_key: <<>>, + exportable: false + ) + + @spec create() :: __MODULE__.t() + def create() do + {pub, priv} = :crypto.generate_key(:eddsa, :ed25519) + __MODULE__.__struct__( + jwt_alg: "EdDSA", + secret_key: priv, + public_key: pub, + exportable: false + ) + end + +end diff --git a/lib/ex_ucan/plugins/protocols.ex b/lib/ex_ucan/plugins/protocols.ex new file mode 100644 index 0000000..aaa2c54 --- /dev/null +++ b/lib/ex_ucan/plugins/protocols.ex @@ -0,0 +1,5 @@ +# TODO: docs?? + +defprotocol ExUcan.Plugins.Protocols.Keygen do + def create(type) +end diff --git a/mix.exs b/mix.exs index 8cf721b..03d1355 100644 --- a/mix.exs +++ b/mix.exs @@ -14,14 +14,15 @@ defmodule ExUcan.MixProject do # Run "mix help compile.app" to learn about applications. def application do [ - extra_applications: [:logger] + extra_applications: [:logger, :public_key] ] end # Run "mix help deps" to learn about dependencies. defp deps do [ - {:rustler, "~> 0.30.0", runtime: false} + {:rustler, "~> 0.30.0", runtime: false}, + {:credo, "~> 1.7", only: [:dev, :test], runtime: false} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] diff --git a/mix.lock b/mix.lock index 21fbfe3..c03886e 100644 --- a/mix.lock +++ b/mix.lock @@ -1,4 +1,7 @@ %{ + "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, + "credo": {:hex, :credo, "1.7.1", "6e26bbcc9e22eefbff7e43188e69924e78818e2fe6282487d0703652bc20fd62", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e9871c6095a4c0381c89b6aa98bc6260a8ba6addccf7f6a53da8849c748a58a2"}, + "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, "rustler": {:hex, :rustler, "0.30.0", "cefc49922132b072853fa9b0ca4dc2ffcb452f68fb73b779042b02d545e097fb", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "9ef1abb6a7dda35c47cfc649e6a5a61663af6cf842a55814a554a84607dee389"}, "toml": {:hex, :toml, "0.7.0", "fbcd773caa937d0c7a02c301a1feea25612720ac3fa1ccb8bfd9d30d822911de", [:mix], [], "hexpm", "0690246a2478c1defd100b0c9b89b4ea280a22be9a7b313a8a058a2408a2fa70"},