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:
-
xis the one-time private key. -
Pis the one-time public key (P = x * G). -
H_pis a hash-to-point function that hashes the public keyPto 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)






















