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’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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.
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.
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.
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
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
perfect the verification worked indeed, the doc is a bit confusing.
Thanks for your help!
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.