dalek-cryptography / x25519-dalek

X25519 elliptic curve Diffie-Hellman key exchange in pure-Rust, using curve25519-dalek.
BSD 3-Clause "New" or "Revised" License
326 stars 132 forks source link

Alternating values when creating a StaticSecret #126

Closed alanesmizi closed 11 months ago

alanesmizi commented 1 year ago

Perhaps I am missing something but I am getting what for me is unexpected behaviour

let pk1 = StaticSecret::from(avalue);
let pk2 = StaticSecret::from(avalue);

etc, etc... you can create more pks

I would expect pk1 to be equal to pk2, as I invoke the creation of StaticSecret twice with the same value

What I am getting is that the 1st, 3rd, 5th calls give one output, and the 2nd, 4th and 6th, etc, give a slightly different output the difference being in the first bytes.

Is this expected behaviour?

rozbb commented 12 months ago

Thanks for the issue! Indeed, this seems weird, but I'm not entirely sure what's happening. Could you provide a small test case that fails when you run it?

alanesmizi commented 11 months ago

Hi, I just tried to reproduce without success. Please close the issue.