Been tinkering with nostr lately. It’s a new open protocol being built in the wild. It has a possibility to disrupt centralized social networks such as Twitter. It’s been recently funded by Jack Dorsey, which is the Twitter founder himself. He’s actually using it and he said that it’s much like the very early Twittr days, with better potential. Ok, enough about Dorsey…
What’s interesting here, is that it’s possible to create all sorts of things that can communicate on this network without having to ask permission. I’d personally like to create bots. Even so, clients meant for people are very rudimentary and I have a good feeling this thing could be greatly improved with realtime Phoenix LiveView apps, for instance.
Problem is… to send anything on this network, messages have to be signed with Schnorr Signatures and I can’t find any lib that can natively do it either for Elixir or Erlang. By the way, this signature scheme is also enabling the new Bitcoin taproot addresses.
So, this is a call to elixir cryptographists and math wizards… is there anyone here willing to collaborate or create such a lib? I’m willing to do my part and would most probably make good use of it.
There are parts that could be tricky in pure Erlang / Elixir, for instance anything that requires constant-time arithmetic.
One way to avoid that would be to wrap an existing Rust library like k256 with Rustler. I’m neither a cryptographer nor much of a Rust dev, but this example seems like it wouldn’t be too much hassle to hook up.
Looks like with the help of rustler_precompiled, it’s possible to embed rust code in a lib and not require all dependent projects to have the whole rust toolkit installed…
I would guess the least complex and most straight forward way would be wrap an elixir front end to a well-maintained rust or c++ library, if you do end up going the rust wrapper route I would love to contribute in some way I have dabbled with ideas around this kind of thing but no real killer ideas, I’m in no way a cryptography expert so you’d probably want to find someone who really knows their way around this stuff however I am learning tonnes and happy to pitch in when/how I can.
Well, actually trying somehow wrap this in a nice elixir library that’s also rustler_precompiled… if successful, that would do it. Goal is to embed rust without requiring its compiler in apps depending on the said lib.
Right now, I’m learning rust basics so I have a slight idea of how rustler works as explained here.
At that point, any help would be greatly appreciated. The endgame is to make elixir usable on nostr.
Here’s a library I’ve found that wraps secp256k1 as a NIF library doing a quick search, perhaps this could help point you in the right direction as Schnorr is an extension on ECDSA. Sadly it hasn’t been maintained for several years, I would suppose some good examples of rust NIFs in the community today are:
There are others but these are just the ones I have personally taken a look under the hood of. The rustler documentation has some detailed examples that can get you pretty far. In general this is a common problem, cryptographic primitives as applied to the blockchain often don’t have good library support in elixir
Hey all, not sure how much help I can be, but I’ve dabbled some in Rust and Rustler and think I might be able to help a bit. Looks like folks the Schnorr signatures implementation inside the k256 crate. Curious how you want to go about this, do you want to wrap the entirety of rust-elliptic and only implemented the wrapper for k256 (exposing more as you need later), or do you want to only wrap the k256 portion?
Note that I’m not a cryptography person, just happen to have some Rust and Elixir experience and have played some with Rustler. With that in mind, what can I do that would be helpful for you all?
looks really good so far, love how this collaboratively came together. First time poster on elixir forum (I’ve been read only for a very long time) and it was really lovely to see this play out.
I wonder how much stuff is still needed before being able to go from this library to building an application on top of the protocol?