jedisct1 / libhydrogen

A lightweight, secure, easy-to-use crypto library suitable for constrained environments.
https://libhydrogen.org
Other
631 stars 94 forks source link

Do KK_variant's Three functions perform the signing and public key encryption? #134

Open KamiK2K opened 2 years ago

KamiK2K commented 2 years ago

Hi all,

I am implementing the KK_variant of the key exchange mechanism and I was looking into the function calls.

Since all hydro_kx_kk_1(), hydro_kx_kk_2(), and hydro_kx_kk_3() functions need their peers public key and the local device's key pair, are these functions actually doing encrypt with peer's public key and sign with local private key, along with verify with peer's public key and decrypt using local device's private key?

I might asked my question in a vague way, But I am trying to find out what exactly happening inside these function calls. I looked into all of the function calls and was not able to find out.

I am assuming that client calls hydro_kx_kk_1() and initiates a state and encrypts some information using peer's public key and puts it into packet1;

Then the server calls hydro_kx_kk_2() and receives packet1 and decrypts it using its own private key, then computes the session key pair and encrypts it using client's public key and signs it with its own private key.

after that, the client calls hydro_kx_kk_3() and receives packet2 and verifies the signature using peer's public key and decrypts it using its own private key, then computes the same session key pair.

Is this statement correct?

thanks