Packages

Proof of work resource creation, generation and verification

Current section

4 Versions

Jump to

Compare versions

3 files changed
+35 additions
-2 deletions
  @@ -10,4 +10,4 @@
10 10 {<<"links">>,[{<<"GitHub">>,<<"https://github.com/danj3/elixir-hashcash">>}]}.
11 11 {<<"name">>,<<"hashcash">>}.
12 12 {<<"requirements">>,[]}.
13 - {<<"version">>,<<"1.1.0">>}.
13 + {<<"version">>,<<"1.1.1">>}.
  @@ -1,4 +1,37 @@
1 1 defmodule Hashcash do
2 + @moduledoc """
3 + Elixir implementation of the hashcash algorigthm as described in
4 + http://hashcash.org and
5 + https://en.wikipedia.org/wiki/Hashcash
6 +
7 + # Generate a stamp for another party to generate:
8 +
9 + ```
10 + Hashcash.resource("foobar") |> Hashcash.resource_format
11 + %Hashcash{
12 + bits: 20,
13 + counter: 0,
14 + date: [year: 2022, month: 9, day: 2],
15 + ext: nil,
16 + rand: "gAbLlrNJFwsKWincKbOvNP6kNkUHRt1",
17 + resource: "foobar",
18 + stamp_base: "1:20:220902:foobar::gAbLlrNJFwsKWincKbOvNP6kNkUHRt1",
19 + stamp_string: "1:20:220902:foobar::gAbLlrNJFwsKWincKbOvNP6kNkUHRt1:0",
20 + version: 1
21 + }
22 + ```
23 +
24 + The `stamp_string` can be sent to the other party.
25 +
26 + To verify:
27 +
28 + ```
29 + iex(4)> Hashcash.stamp("1:20:220902:foobar::GszJUJJC+tcQSkvw+GPg7FBYYi289eL:294524") |> Hashcash.verify("foobar")
30 + {:ok, :verified}
31 + ```
32 +
33 + """
34 +
2 35 require Logger
3 36
4 37 defstruct version: 1,
  @@ -4,7 +4,7 @@ defmodule Hashcash.Mixfile do
4 4 def project do
5 5 [
6 6 app: :hashcash,
7 - version: "1.1.0",
7 + version: "1.1.1",
8 8 elixir: "~> 1.6",
9 9 build_embedded: Mix.env == :prod,
10 10 start_permanent: Mix.env == :prod,