aead / ecdh

A generic ECDH implementation
MIT License
57 stars 16 forks source link

Change Size of Keys #2

Open dfense opened 7 years ago

dfense commented 7 years ago

I have a current project that uses ECDH from this embedded library and was hoping to get your library to talk to it.

https://github.com/kmackay/micro-ecc

Ironically it uses different key sizes, exact opposite as your library.

Public Key (64 bytes) Private Key (32 bytes)

I believe it's due to the way the github library defaulted. I am not familiar enough with the algorithm to know, in all the places you have a hard coded in size, how much would get corrupted by making the change and if the hash etc belongs to one of the key sizes.

Is it possible to wrap your sizes in a const () at the top, and make it easily changable ?

aead commented 7 years ago

As far as I can see the micro-ecc library uses the NIST curves secp160r1 - secp256r1, and secp256k1. The NIST curves P224 - P521 are directly supported - see the elliptic package, but there are no "hard coded key sizes".

The X25519 KeyExchange (using djb's curve25519) uses the hard-coded size of 32 byte. (because X25519 uses only the X-coordinates)

If you want to do a key exchange between this library and the micro-ecc library, you can use one of the NIST curves (secp224r1 - secp521r1) and it should work - if not I need more details about what you do?