jsm

jsm

NoNoncense - generate globally unique nonces in distributed Elixir

Generate globally unique nonces (number-only-used-once) in distributed Elixir. These nonces are be used to form the basis of an upcoming GUID generation package unique ID package Once, or in crypto operations that require nonces.

The nonces come in multiple types:

  • counter nonces that are unique but predictable and can be generated incredibly quickly
  • sortable nonces (Snowflake IDs) that have an accurate creation timestamp in their first bits
  • encrypted nonces that are unique but unpredictable

The nonces are guaranteed to be unique if:

  • machine IDs are unique for each node
  • individual machines maintain a somewhat accurate clock (specifically, the UTC clock has to have progressed between node restarts)

To aid with the unique machine IDs, NoNoncense.MachineId and its subsidiary conflict-detecting genserver NoNoncense.MachineId.ConflictGuard can be used. ConflictGuard requires connected nodes to function, but is an optional extra and the entire thing can also work without it.

It’s possible to use the nonces for cryptographic purposes like cipher IVs and generating Poly1305 one-time-keys. For usecases where a nonce is required that is not just unique but unpredictable, there is a uniqueness-preserving encrypted-nonce option. However, caveats apply, you should read the NoNoncense module docs and make up your own mind.

Last but not least, performance is great thanks to the use of Erlang primitives :persistent_term and :atomics. Plaintext nonces can be generated at rates of tens of millions of nonces per second :slight_smile:

Package: no_noncense | Hex
Docs: NoNoncense v0.0.3 — Documentation

Most Liked

jsm

jsm

The related Ecto type has arrived!

Where Next?

Popular in Libraries Top

pkrawat1
Hey guyz We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it. Have...
New
tompave
Hello there, I would like to share a feature toggles library (AKA feature flags) I’ve been working on. The main package is FunWithFlags...
New
blatyo
https://www.conduitframework.com/ The best overview for how things are tied together is this presentation. Modules and functions are pre...
New
asiniy
Hey there! I wrote a download elixir package which does exactly what its name about - an easy way to download files. I saw solutions ...
New
benlime
I created a new library GitHub - benvp/ex_cva: Class Variance Authority for Elixir which aims to make it very easy to define different va...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
bryanjos
Hi, I just published version 0.23.0 of Elixirscript. Most of the changes are around JavaScript interop now that Elixirscript uses the ...
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
New
Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Sub Categories:

We're in Beta

About us Mission Statement