1

I am trying to use the function new_with_hash from secp256k1::ecdh::SharedSecret in Rust

but I am getting this error

no function or associated item named `new_with_hash` found for struct `SharedSecret` in the current scope

It seems like the function does not exist anymore. Is there a direct replacement for this method in the new version?

lolplanet
  • 23
  • 4

1 Answers1

2

Based on this PR it was changed to a free function:

Pulls the new_with_hash logic out into a standalone public function that just returns the 64 bytes representing the x,y co-ordinates of the computed shared secret point. Callers are then responsible for hashing this point to get the shared secret

This new function is: shared_secret_point:

Creates a shared point from public key and secret key.

Can be used like SharedSecret but caller is responsible for then hashing the returned buffer. This allows for the use of a custom hash function since SharedSecret uses SHA256.

You can read the PR comments for more about the motivation for the change.

kmdreko
  • 42,554
  • 6
  • 57
  • 106