alexlanderzander

alexlanderzander

Getting GroupDigest Import Error when trying to implement a function to calculate a key image with Rustler NIF: k256 hash_from_bytes

Hello everyone,

I’m working on a blockchain project in Elixir and I’m implementing some of the core cryptography in a Rust NIF using Rustler.

I’ve hit a wall trying to implement a function to calculate a key image (a component for preventing double-spending in a UTXO model).

The Objective

The goal is to create a NIF get_key_image_from_private_key. This function needs to calculate the key image I using the formula I = x * H_p(P), where:

  • x is the one-time private key.

  • P is the one-time public key (P = x * G).

  • H_p is a hash-to-point function that hashes the public key P to a new point on the elliptic curve.

The Problem

To implement H_p, I’m trying to use the hash_from_bytes function, which seems to be provided by the GroupDigest trait in the elliptic-curve / k256 ecosystem.

Despite having the hash2curve feature enabled for k256 in my Cargo.toml, I cannot find the correct way to import and use this trait. This leads to the compilation error:

error[E0599]: no function or associated item named 'hash_from_bytes' found for struct 'ProjectivePoint' in the current scope

What I’ve Tried

I’ve tried multiple import paths, but none have worked:

  • use k256::elliptic_curve::group::GroupDigest; (Error: unresolved import 'k256::group')

  • use elliptic_curve::group::GroupDigest; (Error: use of unresolved module or unlinked crate 'elliptic_curve')

  • use k256::group::GroupDigest; (Error: could not find 'group' in 'k256')

  • use group::GroupDigest; (Error: no 'GroupDigest' in the root)

First Post!

dimitarvp

dimitarvp

If you simply used the trait in your code without specifying where is it from, does rust-analyzer not offer you where to import it from?

Where Next?

Popular in Troubleshooting Top

chocolatedonut
Besides (over)logging every code-path leading to Repo.insert_all, is it possible to make Postgrex and/or ecto_sql log the exact, failing ...
New
mooreryan
In a project I’m working on, I cannot get tests with breakpoints or pry working. Here is an example in a new mix project. Create a fresh...
New
wktdev
I tried to learn Elixir a few years ago and stopped. I am trying again. In the code below I have a GenServer that is started by a Superv...
New
harmon25
Hi All, I am bumping into a weird issue with an umbrella app while upgrading to latest Elixir 1.19.x + otp28. A couple apps in the umbr...
New
runyonave
We have been stuck on this for a few days now and I am really not sure what could be missing. I can get chromic_pdf to work perfectly fin...
New
arnoldwolfe
I’ve been unable to deploy apps for over a week now due to the following error. It all started when Github has issues with GitHub Actions...
New
Richardm
Hi, I have the following code, and even though I can see (via the inspect) that the response_body does contain one of the strings I’m lo...
New
onelastdance
Hey there, Using the install script method recommended here on Ubuntu 24.04: And then running the following commands: iex> :obser...
New
klo
Is there any way to go from a float 1.0 to 1.00 while retaining the float() type?
New
apoorv-2204
The Issue of Enums in Elixir Elixir doesn’t have a native enum construct, so we usually rely on atoms, strings, or macros to represent na...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
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
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Fl4m3Ph03n1x
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
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement