Sign-In with Ethereum - Elixir Library Release

In our continued updates on additional language support to help bolster the adoption of Sign-In with Ethereum, we're happy to announce the alpha release of our Elixir library.

Sign-In with Ethereum - Elixir Library Release

In our continued updates on additional language support to help bolster the adoption of Sign-In with Ethereum, we're happy to announce the alpha release of our Elixir library:

GitHub - spruceid/siwe-ex: Sign-In with Ethereum Implementation for Elixir
Sign-In with Ethereum Implementation for Elixir. Contribute to spruceid/siwe-ex development by creating an account on GitHub.

Sign-In with Ethereum can now be found and used as a hex, and be installed in your Elixir project by including it in your list of dependencies in mix.exs:

def deps do
  [
    {:siwe, "~> 0.3"}
  ]
end

This Elixir library was created by leveraging the existing work on our Sign-In with Ethereum Rust library. Our Rust library is called by this library for signature verification and message format validation. The repository has been dual-licensed under Apache-2.0 and MIT, making it as flexible and simple as possible for developers to use in their projects.


Using the Library

To see how this works in iex, clone the repository and run:

$ mix deps.get

Then create two files, message.txt and signature.txt:

./message.txt should contain:

login.xyz wants you to sign in with your Ethereum account:
0xfA151B5453CE69ABf60f0dbdE71F6C9C5868800E

Sign-In With Ethereum Example Statement

URI: https://login.xyz
Version: 1
Chain ID: 1
Nonce: ToTaLLyRanDOM
Issued At: 2021-12-17T00:38:39.834Z

./signature.txt should contain:

0x8d1327a1abbdf172875e5be41706c50fc3bede8af363b67aefbb543d6d082fb76a22057d7cb6d668ceba883f7d70ab7f1dc015b76b51d226af9d610fa20360ad1c

and then run:

$ iex -S mix

Once in iex, you can then run the following in the REPL to see the result:

iex> {:ok, msg} = File.read("./message.txt")
...
iex> {:ok, sig} = File.read("./signature.txt")
...
iex> Siwe.parse_if_valid(String.trim(msg), String.trim(sig))
{:ok, %{
  __struct__: Siwe,
  address: "0xfA151B5453CE69ABf60f0dbdE71F6C9C5868800E",
  chain_id: "1",
  domain: "login.xyz",
  expiration_time: nil,
  issued_at: "2021-12-17T00:38:39.834Z",
  nonce: "ToTaLLyRanDOM",
  not_before: nil,
  request_id: nil,
  resources: [],
  statement: "Sign-In With Ethereum Example Statement",
  uri: "https://login.xyz",
  version: "1"
}}

Any valid Sign-In with Ethereum message and signature pair can be substituted. The functions described below can also be tested with msg, sig, or a value set to the result Siwe.parse_if_valid.


Maturity disclaimer: Our Elixir library for Sign-In with Ethereum has not yet undergone a formal security audit. We welcome continued feedback on the usability, architecture, and security of this implementation.


If you're interested in integrating Sign-In with Ethereum into your dapp, app, or service, we are more than happy to help and provide any support we can. As we continue our work supporting Sign-In with Ethereum, we especially welcome implementers who already have users relying on similar workflows, authors of related EIPs, and wallet vendors who would like to do more to support user-owned identities to join us.

If you are interested in being involved, please join our Discord server: