openwsn-berkeley / lakers

EDHOC implemented in Rust, optimized for microcontrollers, with bindings for C and Python.
https://crates.io/crates/lakers
BSD 3-Clause "New" or "Revised" License
13 stars 10 forks source link

Add RNG and generate ephemeral keys #45

Closed geonnave closed 1 year ago

geonnave commented 1 year ago

Addressing #41 and #42.

This PR adds support for generation of ephemeral private keys, as well as derivation of public keys. It also updates prepare_message_1 and prepare_message_2 to accept an ephemeral keypair as parameter.

The implementation differs for each crypto backend:

geonnave commented 1 year ago

Yes, it is because of the different types.

malishav commented 1 year ago

Before invoking the hacspec function, why don't you convert the array to ByteSeq like in https://github.com/openwsn-berkeley/edhoc-rs/blob/main/crypto/edhoc-crypto-hacspec/src/lib.rs#L50? This would avoid code duplication from hacspec

geonnave commented 1 year ago

You are right, fixed.

malishav commented 1 year ago

Since this is now implemented, could you remove the G_X, X, G_Y, Y constants from consts/src/lib.rs for both modules?

geonnave commented 1 year ago

Since this is now implemented, could you remove the G_X, X, G_Y, Y constants from consts/src/lib.rs for both modules?

I can remove Y and G_Y, as I am still using X and G_X for tests.

malishav commented 1 year ago

But why don't you move X and G_X then as test vectors in the test module? They should definitely not appear any more in consts.

geonnave commented 1 year ago

But why don't you move X and G_X then as test vectors in the test module? They should definitely not appear any more in consts.

Sounds good, will do it.

malishav commented 1 year ago

Congrats on getting this ready for merge! Merging now!