paulmillr / micro-key-producer

Produces secure keys and passwords. Supports SSH, PGP, BLS, OTP and many other formats
MIT License
34 stars 9 forks source link

does this lbrary supports non-hardened derivation of a public key ? #12

Closed wighawag closed 1 year ago

wighawag commented 1 year ago

I am looking in generated keys from a parent hd key both from its private key and public key, so that the resulting keys matches

The api seems to only work on keys where the private key is known. any pointer to get non-hardened keys ?

I want something like the function deriveFromPublicKey in the following

derive(parent private key).publickey = deriveFromPublicKey(public key)

paulmillr commented 1 year ago

No. Non-hardened keys have reduced security, we don't support it.

wighawag commented 1 year ago

Thanks for the quick reply

In the mean time I managed to get following working and now I am confused:

const publicOnlyKey = HDKey.fromExtendedKey(hdkey.publicExtendedKey);
const derivedFromPublic = publicOnlyKey.derive("m/0/2147483647/1").publicKey;
const derivedFromPrivate = hdkey.derive("m/0/2147483647/1").publicKey;

is that not supposed to work in this library ?

paulmillr commented 1 year ago

I don't see fromExtendedKey in https://github.com/paulmillr/ed25519-keygen/blob/main/src/hdkey.ts

wighawag commented 1 year ago

Oh sorry, I was reading the doc from there but was using https://github.com/paulmillr/scure-bip32

So I guess for bip32 it is fine