bkolobara
Erlang :cryto.generate_key() trouble
Hi,
I’m trying to generate an ED25519 public key from a secret key using Erlang’s crypto application. I’m able to generate a random keypair using:
iex(3)> {p, s} = :crypto.generate_key(:ecdh, :x25519)
{<<139, 150, 158, 47, 97, 82, 64, 37, 96, 216, 224, 34, 120, 116, 57, 178, 35,
123, 99, 142, 109, 65, 68, 80, 236, 154, 22, 112, 0, 37, 68, 114>>,
<<32, 123, 30, 206, 152, 213, 66, 101, 231, 22, 173, 128, 18, 84, 98, 91, 73,
205, 66, 27, 0, 12, 241, 122, 6, 207, 155, 100, 134, 170, 29, 125>>}
But if I want just to generate a public key from an existing secret key I get the following error:
iex(4)> :crypto.generate_key(:ecdh, :x25519, s)
** (ArgumentError) argument error
(crypto) :crypto.ec_key_generate({:evp, :x25519}, <<32, 123, 30, 206, 152, 213, 66, 101, 231, 22, 173, 128, 18, 84, 98, 91, 73, 205, 66, 27, 0, 12, 241, 122, 6, 207, 155, 100, 134, 170, 29, 125>>)
It looks like the ec_key_generate() function is implemented as a NIF and I can’t figure out what I’m doing wrong here.
Most Liked
smanza
Hello. I think the issue is now resolved with the last OTP version. https://github.com/erlang/otp/pull/2329
We are now able to generate ed22519 keys from the crypto app.
2
bkolobara
I contributed that PR
.
I don’t think it’s part of an OTP release yet. Not that familiar with the release structure, but I think the master branch is going to be the next major version? So it may take some time.
2
Popular in Questions
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir
iex(2)...
New
Other popular topics
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Manning 2016 Halloween weekend sale via Deal of the Day
Friday, October 28 - Half off all MEAPs - code WM102816LT
Saturday, October 29 ...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New








