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

onelastdance
Hey there, Using the install script method recommended here on Ubuntu 24.04: And then running the following commands: iex> :obser...
New
alexlanderzander
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 Rus...
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
mohammedzeglam
I am trying deploy phoenix app to cloud run every thing works locally fine using public IP but when i deployed to cloud run the app could...
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
klo
Is there any way to go from a float 1.0 to 1.00 while retaining the float() type?
New
rayex
Hi, I am using the following versions: Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] El...
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
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

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New

We're in Beta

About us Mission Statement