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 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)
Trending in Questions
Other Trending Topics
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
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
If you simply used the trait in your code without specifying where is it from, does
rust-analyzernot offer you where to import it from?