Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
feat(keypair.ex): added create
Browse files Browse the repository at this point in the history
  • Loading branch information
madclaws committed Oct 28, 2023
1 parent 455d616 commit 4d6f823
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
Empty file.
32 changes: 32 additions & 0 deletions lib/ex_ucan/plugins/ed25519/keypair.ex
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions lib/ex_ucan/plugins/protocols.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TODO: docs??

defprotocol ExUcan.Plugins.Protocols.Keygen do
def create(type)
end
5 changes: 3 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
Expand Down
3 changes: 3 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -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"},
Expand Down

0 comments on commit 4d6f823

Please sign in to comment.