BoZhenka
I have some problems with :crypto.verify.
message = 'whatever'
sign = 'zFuf7bRH4RHwyktaqHQwmX5rn3LfSb4dKo'
public_key = 'MIGJAoGBAM1fmNUvezts3yglTdhXuqG7OhHxQtDFA'
:crypto.verify(:rsa, :sha256, message, sign, public_key)
This is give me an ArgumentError, like:
(crypto) :crypto.pkey_verify_nif(:rsa, :sha256, 'whatever', 'zFuf7bRH4RHwyktaqHQwmX5rn3LfSb4dKo', ["M", "I", "G", "J", "A", "o", "G", "B", "A", "M", "1", "f", "m", "N", "U", "v", "e", "z", "t", "s", "3", "y", "g", "l", "T", "d", "h", "X", "u", "q", "G", "7", "O", "h", "H", "x", "Q", "t", "D", "F", "A"], [])
(crypto) crypto.erl:874: :crypto.verify/6
Method :crypto.verify/5 exist, but some reason it’s gave me error about …verify/6
I don’t get it. What should I do for correct working of this?..
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 7 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
bglusman
I don’t think I did verification when I used it, but these kinds of unclear argument errors are the main motivation behind GitHub - ntrepid8/ex_crypto: Wrapper around the Erlang crypto module for Elixir. · GitHub which I contributed a few additional methods to 3 or 4 years back… I’d encourage anyone doing Crypto in Elixir to consider using it, even though it’s easy to use the erlang crypto directly, because it will give much more helpful error messages when things go wrong.
n1c0
perfect the verification worked indeed, the doc is a bit confusing.
Thanks for your help!
voltone
I’m not sure why the API for EdDSA behaves differently, but:
nilis not a thing in Erlang; according to the type spec you can set the second param to:none, though ECDSA requires that you pass in a valid digest type; so set this to:sha256:digesttuple should be the binary digest, not Hex encodedSo this will work:
:crypto.verify(:ecdsa, :sha256, {:digest, hash}, sig, [public, :secp256k1])to verify the original signature using a SHA256 rather than the original message. And to generate a signature::crypto.sign(:ecdsa, :sha256, {:digest, hash}, [secret, :secp256k1])n1c0
Hi all,
catching up on that topic, I am currently facing an issue when I try to sign / verify on a msg that is already a digest.
I generate the
secp256k1keypair, sign a message with it and verify it. so far so good:Now my issue is when instead of passing a plaintext message and a hash algorithm, i want to pass the digest directly, I followed the doc and tried the following:
and i am now trying to sign with the
{:digest, hash_hex}as a parameter, I get the following error:I tried to check if this was my syntax that was wrong by running the same kind of operation with and
ed25519keypair (I used OTP 23 RC3 for that experiment):so it works as expected for
eddsabut not forecdsa, anyone knows what is going on? what I am missing?thanks
voltone
The
public_keyvariable appears to contains a truncated Base64 fragment of a 1024-bit RSA public key. Assuming you actually have the full value you can convert it to anrsa_public()type like this:The signature also appears to be truncated. Given the full Base64 encoded signature you can verify the signature with
:crypto.verify:Note the use of binary strings as opposed to chartists (single quotes), as others have pointed out.
victorolinasc
The function signature of
:crypto.verify/5does not match with your params.First 2 parameters seem to match but your message seems not to be “cleartext” so you’d need to pass it wrapped in a tuple. Your public key also does not match the typespec.
Here is a StackOverflow example: https://stackoverflow.com/a/20509599/1397594
Also note your parameters are passing charlists and not binaries.
idi527
According to crypto — OTP 29.0.2 (crypto 5.9), the message needs to be a binary, not a charlist. As well as signature and it shouldn’t be encoded either. And public key needs to be in the format erlang understands.